36 |
|
#include "ray.h" |
37 |
|
#include <string.h> |
38 |
|
|
39 |
+ |
#ifndef MAXFIFO |
40 |
+ |
#define MAXFIFO 4096 /* clear FIFO past this */ |
41 |
+ |
#endif |
42 |
+ |
|
43 |
|
int (*ray_fifo_out)(RAY *r) = NULL; /* ray output callback */ |
44 |
|
|
45 |
|
static RAY *r_fifo_buf = NULL; /* circular FIFO out buffer */ |
59 |
|
int i; |
60 |
|
|
61 |
|
if (r_fifo_buf == NULL) |
62 |
< |
r_fifo_len = 1<<5; |
62 |
> |
r_fifo_len = 1<<5; /* must be power of two */ |
63 |
|
else |
64 |
|
r_fifo_len <<= 1; |
65 |
|
/* allocate new */ |
124 |
|
if (incall++) |
125 |
|
error(INTERNAL, "recursive call to ray_fifo_in()"); |
126 |
|
|
127 |
< |
if (r_fifo_start >= 1L<<30) { /* reset our counters */ |
127 |
> |
/* need to reset our FIFO? */ |
128 |
> |
if ((r_fifo_start >= 1L<<30) | (r_fifo_len > MAXFIFO)) { |
129 |
|
if ((rv = ray_fifo_flush()) < 0) |
130 |
|
{--incall; return(-1);} |
131 |
|
rval += rv; |