From: CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 23-MAY-1989 02:31 To: MRGATE::"ARISIA::EVERHART" Subj: VMS record formats and VAXC Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Mon, 22 MAY 89 13:13:22 PDT Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Mon, 22 May 89 12:48:54 PDT Received: by ucbvax.Berkeley.EDU (5.61/1.36) id AA20820; Mon, 22 May 89 12:30:31 -0700 Received: from USENET by ucbvax.Berkeley.EDU with netnews for info-vax@kl.sri.com (info-vax@kl.sri.com) (contact usenet@ucbvax.Berkeley.EDU if you have questions) Date: 22 May 89 18:58:11 GMT From: gjc@bu-cs.bu.edu (George J. Carrette) Organization: Boston U. Comp. Sci. Subject: VMS record formats and VAXC Message-Id: <31586@bu-cs.BU.EDU> References: <685@marob.MASA.COM> Sender: info-vax-request@kl.sri.com To: info-vax@kl.sri.com A straight fopen(x,"wb") is a pretty darn good approximation to unix fopen(x,"w"). However, many programs written before the stream_* format was available in RMS would use a straight "unstructured" 512 byte fixed record file with no record attributes. When I write a "binary" "data-file" from VAXC I prefer to use the following: fopen(name,"wb","mrs=512","rfm=fix","ctx=rec"); Then, if you want extra speed, use macro versions of getc and putc! (Note: This getc will return extra characters at the end of some kinds of RMS files.) First fix iobuf in stdio.h to have unsigned char for _ptr and _base instead of char. Then: #define xgetc(p) (--(*p)->_cnt>=0?((int)*(*p)->_ptr++):xfilbuf(p)) #define xputc(x,p) \ (--(*p)->_cnt>=0?(int)(*(*p)->_ptr++=(unsigned char)(x)): \ xflsbuf((unsigned char)(x),p)) Now xfilbuf and xflsbuf both work by setting (*p)->_cnt = 0 and then calling fgetc and fputc. The speed-up when using these macro getc and putc over using the DIGITAL implementations, which turn into fgetc and fputc, is VERY LARGE indeed. Q: Has DIGITAL made any improvements here in the latest releases of the VAXC compiler? I'm still using V2.3 myself. Q: Can anyone figure out why a "FILE *" in VAXC is a pointer to a pointer to an iobuf, instead of just being a pointer to an iobuf? What is gained by having an extra level of indirection? -gjc