@@ -340,6 +340,9 @@ #define ONETHIRD 0.333333333333333333333333333333333333333333333333333333333333 +/* Define type large enough to handle pointer. */ +#define INT_PTR unsigned long long + #include #include #include @@ -938,16 +941,16 @@ /* extracted from the two least significant bits of the pointer. */ #define decode(ptr, otri) \ - (otri).orient = (int) ((unsigned long) (ptr) & (unsigned long) 3l); \ + (otri).orient = (int) ((INT_PTR) (ptr) & (INT_PTR) 3l); \ (otri).tri = (triangle *) \ - ((unsigned long) (ptr) ^ (unsigned long) (otri).orient) + ((INT_PTR) (ptr) ^ (INT_PTR) (otri).orient) /* encode() compresses an oriented triangle into a single pointer. It */ /* relies on the assumption that all triangles are aligned to four-byte */ /* boundaries, so the two least significant bits of (otri).tri are zero. */ #define encode(otri) \ - (triangle) ((unsigned long) (otri).tri | (unsigned long) (otri).orient) + (triangle) ((INT_PTR) (otri).tri | (INT_PTR) (otri).orient) /* The following handle manipulation primitives are all described by Guibas */ /* and Stolfi. However, Guibas and Stolfi use an edge-based data */ @@ -1111,16 +1114,16 @@ #define infect(otri) \ (otri).tri[6] = (triangle) \ - ((unsigned long) (otri).tri[6] | (unsigned long) 2l) + ((INT_PTR) (otri).tri[6] | (INT_PTR) 2l) #define uninfect(otri) \ (otri).tri[6] = (triangle) \ - ((unsigned long) (otri).tri[6] & ~ (unsigned long) 2l) + ((INT_PTR) (otri).tri[6] & ~ (INT_PTR) 2l) /* Test a triangle for viral infection. */ #define infected(otri) \ - (((unsigned long) (otri).tri[6] & (unsigned long) 2l) != 0l) + (((INT_PTR) (otri).tri[6] & (INT_PTR) 2l) != 0l) /* Check or set a triangle's attributes. */ @@ -1158,16 +1161,16 @@ /* are masked out to produce the real pointer. */ #define sdecode(sptr, osub) \ - (osub).ssorient = (int) ((unsigned long) (sptr) & (unsigned long) 1l); \ + (osub).ssorient = (int) ((INT_PTR) (sptr) & (INT_PTR) 1l); \ (osub).ss = (subseg *) \ - ((unsigned long) (sptr) & ~ (unsigned long) 3l) + ((INT_PTR) (sptr) & ~ (INT_PTR) 3l) /* sencode() compresses an oriented subsegment into a single pointer. It */ /* relies on the assumption that all subsegments are aligned to two-byte */ /* boundaries, so the least significant bit of (osub).ss is zero. */ #define sencode(osub) \ - (subseg) ((unsigned long) (osub).ss | (unsigned long) (osub).ssorient) + (subseg) ((INT_PTR) (osub).ss | (INT_PTR) (osub).ssorient) /* ssym() toggles the orientation of a subsegment. */ @@ -3891,7 +3894,7 @@ #endif /* not ANSI_DECLARATORS */ { - unsigned long alignptr; + INT_PTR alignptr = 0; pool->items = 0; pool->maxitems = 0; @@ -3899,11 +3902,11 @@ /* Set the currently active block. */ pool->nowblock = pool->firstblock; /* Find the first item in the pool. Increment by the size of (VOID *). */ - alignptr = (unsigned long) (pool->nowblock + 1); + alignptr = (INT_PTR) (pool->nowblock + 1); /* Align the item on an `alignbytes'-byte boundary. */ pool->nextitem = (VOID *) - (alignptr + (unsigned long) pool->alignbytes - - (alignptr % (unsigned long) pool->alignbytes)); + (alignptr + (INT_PTR) pool->alignbytes - + (alignptr % (INT_PTR) pool->alignbytes)); /* There are lots of unallocated items left in this block. */ pool->unallocateditems = pool->itemsfirstblock; /* The stack of deallocated items is empty. */ @@ -4008,7 +4011,7 @@ { VOID *newitem; VOID **newblock; - unsigned long alignptr; + INT_PTR alignptr = 0; /* First check the linked list of dead items. If the list is not */ /* empty, allocate an item from the list rather than a fresh one. */ @@ -4033,11 +4036,11 @@ pool->nowblock = (VOID **) *(pool->nowblock); /* Find the first item in the block. */ /* Increment by the size of (VOID *). */ - alignptr = (unsigned long) (pool->nowblock + 1); + alignptr = (INT_PTR) (pool->nowblock + 1); /* Align the item on an `alignbytes'-byte boundary. */ pool->nextitem = (VOID *) - (alignptr + (unsigned long) pool->alignbytes - - (alignptr % (unsigned long) pool->alignbytes)); + (alignptr + (INT_PTR) pool->alignbytes - + (alignptr % (INT_PTR) pool->alignbytes)); /* There are lots of unallocated items left in this block. */ pool->unallocateditems = pool->itemsperblock; } @@ -4092,16 +4095,16 @@ #endif /* not ANSI_DECLARATORS */ { - unsigned long alignptr; + INT_PTR alignptr = 0; /* Begin the traversal in the first block. */ pool->pathblock = pool->firstblock; /* Find the first item in the block. Increment by the size of (VOID *). */ - alignptr = (unsigned long) (pool->pathblock + 1); + alignptr = (INT_PTR) (pool->pathblock + 1); /* Align with item on an `alignbytes'-byte boundary. */ pool->pathitem = (VOID *) - (alignptr + (unsigned long) pool->alignbytes - - (alignptr % (unsigned long) pool->alignbytes)); + (alignptr + (INT_PTR) pool->alignbytes - + (alignptr % (INT_PTR) pool->alignbytes)); /* Set the number of items left in the current block. */ pool->pathitemsleft = pool->itemsfirstblock; } @@ -4129,7 +4132,7 @@ { VOID *newitem; - unsigned long alignptr; + INT_PTR alignptr = 0; /* Stop upon exhausting the list of items. */ if (pool->pathitem == pool->nextitem) { @@ -4141,11 +4144,11 @@ /* Find the next block. */ pool->pathblock = (VOID **) *(pool->pathblock); /* Find the first item in the block. Increment by the size of (VOID *). */ - alignptr = (unsigned long) (pool->pathblock + 1); + alignptr = (INT_PTR) (pool->pathblock + 1); /* Align with item on an `alignbytes'-byte boundary. */ pool->pathitem = (VOID *) - (alignptr + (unsigned long) pool->alignbytes - - (alignptr % (unsigned long) pool->alignbytes)); + (alignptr + (INT_PTR) pool->alignbytes - + (alignptr % (INT_PTR) pool->alignbytes)); /* Set the number of items left in the current block. */ pool->pathitemsleft = pool->itemsperblock; } @@ -4197,16 +4200,16 @@ #endif /* not ANSI_DECLARATORS */ { - unsigned long alignptr; + INT_PTR alignptr = 0; /* Set up `dummytri', the `triangle' that occupies "outer space." */ m->dummytribase = (triangle *) trimalloc(trianglebytes + m->triangles.alignbytes); /* Align `dummytri' on a `triangles.alignbytes'-byte boundary. */ - alignptr = (unsigned long) m->dummytribase; + alignptr = (INT_PTR) m->dummytribase; m->dummytri = (triangle *) - (alignptr + (unsigned long) m->triangles.alignbytes - - (alignptr % (unsigned long) m->triangles.alignbytes)); + (alignptr + (INT_PTR) m->triangles.alignbytes - + (alignptr % (INT_PTR) m->triangles.alignbytes)); /* Initialize the three adjoining triangles to be "outer space." These */ /* will eventually be changed by various bonding operations, but their */ /* values don't really matter, as long as they can legally be */ @@ -4226,10 +4229,10 @@ m->dummysubbase = (subseg *) trimalloc(subsegbytes + m->subsegs.alignbytes); /* Align `dummysub' on a `subsegs.alignbytes'-byte boundary. */ - alignptr = (unsigned long) m->dummysubbase; + alignptr = (INT_PTR) m->dummysubbase; m->dummysub = (subseg *) - (alignptr + (unsigned long) m->subsegs.alignbytes - - (alignptr % (unsigned long) m->subsegs.alignbytes)); + (alignptr + (INT_PTR) m->subsegs.alignbytes - + (alignptr % (INT_PTR) m->subsegs.alignbytes)); /* Initialize the two adjoining subsegments to be the omnipresent */ /* subsegment. These will eventually be changed by various bonding */ /* operations, but their values don't really matter, as long as they */ @@ -4586,7 +4589,7 @@ { VOID **getblock; char *foundvertex; - unsigned long alignptr; + INT_PTR alignptr = 0; int current; getblock = m->vertices.firstblock; @@ -4603,9 +4606,9 @@ } /* Now find the right vertex. */ - alignptr = (unsigned long) (getblock + 1); - foundvertex = (char *) (alignptr + (unsigned long) m->vertices.alignbytes - - (alignptr % (unsigned long) m->vertices.alignbytes)); + alignptr = (INT_PTR) (getblock + 1); + foundvertex = (char *) (alignptr + (INT_PTR) m->vertices.alignbytes - + (alignptr % (INT_PTR) m->vertices.alignbytes)); return (vertex) (foundvertex + m->vertices.itembytes * (number - current)); } @@ -7649,7 +7652,7 @@ char *firsttri; struct otri sampletri; vertex torg, tdest; - unsigned long alignptr; + INT_PTR alignptr = 0; REAL searchdist, dist; REAL ahead; long samplesperblock, totalsamplesleft, samplesleft; @@ -7721,11 +7724,11 @@ population = totalpopulation; } /* Find a pointer to the first triangle in the block. */ - alignptr = (unsigned long) (sampleblock + 1); + alignptr = (INT_PTR) (sampleblock + 1); firsttri = (char *) (alignptr + - (unsigned long) m->triangles.alignbytes - + (INT_PTR) m->triangles.alignbytes - (alignptr % - (unsigned long) m->triangles.alignbytes)); + (INT_PTR) m->triangles.alignbytes)); /* Choose `samplesleft' randomly sampled triangles in this block. */ do {