--- ray/src/rt/rpict.c 1993/11/18 09:22:55 2.31 +++ ray/src/rt/rpict.c 1993/12/12 13:56:08 2.36 @@ -1,4 +1,4 @@ -/* Copyright (c) 1992 Regents of the University of California */ +/* Copyright (c) 1993 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -12,20 +12,21 @@ static char SCCSid[] = "$SunId$ LBL"; #include "ray.h" +#include + #ifndef NIX #ifdef BSD #include #include #else -#include #include -#include -extern time_t time(); +#include +#include #endif -#else -extern unsigned long time(); #endif +extern time_t time(); + #include #include "view.h" @@ -86,9 +87,9 @@ int ralrm = 0; /* seconds between reports */ double pctdone = 0.0; /* percentage done */ -unsigned long tlastrept = 0L; /* time at last report */ +time_t tlastrept = 0L; /* time at last report */ -extern unsigned long tstart; /* starting time */ +extern time_t tstart; /* starting time */ extern unsigned long nrays; /* number of rays traced */ @@ -132,15 +133,18 @@ int code; #ifndef NIX report() /* report progress */ { - char hostname[128]; double u, s; #ifdef BSD + char hostname[257]; struct rusage rubuf; #else struct tms tbuf; + struct utsname nambuf; + double period; +#define hostname nambuf.nodename #endif - tlastrept = time((unsigned long *)NULL); + tlastrept = time((time_t *)NULL); #ifdef BSD getrusage(RUSAGE_SELF, &rubuf); u = rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6; @@ -148,27 +152,36 @@ report() /* report progress */ getrusage(RUSAGE_CHILDREN, &rubuf); u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6; s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6; + gethostname(hostname, sizeof(hostname)); #else times(&tbuf); - u = ( tbuf.tms_utime + tbuf.tms_cutime ) / CLK_TCK; - s = ( tbuf.tms_stime + tbuf.tms_cstime ) / CLK_TCK; +#ifdef _SC_CLK_TCK + period = 1.0 / sysconf(_SC_CLK_TCK); +#else + period = 1.0 / 60.0; #endif - gethostname(hostname, sizeof(hostname)); + u = ( tbuf.tms_utime + tbuf.tms_cutime ) * period; + s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period; + uname(&nambuf); +#endif sprintf(errmsg, "%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s\n", nrays, pctdone, u/3600., s/3600., (tlastrept-tstart)/3600., hostname); eputs(errmsg); +#ifndef BSD + signal(SIGCONT, report); +#undef hostname +#endif } #else report() /* report progress */ { - tlastrept = time((unsigned long *)NULL); + tlastrept = time((time_t *)NULL); sprintf(errmsg, "%lu rays, %4.2f%% after %5.4f hours\n", nrays, pctdone, (tlastrept-tstart)/3600.0); eputs(errmsg); - signal(SIGCONT, report); } #endif @@ -424,7 +437,7 @@ char *zfile, *oldfile; goto writerr; /* record progress */ pctdone = 100.0*(vres-1-ypos)/vres; - if (ralrm > 0 && time((unsigned long *)NULL) >= tlastrept+ralrm) + if (ralrm > 0 && time((time_t *)NULL) >= tlastrept+ralrm) report(); #ifndef BSD else