aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Jackson2006-02-20 17:09:00 -0600
committerAdam Jackson2006-02-20 17:09:00 -0600
commit22e41ef08338ae6dd59acbe6d4d8e50d83672816 (patch)
tree29bc22ae9a7be2d54b974500e92366122e1c60a3 /libdrm/xf86drmHash.c
parent0a211db23c0d7e22946aa25f22e9aeab6783b617 (diff)
downloadexternal-libgbm-22e41ef08338ae6dd59acbe6d4d8e50d83672816.tar.gz
external-libgbm-22e41ef08338ae6dd59acbe6d4d8e50d83672816.tar.xz
external-libgbm-22e41ef08338ae6dd59acbe6d4d8e50d83672816.zip
Formatting cleanup, dead code removal. Remove N() namespacing macro,
useless. Remove SIGIO handling functions as they're server-only and properly belong in libdri.
Diffstat (limited to 'libdrm/xf86drmHash.c')
-rw-r--r--libdrm/xf86drmHash.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/libdrm/xf86drmHash.c b/libdrm/xf86drmHash.c
index c3e7f0d7..71d3d895 100644
--- a/libdrm/xf86drmHash.c
+++ b/libdrm/xf86drmHash.c
@@ -91,8 +91,6 @@
91# endif 91# endif
92#endif 92#endif
93 93
94#define N(x) drm##x
95
96#define HASH_MAGIC 0xdeadbeef 94#define HASH_MAGIC 0xdeadbeef
97#define HASH_DEBUG 0 95#define HASH_DEBUG 0
98#define HASH_SIZE 512 /* Good for about 100 entries */ 96#define HASH_SIZE 512 /* Good for about 100 entries */
@@ -135,11 +133,11 @@ typedef struct HashTable {
135} HashTable, *HashTablePtr; 133} HashTable, *HashTablePtr;
136 134
137#if HASH_MAIN 135#if HASH_MAIN
138extern void *N(HashCreate)(void); 136extern void *drmHashCreate(void);
139extern int N(HashDestroy)(void *t); 137extern int drmHashDestroy(void *t);
140extern int N(HashLookup)(void *t, unsigned long key, unsigned long *value); 138extern int drmHashLookup(void *t, unsigned long key, unsigned long *value);
141extern int N(HashInsert)(void *t, unsigned long key, unsigned long value); 139extern int drmHashInsert(void *t, unsigned long key, unsigned long value);
142extern int N(HashDelete)(void *t, unsigned long key); 140extern int drmHashDelete(void *t, unsigned long key);
143#endif 141#endif
144 142
145static unsigned long HashHash(unsigned long key) 143static unsigned long HashHash(unsigned long key)
@@ -170,7 +168,7 @@ static unsigned long HashHash(unsigned long key)
170 return hash; 168 return hash;
171} 169}
172 170
173void *N(HashCreate)(void) 171void *drmHashCreate(void)
174{ 172{
175 HashTablePtr table; 173 HashTablePtr table;
176 int i; 174 int i;
@@ -187,7 +185,7 @@ void *N(HashCreate)(void)
187 return table; 185 return table;
188} 186}
189 187
190int N(HashDestroy)(void *t) 188int drmHashDestroy(void *t)
191{ 189{
192 HashTablePtr table = (HashTablePtr)t; 190 HashTablePtr table = (HashTablePtr)t;
193 HashBucketPtr bucket; 191 HashBucketPtr bucket;
@@ -238,7 +236,7 @@ static HashBucketPtr HashFind(HashTablePtr table,
238 return NULL; 236 return NULL;
239} 237}
240 238
241int N(HashLookup)(void *t, unsigned long key, void **value) 239int drmHashLookup(void *t, unsigned long key, void **value)
242{ 240{
243 HashTablePtr table = (HashTablePtr)t; 241 HashTablePtr table = (HashTablePtr)t;
244 HashBucketPtr bucket; 242 HashBucketPtr bucket;
@@ -251,7 +249,7 @@ int N(HashLookup)(void *t, unsigned long key, void **value)
251 return 0; /* Found */ 249 return 0; /* Found */
252} 250}
253 251
254int N(HashInsert)(void *t, unsigned long key, void *value) 252int drmHashInsert(void *t, unsigned long key, void *value)
255{ 253{
256 HashTablePtr table = (HashTablePtr)t; 254 HashTablePtr table = (HashTablePtr)t;
257 HashBucketPtr bucket; 255 HashBucketPtr bucket;
@@ -273,7 +271,7 @@ int N(HashInsert)(void *t, unsigned long key, void *value)
273 return 0; /* Added to table */ 271 return 0; /* Added to table */
274} 272}
275 273
276int N(HashDelete)(void *t, unsigned long key) 274int drmHashDelete(void *t, unsigned long key)
277{ 275{
278 HashTablePtr table = (HashTablePtr)t; 276 HashTablePtr table = (HashTablePtr)t;
279 unsigned long hash; 277 unsigned long hash;
@@ -290,7 +288,7 @@ int N(HashDelete)(void *t, unsigned long key)
290 return 0; 288 return 0;
291} 289}
292 290
293int N(HashNext)(void *t, unsigned long *key, void **value) 291int drmHashNext(void *t, unsigned long *key, void **value)
294{ 292{
295 HashTablePtr table = (HashTablePtr)t; 293 HashTablePtr table = (HashTablePtr)t;
296 294
@@ -306,7 +304,7 @@ int N(HashNext)(void *t, unsigned long *key, void **value)
306 return 0; 304 return 0;
307} 305}
308 306
309int N(HashFirst)(void *t, unsigned long *key, void **value) 307int drmHashFirst(void *t, unsigned long *key, void **value)
310{ 308{
311 HashTablePtr table = (HashTablePtr)t; 309 HashTablePtr table = (HashTablePtr)t;
312 310
@@ -314,7 +312,7 @@ int N(HashFirst)(void *t, unsigned long *key, void **value)
314 312
315 table->p0 = 0; 313 table->p0 = 0;
316 table->p1 = table->buckets[0]; 314 table->p1 = table->buckets[0];
317 return N(HashNext)(table, key, value); 315 return drmHashNext(table, key, value);
318} 316}
319 317
320#if HASH_MAIN 318#if HASH_MAIN
@@ -363,7 +361,7 @@ static void check_table(HashTablePtr table,
363 unsigned long key, unsigned long value) 361 unsigned long key, unsigned long value)
364{ 362{
365 unsigned long retval = 0; 363 unsigned long retval = 0;
366 int retcode = N(HashLookup)(table, key, &retval); 364 int retcode = drmHashLookup(table, key, &retval);
367 365
368 switch (retcode) { 366 switch (retcode) {
369 case -1: 367 case -1:
@@ -393,50 +391,50 @@ int main(void)
393 int i; 391 int i;
394 392
395 printf("\n***** 256 consecutive integers ****\n"); 393 printf("\n***** 256 consecutive integers ****\n");
396 table = N(HashCreate)(); 394 table = drmHashCreate();
397 for (i = 0; i < 256; i++) N(HashInsert)(table, i, i); 395 for (i = 0; i < 256; i++) drmHashInsert(table, i, i);
398 for (i = 0; i < 256; i++) check_table(table, i, i); 396 for (i = 0; i < 256; i++) check_table(table, i, i);
399 for (i = 256; i >= 0; i--) check_table(table, i, i); 397 for (i = 256; i >= 0; i--) check_table(table, i, i);
400 compute_dist(table); 398 compute_dist(table);
401 N(HashDestroy)(table); 399 drmHashDestroy(table);
402 400
403 printf("\n***** 1024 consecutive integers ****\n"); 401 printf("\n***** 1024 consecutive integers ****\n");
404 table = N(HashCreate)(); 402 table = drmHashCreate();
405 for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i); 403 for (i = 0; i < 1024; i++) drmHashInsert(table, i, i);
406 for (i = 0; i < 1024; i++) check_table(table, i, i); 404 for (i = 0; i < 1024; i++) check_table(table, i, i);
407 for (i = 1024; i >= 0; i--) check_table(table, i, i); 405 for (i = 1024; i >= 0; i--) check_table(table, i, i);
408 compute_dist(table); 406 compute_dist(table);
409 N(HashDestroy)(table); 407 drmHashDestroy(table);
410 408
411 printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); 409 printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
412 table = N(HashCreate)(); 410 table = drmHashCreate();
413 for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i); 411 for (i = 0; i < 1024; i++) drmHashInsert(table, i*4096, i);
414 for (i = 0; i < 1024; i++) check_table(table, i*4096, i); 412 for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
415 for (i = 1024; i >= 0; i--) check_table(table, i*4096, i); 413 for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
416 compute_dist(table); 414 compute_dist(table);
417 N(HashDestroy)(table); 415 drmHashDestroy(table);
418 416
419 printf("\n***** 1024 random integers ****\n"); 417 printf("\n***** 1024 random integers ****\n");
420 table = N(HashCreate)(); 418 table = drmHashCreate();
421 srandom(0xbeefbeef); 419 srandom(0xbeefbeef);
422 for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i); 420 for (i = 0; i < 1024; i++) drmHashInsert(table, random(), i);
423 srandom(0xbeefbeef); 421 srandom(0xbeefbeef);
424 for (i = 0; i < 1024; i++) check_table(table, random(), i); 422 for (i = 0; i < 1024; i++) check_table(table, random(), i);
425 srandom(0xbeefbeef); 423 srandom(0xbeefbeef);
426 for (i = 0; i < 1024; i++) check_table(table, random(), i); 424 for (i = 0; i < 1024; i++) check_table(table, random(), i);
427 compute_dist(table); 425 compute_dist(table);
428 N(HashDestroy)(table); 426 drmHashDestroy(table);
429 427
430 printf("\n***** 5000 random integers ****\n"); 428 printf("\n***** 5000 random integers ****\n");
431 table = N(HashCreate)(); 429 table = drmHashCreate();
432 srandom(0xbeefbeef); 430 srandom(0xbeefbeef);
433 for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i); 431 for (i = 0; i < 5000; i++) drmHashInsert(table, random(), i);
434 srandom(0xbeefbeef); 432 srandom(0xbeefbeef);
435 for (i = 0; i < 5000; i++) check_table(table, random(), i); 433 for (i = 0; i < 5000; i++) check_table(table, random(), i);
436 srandom(0xbeefbeef); 434 srandom(0xbeefbeef);
437 for (i = 0; i < 5000; i++) check_table(table, random(), i); 435 for (i = 0; i < 5000; i++) check_table(table, random(), i);
438 compute_dist(table); 436 compute_dist(table);
439 N(HashDestroy)(table); 437 drmHashDestroy(table);
440 438
441 return 0; 439 return 0;
442} 440}