1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Bundle holodeck beams together into clumps. |
6 |
|
*/ |
17 |
|
|
18 |
|
#define nextneigh() (bneighrem<=0 ? 0 : bneighlist[--bneighrem]) |
19 |
|
|
23 |
– |
static BEAMI *beamdir; |
20 |
|
|
25 |
– |
|
21 |
|
gcshifti(gc, ia, di, hp) /* shift cell row or column */ |
22 |
|
register GCOORD *gc; |
23 |
|
int ia, di; |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
< |
static int |
101 |
< |
bpcmp(b1p, b2p) /* compare beam positions on disk */ |
102 |
< |
int *b1p, *b2p; |
103 |
< |
{ |
104 |
< |
register long pdif = beamdir[*b1p].fo - beamdir[*b2p].fo; |
105 |
< |
|
106 |
< |
if (pdif > 0L) return(1); |
107 |
< |
if (pdif < 0L) return(-1); |
108 |
< |
return(0); |
109 |
< |
} |
110 |
< |
|
111 |
< |
|
112 |
< |
clumpbeams(hp, maxcnt, maxsiz, bf) /* clump beams from hinp */ |
95 |
> |
clumpbeams(hp, maxcnt, maxsiz, cf) /* clump beams from hinp */ |
96 |
|
register HOLO *hp; |
97 |
|
int maxcnt, maxsiz; |
98 |
< |
int (*bf)(); |
98 |
> |
int (*cf)(); |
99 |
|
{ |
100 |
|
static short primes[] = {9431,6803,4177,2659,1609,887,587,251,47,1}; |
101 |
< |
HDBEAMI bis; |
119 |
< |
BEAM *bp; |
120 |
< |
unsigned int4 *bflags; |
101 |
> |
uint32 *bflags; |
102 |
|
int *bqueue; |
103 |
|
int bqlen; |
104 |
< |
int4 bqtotal; |
104 |
> |
int32 bqtotal; |
105 |
|
int bc, bci, bqc, myprime; |
106 |
|
register int i; |
107 |
|
/* get clump size */ |
110 |
|
maxsiz /= sizeof(RAYVAL); |
111 |
|
/* allocate beam queue */ |
112 |
|
bqueue = (int *)malloc(maxcnt*sizeof(int)); |
113 |
< |
bflags = (unsigned int4 *)calloc((nbeams(hp)>>5)+1, |
114 |
< |
sizeof(unsigned int4)); |
113 |
> |
bflags = (uint32 *)calloc((nbeams(hp)>>5)+1, |
114 |
> |
sizeof(uint32)); |
115 |
|
if (bqueue == NULL | bflags == NULL) |
116 |
|
error(SYSTEM, "out of memory in clumpbeams"); |
117 |
|
/* mark empty beams as done */ |
150 |
|
if (i > 0) |
151 |
|
break; |
152 |
|
} |
153 |
< |
beamdir = hp->bi; /* sort queue */ |
173 |
< |
qsort((char *)bqueue, bqlen, sizeof(*bqueue), bpcmp); |
174 |
< |
/* transfer each beam */ |
175 |
< |
for (i = 0; i < bqlen; i++) { |
176 |
< |
bp = hdgetbeam(bis.h=hp, bis.b=bqueue[i]); |
177 |
< |
(*bf)(bp, &bis); |
178 |
< |
} |
179 |
< |
hdfreebeam(NULL, 0); /* write & free clump */ |
153 |
> |
(*cf)(hp, bqueue, bqlen); /* transfer clump */ |
154 |
|
} |
155 |
< |
hdsync(NULL, 0); /* we're done -- clean up */ |
156 |
< |
free((char *)bqueue); |
157 |
< |
free((char *)bflags); |
155 |
> |
/* all done; clean up */ |
156 |
> |
free((void *)bqueue); |
157 |
> |
free((void *)bflags); |
158 |
|
} |