ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
(Generate patch)

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.51 by gwlarson, Thu Aug 5 19:20:10 1999 UTC vs.
Revision 3.62 by schorsch, Tue Oct 21 19:19:28 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1999 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Radiance holodeck generation controller
6   */
7  
11 #include "rholo.h"
12 #include "random.h"
8   #include <signal.h>
9   #include <sys/stat.h>
10 + #include <string.h>
11  
12 + #include "rholo.h"
13 + #include "platform.h"
14 + #include "random.h"
15 +
16   #ifndef FRAGWARN
17   #define FRAGWARN        20              /* fragmentation for warning (%) */
18   #endif
# Line 48 | Line 48 | time_t starttime;              /* time we got started */
48   time_t  endtime;                /* time we should end by */
49   time_t  reporttime;             /* time for next report */
50  
51 < long    maxdisk;                /* maximum file space (bytes) */
51 > off_t   maxdisk;                /* maximum file space (bytes) */
52  
53   int     rtargc = 1;             /* rtrace command */
54   char    *rtargv[128] = {"rtrace", NULL};
# Line 155 | Line 155 | userr:
155   }
156  
157  
158 + void
159   onsig(signo)                            /* fatal signal */
160   int  signo;
161   {
# Line 217 | Line 218 | initrholo()                    /* get our holodeck running */
218                  init_global();
219                                                  /* record disk space limit */
220          if (!vdef(DISKSPACE))
221 <                maxdisk = 0;
221 >                maxdisk = ((off_t)1<<(sizeof(off_t)*8-2)) - 1024;
222          else
223                  maxdisk = 1024.*1024.*vflt(DISKSPACE);
224                                                  /* set up memory cache */
# Line 269 | Line 270 | initrholo()                    /* get our holodeck running */
270          }
271                                          /* set up signal handling */
272          sigdie(SIGINT, "Interrupt");
272        sigdie(SIGHUP, "Hangup");
273          sigdie(SIGTERM, "Terminate");
274 + #ifdef SIGHUP
275 +        sigdie(SIGHUP, "Hangup");
276 + #endif
277 + #ifdef SIGPIPE
278          sigdie(SIGPIPE, "Broken pipe");
279 + #endif
280 + #ifdef SIGALRM
281          sigdie(SIGALRM, "Alarm clock");
282 + #endif
283   #ifdef  SIGXCPU
284          sigdie(SIGXCPU, "CPU limit exceeded");
285 + #endif
286 + #ifdef  SIGXFSZ
287          sigdie(SIGXFSZ, "File size exceeded");
288   #endif
289                                          /* protect holodeck file */
290 <        orig_mode = resfmode(hdlist[0]->fd, ncprocs>0 ? 0 : 0444);
290 >        orig_mode = resfmode(hdlist[0]->fd, (ncprocs>0) & (force>=0) ? 0 : 0444);
291          return;
292   memerr:
293          error(SYSTEM, "out of memory in initrholo");
# Line 290 | Line 299 | rholo()                                /* holodeck main loop */
299          static long     nextfragwarn = 100*(1L<<20);
300          static int      idle = 0;
301          PACKET  *pl = NULL, *plend;
302 <        long    fsiz;
302 >        off_t   fsiz;
303          int     pksiz;
304          register PACKET *p;
305          time_t  t;
# Line 415 | Line 424 | creatholo(gp)                  /* create a holodeck output file */
424   HDGRID  *gp;
425   {
426          extern char     VersionID[];
427 <        int4    lastloc, nextloc;
427 >        int32   lastloc, nextloc;
428          int     n;
429          int     fd;
430          FILE    *fp;
# Line 433 | Line 442 | HDGRID *gp;
442          putw(HOLOMAGIC, fp);            /* put magic number */
443          fd = dup(fileno(fp));
444          fclose(fp);                     /* flush and close stdio stream */
445 <        lastloc = lseek(fd, 0L, 2);
445 >        lastloc = lseek(fd, (off_t)0, SEEK_END);
446          for (n = vdef(SECTION); n--; gp++) {    /* initialize each section */
447                  nextloc = 0L;
448                  write(fd, (char *)&nextloc, sizeof(nextloc));
# Line 441 | Line 450 | HDGRID *gp;
450                  if (!n)
451                          break;
452                  nextloc = hdfilen(fd);          /* write section pointer */
453 <                if (lseek(fd, (long)lastloc, 0) < 0)
453 >                if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0)
454                          error(SYSTEM,
455                                  "cannot seek on holodeck file in creatholo");
456                  write(fd, (char *)&nextloc, sizeof(nextloc));
457 <                lseek(fd, (long)(lastloc=nextloc), 0);
457 >                lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET);
458          }
459   }
460  
# Line 478 | Line 487 | char   *s;
487  
488   loadholo()                      /* start loading a holodeck from fname */
489   {
481        extern long     ftell();
490          FILE    *fp;
491          int     fd;
492          int     n;
493 <        int4    nextloc;
493 >        int32   nextloc;
494          
495 <        if (ncprocs > 0 & force >= 0)
495 >        if ((ncprocs > 0) & (force >= 0))
496                  fp = fopen(hdkfile, "r+");
497          else
498                  fp = NULL;
# Line 513 | Line 521 | loadholo()                     /* start loading a holodeck from fname */
521          fd = dup(fileno(fp));
522          fclose(fp);                             /* done with stdio */
523          for (n = 0; nextloc > 0L; n++) {        /* initialize each section */
524 <                lseek(fd, (long)nextloc, 0);
524 >                lseek(fd, (off_t)nextloc, SEEK_SET);
525                  read(fd, (char *)&nextloc, sizeof(nextloc));
526                  hdinit(fd, NULL);
527          }
# Line 534 | Line 542 | PACKET *pl;
542          while (pl != NULL) {
543                  p = pl; pl = p->next; p->next = NULL;
544                  if (p->nr > 0) {                /* add to holodeck */
545 <                        bcopy((char *)p->ra,
546 <                                (char *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
545 >                        memcpy( (void *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
546 >                                (void *)p->ra,
547                                  p->nr*sizeof(RAYVAL));
548                          if (outdev != NULL)     /* display it */
549                                  disp_packet((PACKHEAD *)p);
# Line 563 | Line 571 | register char  *rn, *fn;
571   {
572          char    *tp, *dp;
573  
574 <        for (tp = NULL, dp = rn; *rn = *fn++; rn++)
574 >        for (tp = NULL, dp = rn; (*rn = *fn++); rn++) {
575                  if (*rn == '/')
576                          dp = rn;
577                  else if (*rn == '.')
578                          tp = rn;
579 +        }
580          if (tp != NULL && tp > dp)
581                  *tp = '\0';
582   }
# Line 581 | Line 590 | int    vc;
590   }
591  
592  
593 + void
594   eputs(s)                        /* put error message to stderr */
595   register char  *s;
596   {
# Line 600 | Line 610 | register char  *s;
610   }
611  
612  
613 + void
614   quit(ec)                        /* exit program gracefully */
615   int     ec;
616   {
# Line 608 | Line 619 | int    ec;
619          if (hdlist[0] != NULL) {        /* close holodeck */
620                  if (nprocs > 0)
621                          status = done_rtrace();         /* calls hdsync() */
622 <                if (ncprocs > 0 & force >= 0 && vdef(REPORT)) {
623 <                        long    fsiz, fuse;
622 >                if ((ncprocs > 0) & (force >= 0) && vdef(REPORT)) {
623 >                        off_t   fsiz, fuse;
624                          fsiz = hdfilen(hdlist[0]->fd);
625                          fuse = hdfiluse(hdlist[0]->fd, 1);
626                          fprintf(stderr,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines