--- ray/src/common/portio.c 1996/11/15 16:17:05 2.4 +++ ray/src/common/portio.c 2003/12/09 15:51:42 2.10 @@ -1,23 +1,27 @@ -/* 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.10 2003/12/09 15:51:42 greg Exp $"; #endif - /* * Portable i/o for binary files + * + * External symbols declared in standard.h */ +#include "copyright.h" + #include -#ifndef frexp -extern double frexp(); +#include "rtio.h" + +#include + +#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ +#define getc getc_unlocked +#define putc putc_unlocked #endif -#ifndef ldexp -extern double ldexp(); -#endif +void putstr(s, fp) /* write null-terminated string to fp */ register char *s; register FILE *fp; @@ -28,6 +32,7 @@ register FILE *fp; } +void putint(i, siz, fp) /* write a siz-byte integer to fp */ long i; register int siz; @@ -38,6 +43,7 @@ register FILE *fp; } +void putflt(f, fp) /* put out floating point number */ double f; FILE *fp; @@ -91,8 +97,10 @@ double getflt(fp) /* get a floating point number */ FILE *fp; { + long l; double d; - d = (getint(4, fp) + .5) / 0x7fffffff; + l = getint(4, fp); + d = (l + (l > 0 ? .5 : -.5)) * (1./0x7fffffff); return(ldexp(d, (int)getint(1, fp))); }