diff options
author | Gareth Hughes | 2001-03-12 18:22:05 -0600 |
---|---|---|
committer | Gareth Hughes | 2001-03-12 18:22:05 -0600 |
commit | e2b2bffc6b25361b2f09afc5a28030645440cd03 (patch) | |
tree | c03a2be248dbbf3c9a624e3e496b76193a9403f0 /libdrm/xf86drmHash.c | |
parent | 0b60aad8a5f1e6d38bf2d254fa5209492157e344 (diff) | |
download | libdrm-e2b2bffc6b25361b2f09afc5a28030645440cd03.tar.gz libdrm-e2b2bffc6b25361b2f09afc5a28030645440cd03.tar.xz libdrm-e2b2bffc6b25361b2f09afc5a28030645440cd03.zip |
Rest of MGA dualhead patch.
Diffstat (limited to 'libdrm/xf86drmHash.c')
-rw-r--r-- | libdrm/xf86drmHash.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/libdrm/xf86drmHash.c b/libdrm/xf86drmHash.c index 24b698cc..70240b95 100644 --- a/libdrm/xf86drmHash.c +++ b/libdrm/xf86drmHash.c | |||
@@ -10,11 +10,11 @@ | |||
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
11 | * and/or sell copies of the Software, and to permit persons to whom the | 11 | * and/or sell copies of the Software, and to permit persons to whom the |
12 | * Software is furnished to do so, subject to the following conditions: | 12 | * Software is furnished to do so, subject to the following conditions: |
13 | * | 13 | * |
14 | * The above copyright notice and this permission notice (including the next | 14 | * The above copyright notice and this permission notice (including the next |
15 | * paragraph) shall be included in all copies or substantial portions of the | 15 | * paragraph) shall be included in all copies or substantial portions of the |
16 | * Software. | 16 | * Software. |
17 | * | 17 | * |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
@@ -22,7 +22,7 @@ | |||
22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | 22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
24 | * DEALINGS IN THE SOFTWARE. | 24 | * DEALINGS IN THE SOFTWARE. |
25 | * | 25 | * |
26 | * Authors: Rickard E. (Rik) Faith <faith@valinux.com> | 26 | * Authors: Rickard E. (Rik) Faith <faith@valinux.com> |
27 | * | 27 | * |
28 | * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.3 2000/06/17 00:03:34 martin Exp $ | 28 | * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.3 2000/06/17 00:03:34 martin Exp $ |
@@ -187,7 +187,7 @@ int N(HashDestroy)(void *t) | |||
187 | int i; | 187 | int i; |
188 | 188 | ||
189 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ | 189 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ |
190 | 190 | ||
191 | for (i = 0; i < HASH_SIZE; i++) { | 191 | for (i = 0; i < HASH_SIZE; i++) { |
192 | for (bucket = table->buckets[i]; bucket;) { | 192 | for (bucket = table->buckets[i]; bucket;) { |
193 | next = bucket->next; | 193 | next = bucket->next; |
@@ -235,8 +235,8 @@ int N(HashLookup)(void *t, unsigned long key, void **value) | |||
235 | HashTablePtr table = (HashTablePtr)t; | 235 | HashTablePtr table = (HashTablePtr)t; |
236 | HashBucketPtr bucket; | 236 | HashBucketPtr bucket; |
237 | 237 | ||
238 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ | 238 | if (!table || table->magic != HASH_MAGIC) return -1; /* Bad magic */ |
239 | 239 | ||
240 | bucket = HashFind(table, key, NULL); | 240 | bucket = HashFind(table, key, NULL); |
241 | if (!bucket) return 1; /* Not found */ | 241 | if (!bucket) return 1; /* Not found */ |
242 | *value = bucket->value; | 242 | *value = bucket->value; |
@@ -250,7 +250,7 @@ int N(HashInsert)(void *t, unsigned long key, void *value) | |||
250 | unsigned long hash; | 250 | unsigned long hash; |
251 | 251 | ||
252 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ | 252 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ |
253 | 253 | ||
254 | if (HashFind(table, key, &hash)) return 1; /* Already in table */ | 254 | if (HashFind(table, key, &hash)) return 1; /* Already in table */ |
255 | 255 | ||
256 | bucket = HASH_ALLOC(sizeof(*bucket)); | 256 | bucket = HASH_ALLOC(sizeof(*bucket)); |
@@ -272,7 +272,7 @@ int N(HashDelete)(void *t, unsigned long key) | |||
272 | HashBucketPtr bucket; | 272 | HashBucketPtr bucket; |
273 | 273 | ||
274 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ | 274 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ |
275 | 275 | ||
276 | bucket = HashFind(table, key, &hash); | 276 | bucket = HashFind(table, key, &hash); |
277 | 277 | ||
278 | if (!bucket) return 1; /* Not found */ | 278 | if (!bucket) return 1; /* Not found */ |
@@ -285,7 +285,7 @@ int N(HashDelete)(void *t, unsigned long key) | |||
285 | int N(HashNext)(void *t, unsigned long *key, void **value) | 285 | int N(HashNext)(void *t, unsigned long *key, void **value) |
286 | { | 286 | { |
287 | HashTablePtr table = (HashTablePtr)t; | 287 | HashTablePtr table = (HashTablePtr)t; |
288 | 288 | ||
289 | for (; table->p0 < HASH_SIZE; | 289 | for (; table->p0 < HASH_SIZE; |
290 | ++table->p0, table->p1 = table->buckets[table->p0]) { | 290 | ++table->p0, table->p1 = table->buckets[table->p0]) { |
291 | if (table->p1) { | 291 | if (table->p1) { |
@@ -301,7 +301,7 @@ int N(HashNext)(void *t, unsigned long *key, void **value) | |||
301 | int N(HashFirst)(void *t, unsigned long *key, void **value) | 301 | int N(HashFirst)(void *t, unsigned long *key, void **value) |
302 | { | 302 | { |
303 | HashTablePtr table = (HashTablePtr)t; | 303 | HashTablePtr table = (HashTablePtr)t; |
304 | 304 | ||
305 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ | 305 | if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ |
306 | 306 | ||
307 | table->p0 = 0; | 307 | table->p0 = 0; |
@@ -337,7 +337,7 @@ static void compute_dist(HashTablePtr table) | |||
337 | { | 337 | { |
338 | int i; | 338 | int i; |
339 | HashBucketPtr bucket; | 339 | HashBucketPtr bucket; |
340 | 340 | ||
341 | printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n", | 341 | printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n", |
342 | table->entries, table->hits, table->partials, table->misses); | 342 | table->entries, table->hits, table->partials, table->misses); |
343 | clear_dist(); | 343 | clear_dist(); |
@@ -356,7 +356,7 @@ static void check_table(HashTablePtr table, | |||
356 | { | 356 | { |
357 | unsigned long retval = 0; | 357 | unsigned long retval = 0; |
358 | int retcode = N(HashLookup)(table, key, &retval); | 358 | int retcode = N(HashLookup)(table, key, &retval); |
359 | 359 | ||
360 | switch (retcode) { | 360 | switch (retcode) { |
361 | case -1: | 361 | case -1: |
362 | printf("Bad magic = 0x%08lx:" | 362 | printf("Bad magic = 0x%08lx:" |
@@ -391,7 +391,7 @@ int main(void) | |||
391 | for (i = 256; i >= 0; i--) check_table(table, i, i); | 391 | for (i = 256; i >= 0; i--) check_table(table, i, i); |
392 | compute_dist(table); | 392 | compute_dist(table); |
393 | N(HashDestroy)(table); | 393 | N(HashDestroy)(table); |
394 | 394 | ||
395 | printf("\n***** 1024 consecutive integers ****\n"); | 395 | printf("\n***** 1024 consecutive integers ****\n"); |
396 | table = N(HashCreate)(); | 396 | table = N(HashCreate)(); |
397 | for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i); | 397 | for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i); |
@@ -399,7 +399,7 @@ int main(void) | |||
399 | for (i = 1024; i >= 0; i--) check_table(table, i, i); | 399 | for (i = 1024; i >= 0; i--) check_table(table, i, i); |
400 | compute_dist(table); | 400 | compute_dist(table); |
401 | N(HashDestroy)(table); | 401 | N(HashDestroy)(table); |
402 | 402 | ||
403 | printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); | 403 | printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); |
404 | table = N(HashCreate)(); | 404 | table = N(HashCreate)(); |
405 | for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i); | 405 | for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i); |
@@ -407,7 +407,7 @@ int main(void) | |||
407 | for (i = 1024; i >= 0; i--) check_table(table, i*4096, i); | 407 | for (i = 1024; i >= 0; i--) check_table(table, i*4096, i); |
408 | compute_dist(table); | 408 | compute_dist(table); |
409 | N(HashDestroy)(table); | 409 | N(HashDestroy)(table); |
410 | 410 | ||
411 | printf("\n***** 1024 random integers ****\n"); | 411 | printf("\n***** 1024 random integers ****\n"); |
412 | table = N(HashCreate)(); | 412 | table = N(HashCreate)(); |
413 | srandom(0xbeefbeef); | 413 | srandom(0xbeefbeef); |
@@ -429,7 +429,7 @@ int main(void) | |||
429 | for (i = 0; i < 5000; i++) check_table(table, random(), i); | 429 | for (i = 0; i < 5000; i++) check_table(table, random(), i); |
430 | compute_dist(table); | 430 | compute_dist(table); |
431 | N(HashDestroy)(table); | 431 | N(HashDestroy)(table); |
432 | 432 | ||
433 | return 0; | 433 | return 0; |
434 | } | 434 | } |
435 | #endif | 435 | #endif |