[28016] | 1 | @@ -340,6 +340,9 @@
|
---|
| 2 |
|
---|
| 3 | #define ONETHIRD 0.333333333333333333333333333333333333333333333333333333333333
|
---|
| 4 |
|
---|
| 5 | +/* Define type large enough to handle pointer. */
|
---|
| 6 | +#define INT_PTR unsigned long long
|
---|
| 7 | +
|
---|
| 8 | #include <stdio.h>
|
---|
| 9 | #include <stdlib.h>
|
---|
| 10 | #include <string.h>
|
---|
| 11 | @@ -938,16 +941,16 @@
|
---|
| 12 | /* extracted from the two least significant bits of the pointer. */
|
---|
| 13 |
|
---|
| 14 | #define decode(ptr, otri) \
|
---|
| 15 | - (otri).orient = (int) ((unsigned long) (ptr) & (unsigned long) 3l); \
|
---|
| 16 | + (otri).orient = (int) ((INT_PTR) (ptr) & (INT_PTR) 3l); \
|
---|
| 17 | (otri).tri = (triangle *) \
|
---|
| 18 | - ((unsigned long) (ptr) ^ (unsigned long) (otri).orient)
|
---|
| 19 | + ((INT_PTR) (ptr) ^ (INT_PTR) (otri).orient)
|
---|
| 20 |
|
---|
| 21 | /* encode() compresses an oriented triangle into a single pointer. It */
|
---|
| 22 | /* relies on the assumption that all triangles are aligned to four-byte */
|
---|
| 23 | /* boundaries, so the two least significant bits of (otri).tri are zero. */
|
---|
| 24 |
|
---|
| 25 | #define encode(otri) \
|
---|
| 26 | - (triangle) ((unsigned long) (otri).tri | (unsigned long) (otri).orient)
|
---|
| 27 | + (triangle) ((INT_PTR) (otri).tri | (INT_PTR) (otri).orient)
|
---|
| 28 |
|
---|
| 29 | /* The following handle manipulation primitives are all described by Guibas */
|
---|
| 30 | /* and Stolfi. However, Guibas and Stolfi use an edge-based data */
|
---|
| 31 | @@ -1111,16 +1114,16 @@
|
---|
| 32 |
|
---|
| 33 | #define infect(otri) \
|
---|
| 34 | (otri).tri[6] = (triangle) \
|
---|
| 35 | - ((unsigned long) (otri).tri[6] | (unsigned long) 2l)
|
---|
| 36 | + ((INT_PTR) (otri).tri[6] | (INT_PTR) 2l)
|
---|
| 37 |
|
---|
| 38 | #define uninfect(otri) \
|
---|
| 39 | (otri).tri[6] = (triangle) \
|
---|
| 40 | - ((unsigned long) (otri).tri[6] & ~ (unsigned long) 2l)
|
---|
| 41 | + ((INT_PTR) (otri).tri[6] & ~ (INT_PTR) 2l)
|
---|
| 42 |
|
---|
| 43 | /* Test a triangle for viral infection. */
|
---|
| 44 |
|
---|
| 45 | #define infected(otri) \
|
---|
| 46 | - (((unsigned long) (otri).tri[6] & (unsigned long) 2l) != 0l)
|
---|
| 47 | + (((INT_PTR) (otri).tri[6] & (INT_PTR) 2l) != 0l)
|
---|
| 48 |
|
---|
| 49 | /* Check or set a triangle's attributes. */
|
---|
| 50 |
|
---|
| 51 | @@ -1158,16 +1161,16 @@
|
---|
| 52 | /* are masked out to produce the real pointer. */
|
---|
| 53 |
|
---|
| 54 | #define sdecode(sptr, osub) \
|
---|
| 55 | - (osub).ssorient = (int) ((unsigned long) (sptr) & (unsigned long) 1l); \
|
---|
| 56 | + (osub).ssorient = (int) ((INT_PTR) (sptr) & (INT_PTR) 1l); \
|
---|
| 57 | (osub).ss = (subseg *) \
|
---|
| 58 | - ((unsigned long) (sptr) & ~ (unsigned long) 3l)
|
---|
| 59 | + ((INT_PTR) (sptr) & ~ (INT_PTR) 3l)
|
---|
| 60 |
|
---|
| 61 | /* sencode() compresses an oriented subsegment into a single pointer. It */
|
---|
| 62 | /* relies on the assumption that all subsegments are aligned to two-byte */
|
---|
| 63 | /* boundaries, so the least significant bit of (osub).ss is zero. */
|
---|
| 64 |
|
---|
| 65 | #define sencode(osub) \
|
---|
| 66 | - (subseg) ((unsigned long) (osub).ss | (unsigned long) (osub).ssorient)
|
---|
| 67 | + (subseg) ((INT_PTR) (osub).ss | (INT_PTR) (osub).ssorient)
|
---|
| 68 |
|
---|
| 69 | /* ssym() toggles the orientation of a subsegment. */
|
---|
| 70 |
|
---|
| 71 | @@ -3891,7 +3894,7 @@
|
---|
| 72 | #endif /* not ANSI_DECLARATORS */
|
---|
| 73 |
|
---|
| 74 | {
|
---|
| 75 | - unsigned long alignptr;
|
---|
| 76 | + INT_PTR alignptr = 0;
|
---|
| 77 |
|
---|
| 78 | pool->items = 0;
|
---|
| 79 | pool->maxitems = 0;
|
---|
| 80 | @@ -3899,11 +3902,11 @@
|
---|
| 81 | /* Set the currently active block. */
|
---|
| 82 | pool->nowblock = pool->firstblock;
|
---|
| 83 | /* Find the first item in the pool. Increment by the size of (VOID *). */
|
---|
| 84 | - alignptr = (unsigned long) (pool->nowblock + 1);
|
---|
| 85 | + alignptr = (INT_PTR) (pool->nowblock + 1);
|
---|
| 86 | /* Align the item on an `alignbytes'-byte boundary. */
|
---|
| 87 | pool->nextitem = (VOID *)
|
---|
| 88 | - (alignptr + (unsigned long) pool->alignbytes -
|
---|
| 89 | - (alignptr % (unsigned long) pool->alignbytes));
|
---|
| 90 | + (alignptr + (INT_PTR) pool->alignbytes -
|
---|
| 91 | + (alignptr % (INT_PTR) pool->alignbytes));
|
---|
| 92 | /* There are lots of unallocated items left in this block. */
|
---|
| 93 | pool->unallocateditems = pool->itemsfirstblock;
|
---|
| 94 | /* The stack of deallocated items is empty. */
|
---|
| 95 | @@ -4008,7 +4011,7 @@
|
---|
| 96 | {
|
---|
| 97 | VOID *newitem;
|
---|
| 98 | VOID **newblock;
|
---|
| 99 | - unsigned long alignptr;
|
---|
| 100 | + INT_PTR alignptr = 0;
|
---|
| 101 |
|
---|
| 102 | /* First check the linked list of dead items. If the list is not */
|
---|
| 103 | /* empty, allocate an item from the list rather than a fresh one. */
|
---|
| 104 | @@ -4033,11 +4036,11 @@
|
---|
| 105 | pool->nowblock = (VOID **) *(pool->nowblock);
|
---|
| 106 | /* Find the first item in the block. */
|
---|
| 107 | /* Increment by the size of (VOID *). */
|
---|
| 108 | - alignptr = (unsigned long) (pool->nowblock + 1);
|
---|
| 109 | + alignptr = (INT_PTR) (pool->nowblock + 1);
|
---|
| 110 | /* Align the item on an `alignbytes'-byte boundary. */
|
---|
| 111 | pool->nextitem = (VOID *)
|
---|
| 112 | - (alignptr + (unsigned long) pool->alignbytes -
|
---|
| 113 | - (alignptr % (unsigned long) pool->alignbytes));
|
---|
| 114 | + (alignptr + (INT_PTR) pool->alignbytes -
|
---|
| 115 | + (alignptr % (INT_PTR) pool->alignbytes));
|
---|
| 116 | /* There are lots of unallocated items left in this block. */
|
---|
| 117 | pool->unallocateditems = pool->itemsperblock;
|
---|
| 118 | }
|
---|
| 119 | @@ -4092,16 +4095,16 @@
|
---|
| 120 | #endif /* not ANSI_DECLARATORS */
|
---|
| 121 |
|
---|
| 122 | {
|
---|
| 123 | - unsigned long alignptr;
|
---|
| 124 | + INT_PTR alignptr = 0;
|
---|
| 125 |
|
---|
| 126 | /* Begin the traversal in the first block. */
|
---|
| 127 | pool->pathblock = pool->firstblock;
|
---|
| 128 | /* Find the first item in the block. Increment by the size of (VOID *). */
|
---|
| 129 | - alignptr = (unsigned long) (pool->pathblock + 1);
|
---|
| 130 | + alignptr = (INT_PTR) (pool->pathblock + 1);
|
---|
| 131 | /* Align with item on an `alignbytes'-byte boundary. */
|
---|
| 132 | pool->pathitem = (VOID *)
|
---|
| 133 | - (alignptr + (unsigned long) pool->alignbytes -
|
---|
| 134 | - (alignptr % (unsigned long) pool->alignbytes));
|
---|
| 135 | + (alignptr + (INT_PTR) pool->alignbytes -
|
---|
| 136 | + (alignptr % (INT_PTR) pool->alignbytes));
|
---|
| 137 | /* Set the number of items left in the current block. */
|
---|
| 138 | pool->pathitemsleft = pool->itemsfirstblock;
|
---|
| 139 | }
|
---|
| 140 | @@ -4129,7 +4132,7 @@
|
---|
| 141 |
|
---|
| 142 | {
|
---|
| 143 | VOID *newitem;
|
---|
| 144 | - unsigned long alignptr;
|
---|
| 145 | + INT_PTR alignptr = 0;
|
---|
| 146 |
|
---|
| 147 | /* Stop upon exhausting the list of items. */
|
---|
| 148 | if (pool->pathitem == pool->nextitem) {
|
---|
| 149 | @@ -4141,11 +4144,11 @@
|
---|
| 150 | /* Find the next block. */
|
---|
| 151 | pool->pathblock = (VOID **) *(pool->pathblock);
|
---|
| 152 | /* Find the first item in the block. Increment by the size of (VOID *). */
|
---|
| 153 | - alignptr = (unsigned long) (pool->pathblock + 1);
|
---|
| 154 | + alignptr = (INT_PTR) (pool->pathblock + 1);
|
---|
| 155 | /* Align with item on an `alignbytes'-byte boundary. */
|
---|
| 156 | pool->pathitem = (VOID *)
|
---|
| 157 | - (alignptr + (unsigned long) pool->alignbytes -
|
---|
| 158 | - (alignptr % (unsigned long) pool->alignbytes));
|
---|
| 159 | + (alignptr + (INT_PTR) pool->alignbytes -
|
---|
| 160 | + (alignptr % (INT_PTR) pool->alignbytes));
|
---|
| 161 | /* Set the number of items left in the current block. */
|
---|
| 162 | pool->pathitemsleft = pool->itemsperblock;
|
---|
| 163 | }
|
---|
| 164 | @@ -4197,16 +4200,16 @@
|
---|
| 165 | #endif /* not ANSI_DECLARATORS */
|
---|
| 166 |
|
---|
| 167 | {
|
---|
| 168 | - unsigned long alignptr;
|
---|
| 169 | + INT_PTR alignptr = 0;
|
---|
| 170 |
|
---|
| 171 | /* Set up `dummytri', the `triangle' that occupies "outer space." */
|
---|
| 172 | m->dummytribase = (triangle *) trimalloc(trianglebytes +
|
---|
| 173 | m->triangles.alignbytes);
|
---|
| 174 | /* Align `dummytri' on a `triangles.alignbytes'-byte boundary. */
|
---|
| 175 | - alignptr = (unsigned long) m->dummytribase;
|
---|
| 176 | + alignptr = (INT_PTR) m->dummytribase;
|
---|
| 177 | m->dummytri = (triangle *)
|
---|
| 178 | - (alignptr + (unsigned long) m->triangles.alignbytes -
|
---|
| 179 | - (alignptr % (unsigned long) m->triangles.alignbytes));
|
---|
| 180 | + (alignptr + (INT_PTR) m->triangles.alignbytes -
|
---|
| 181 | + (alignptr % (INT_PTR) m->triangles.alignbytes));
|
---|
| 182 | /* Initialize the three adjoining triangles to be "outer space." These */
|
---|
| 183 | /* will eventually be changed by various bonding operations, but their */
|
---|
| 184 | /* values don't really matter, as long as they can legally be */
|
---|
| 185 | @@ -4226,10 +4229,10 @@
|
---|
| 186 | m->dummysubbase = (subseg *) trimalloc(subsegbytes +
|
---|
| 187 | m->subsegs.alignbytes);
|
---|
| 188 | /* Align `dummysub' on a `subsegs.alignbytes'-byte boundary. */
|
---|
| 189 | - alignptr = (unsigned long) m->dummysubbase;
|
---|
| 190 | + alignptr = (INT_PTR) m->dummysubbase;
|
---|
| 191 | m->dummysub = (subseg *)
|
---|
| 192 | - (alignptr + (unsigned long) m->subsegs.alignbytes -
|
---|
| 193 | - (alignptr % (unsigned long) m->subsegs.alignbytes));
|
---|
| 194 | + (alignptr + (INT_PTR) m->subsegs.alignbytes -
|
---|
| 195 | + (alignptr % (INT_PTR) m->subsegs.alignbytes));
|
---|
| 196 | /* Initialize the two adjoining subsegments to be the omnipresent */
|
---|
| 197 | /* subsegment. These will eventually be changed by various bonding */
|
---|
| 198 | /* operations, but their values don't really matter, as long as they */
|
---|
| 199 | @@ -4586,7 +4589,7 @@
|
---|
| 200 | {
|
---|
| 201 | VOID **getblock;
|
---|
| 202 | char *foundvertex;
|
---|
| 203 | - unsigned long alignptr;
|
---|
| 204 | + INT_PTR alignptr = 0;
|
---|
| 205 | int current;
|
---|
| 206 |
|
---|
| 207 | getblock = m->vertices.firstblock;
|
---|
| 208 | @@ -4603,9 +4606,9 @@
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | /* Now find the right vertex. */
|
---|
| 212 | - alignptr = (unsigned long) (getblock + 1);
|
---|
| 213 | - foundvertex = (char *) (alignptr + (unsigned long) m->vertices.alignbytes -
|
---|
| 214 | - (alignptr % (unsigned long) m->vertices.alignbytes));
|
---|
| 215 | + alignptr = (INT_PTR) (getblock + 1);
|
---|
| 216 | + foundvertex = (char *) (alignptr + (INT_PTR) m->vertices.alignbytes -
|
---|
| 217 | + (alignptr % (INT_PTR) m->vertices.alignbytes));
|
---|
| 218 | return (vertex) (foundvertex + m->vertices.itembytes * (number - current));
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | @@ -7649,7 +7652,7 @@
|
---|
| 222 | char *firsttri;
|
---|
| 223 | struct otri sampletri;
|
---|
| 224 | vertex torg, tdest;
|
---|
| 225 | - unsigned long alignptr;
|
---|
| 226 | + INT_PTR alignptr = 0;
|
---|
| 227 | REAL searchdist, dist;
|
---|
| 228 | REAL ahead;
|
---|
| 229 | long samplesperblock, totalsamplesleft, samplesleft;
|
---|
| 230 | @@ -7721,11 +7724,11 @@
|
---|
| 231 | population = totalpopulation;
|
---|
| 232 | }
|
---|
| 233 | /* Find a pointer to the first triangle in the block. */
|
---|
| 234 | - alignptr = (unsigned long) (sampleblock + 1);
|
---|
| 235 | + alignptr = (INT_PTR) (sampleblock + 1);
|
---|
| 236 | firsttri = (char *) (alignptr +
|
---|
| 237 | - (unsigned long) m->triangles.alignbytes -
|
---|
| 238 | + (INT_PTR) m->triangles.alignbytes -
|
---|
| 239 | (alignptr %
|
---|
| 240 | - (unsigned long) m->triangles.alignbytes));
|
---|
| 241 | + (INT_PTR) m->triangles.alignbytes));
|
---|
| 242 |
|
---|
| 243 | /* Choose `samplesleft' randomly sampled triangles in this block. */
|
---|
| 244 | do {
|
---|