--- ray/src/common/portio.c 1992/09/21 12:02:23 2.2 +++ ray/src/common/portio.c 2004/09/14 02:53:50 2.11 @@ -1,16 +1,29 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: portio.c,v 2.11 2004/09/14 02:53:50 greg Exp $"; #endif - /* * Portable i/o for binary files + * + * External symbols declared in standard.h */ +#include "copyright.h" + #include +#include "rtio.h" +#include + +#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ +#undef getc +#undef putc +#define getc getc_unlocked +#define putc putc_unlocked +#endif + + +void putstr(s, fp) /* write null-terminated string to fp */ register char *s; register FILE *fp; @@ -21,6 +34,7 @@ register FILE *fp; } +void putint(i, siz, fp) /* write a siz-byte integer to fp */ long i; register int siz; @@ -31,11 +45,11 @@ register FILE *fp; } +void putflt(f, fp) /* put out floating point number */ double f; FILE *fp; { - extern double frexp(); int e; putint((long)(frexp(f,&e)*0x7fffffff), 4, fp); @@ -85,9 +99,10 @@ double getflt(fp) /* get a floating point number */ FILE *fp; { - extern double ldexp(); + long l; double d; - d = (double)getint(4, fp)/0x7fffffff; + l = getint(4, fp); + d = (l + (l > 0 ? .5 : -.5)) * (1./0x7fffffff); return(ldexp(d, (int)getint(1, fp))); }