diff options
author | Keith Whitwell <[email protected]> | 2005-01-12 18:14:42 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2005-01-12 18:14:42 +0000 |
commit | 4676a6ab7b9346e88ad15f5f0a255e4559d5f547 (patch) | |
tree | 6f0914566a7d054a22ed16bf5b3677de490cec96 /src | |
parent | 2937d403db37e04d9523b8ed268dfc4afac5aec9 (diff) |
Expand out the N(x) macro so that tags can find functions like
drmHashFirst(), etc.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/dri_client/xf86drmHash.c | 60 | ||||
-rw-r--r-- | src/mesa/drivers/dri/dri_client/xf86drmRandom.c | 34 | ||||
-rw-r--r-- | src/mesa/drivers/dri/dri_client/xf86drmSL.c | 70 |
3 files changed, 79 insertions, 85 deletions
diff --git a/src/mesa/drivers/dri/dri_client/xf86drmHash.c b/src/mesa/drivers/dri/dri_client/xf86drmHash.c index 1f1a05b3ac9..5f89d540dc2 100644 --- a/src/mesa/drivers/dri/dri_client/xf86drmHash.c +++ b/src/mesa/drivers/dri/dri_client/xf86drmHash.c @@ -86,8 +86,6 @@ # endif #endif -#define N(x) drm##x - #define HASH_MAGIC 0xdeadbeef #define HASH_DEBUG 0 #define HASH_SIZE 512 /* Good for about 100 entries */ @@ -128,11 +126,11 @@ typedef struct HashTable { } HashTable, *HashTablePtr; #if HASH_MAIN -extern void *N(HashCreate)(void); -extern int N(HashDestroy)(void *t); -extern int N(HashLookup)(void *t, unsigned long key, unsigned long *value); -extern int N(HashInsert)(void *t, unsigned long key, unsigned long value); -extern int N(HashDelete)(void *t, unsigned long key); +extern void *drmHashCreate(void); +extern int drmHashDestroy(void *t); +extern int drmHashLookup(void *t, unsigned long key, unsigned long *value); +extern int drmHashInsert(void *t, unsigned long key, unsigned long value); +extern int drmHashDelete(void *t, unsigned long key); #endif static unsigned long HashHash(unsigned long key) @@ -162,7 +160,7 @@ static unsigned long HashHash(unsigned long key) return hash; } -void *N(HashCreate)(void) +void *drmHashCreate(void) { HashTablePtr table; int i; @@ -179,7 +177,7 @@ void *N(HashCreate)(void) return table; } -int N(HashDestroy)(void *t) +int drmHashDestroy(void *t) { HashTablePtr table = (HashTablePtr)t; HashBucketPtr bucket; @@ -230,7 +228,7 @@ static HashBucketPtr HashFind(HashTablePtr table, return NULL; } -int N(HashLookup)(void *t, unsigned long key, void **value) +int drmHashLookup(void *t, unsigned long key, void **value) { HashTablePtr table = (HashTablePtr)t; HashBucketPtr bucket; @@ -243,7 +241,7 @@ int N(HashLookup)(void *t, unsigned long key, void **value) return 0; /* Found */ } -int N(HashInsert)(void *t, unsigned long key, void *value) +int drmHashInsert(void *t, unsigned long key, void *value) { HashTablePtr table = (HashTablePtr)t; HashBucketPtr bucket; @@ -265,7 +263,7 @@ int N(HashInsert)(void *t, unsigned long key, void *value) return 0; /* Added to table */ } -int N(HashDelete)(void *t, unsigned long key) +int drmHashDelete(void *t, unsigned long key) { HashTablePtr table = (HashTablePtr)t; unsigned long hash; @@ -282,7 +280,7 @@ int N(HashDelete)(void *t, unsigned long key) return 0; } -int N(HashNext)(void *t, unsigned long *key, void **value) +int drmHashNext(void *t, unsigned long *key, void **value) { HashTablePtr table = (HashTablePtr)t; @@ -298,7 +296,7 @@ int N(HashNext)(void *t, unsigned long *key, void **value) return 0; } -int N(HashFirst)(void *t, unsigned long *key, void **value) +int drmHashFirst(void *t, unsigned long *key, void **value) { HashTablePtr table = (HashTablePtr)t; @@ -306,7 +304,7 @@ int N(HashFirst)(void *t, unsigned long *key, void **value) table->p0 = 0; table->p1 = table->buckets[0]; - return N(HashNext)(table, key, value); + return drmHashNext(table, key, value); } #if HASH_MAIN @@ -355,7 +353,7 @@ static void check_table(HashTablePtr table, unsigned long key, unsigned long value) { unsigned long retval = 0; - int retcode = N(HashLookup)(table, key, &retval); + int retcode = drmHashLookup(table, key, &retval); switch (retcode) { case -1: @@ -385,50 +383,50 @@ int main(void) int i; printf("\n***** 256 consecutive integers ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 256; i++) N(HashInsert)(table, i, i); + table = drmHashCreate(); + for (i = 0; i < 256; i++) drmHashInsert(table, i, i); for (i = 0; i < 256; i++) check_table(table, i, i); for (i = 256; i >= 0; i--) check_table(table, i, i); compute_dist(table); - N(HashDestroy)(table); + drmHashDestroy(table); printf("\n***** 1024 consecutive integers ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i); + table = drmHashCreate(); + for (i = 0; i < 1024; i++) drmHashInsert(table, i, i); for (i = 0; i < 1024; i++) check_table(table, i, i); for (i = 1024; i >= 0; i--) check_table(table, i, i); compute_dist(table); - N(HashDestroy)(table); + drmHashDestroy(table); printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i); + table = drmHashCreate(); + for (i = 0; i < 1024; i++) drmHashInsert(table, i*4096, i); for (i = 0; i < 1024; i++) check_table(table, i*4096, i); for (i = 1024; i >= 0; i--) check_table(table, i*4096, i); compute_dist(table); - N(HashDestroy)(table); + drmHashDestroy(table); printf("\n***** 1024 random integers ****\n"); - table = N(HashCreate)(); + table = drmHashCreate(); srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i); + for (i = 0; i < 1024; i++) drmHashInsert(table, random(), i); srandom(0xbeefbeef); for (i = 0; i < 1024; i++) check_table(table, random(), i); srandom(0xbeefbeef); for (i = 0; i < 1024; i++) check_table(table, random(), i); compute_dist(table); - N(HashDestroy)(table); + drmHashDestroy(table); printf("\n***** 5000 random integers ****\n"); - table = N(HashCreate)(); + table = drmHashCreate(); srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i); + for (i = 0; i < 5000; i++) drmHashInsert(table, random(), i); srandom(0xbeefbeef); for (i = 0; i < 5000; i++) check_table(table, random(), i); srandom(0xbeefbeef); for (i = 0; i < 5000; i++) check_table(table, random(), i); compute_dist(table); - N(HashDestroy)(table); + drmHashDestroy(table); return 0; } diff --git a/src/mesa/drivers/dri/dri_client/xf86drmRandom.c b/src/mesa/drivers/dri/dri_client/xf86drmRandom.c index 9e1e9ee2c34..cca831d7517 100644 --- a/src/mesa/drivers/dri/dri_client/xf86drmRandom.c +++ b/src/mesa/drivers/dri/dri_client/xf86drmRandom.c @@ -89,8 +89,6 @@ # endif #endif -#define N(x) drm##x - #define RANDOM_MAGIC 0xfeedbeef #define RANDOM_DEBUG 0 @@ -113,13 +111,13 @@ typedef struct RandomState { } RandomState; #if RANDOM_MAIN -extern void *N(RandomCreate)(unsigned long seed); -extern int N(RandomDestroy)(void *state); -extern unsigned long N(Random)(void *state); -extern double N(RandomDouble)(void *state); +extern void *drmRandomCreate(unsigned long seed); +extern int drmRandomDestroy(void *state); +extern unsigned long drmRandom(void *state); +extern double drmRandomDouble(void *state); #endif -void *N(RandomCreate)(unsigned long seed) +void *drmRandomCreate(unsigned long seed) { RandomState *state; @@ -149,13 +147,13 @@ void *N(RandomCreate)(unsigned long seed) return state; } -int N(RandomDestroy)(void *state) +int drmRandomDestroy(void *state) { RANDOM_FREE(state); return 0; } -unsigned long N(Random)(void *state) +unsigned long drmRandom(void *state) { RandomState *s = (RandomState *)state; long hi; @@ -169,11 +167,11 @@ unsigned long N(Random)(void *state) return s->seed; } -double N(RandomDouble)(void *state) +double drmRandomDouble(void *state) { RandomState *s = (RandomState *)state; - return (double)N(Random)(state)/(double)s->m; + return (double)drmRandom(state)/(double)s->m; } #if RANDOM_MAIN @@ -183,15 +181,15 @@ static void check_period(long seed) unsigned long initial; void *state; - state = N(RandomCreate)(seed); - initial = N(Random)(state); + state = drmRandomCreate(seed); + initial = drmRandom(state); ++count; - while (initial != N(Random)(state)) { + while (initial != drmRandom(state)) { if (!++count) break; } printf("With seed of %10ld, period = %10lu (0x%08lx)\n", seed, count, count); - N(RandomDestroy)(state); + drmRandomDestroy(state); } int main(void) @@ -200,14 +198,14 @@ int main(void) int i; unsigned long rand; - state = N(RandomCreate)(1); + state = drmRandomCreate(1); for (i = 0; i < 10000; i++) { - rand = N(Random)(state); + rand = drmRandom(state); } printf("After 10000 iterations: %lu (%lu expected): %s\n", rand, state->check, rand - state->check ? "*INCORRECT*" : "CORRECT"); - N(RandomDestroy)(state); + drmRandomDestroy(state); printf("Checking periods...\n"); check_period(1); diff --git a/src/mesa/drivers/dri/dri_client/xf86drmSL.c b/src/mesa/drivers/dri/dri_client/xf86drmSL.c index dd634c30f62..a9d64c920f0 100644 --- a/src/mesa/drivers/dri/dri_client/xf86drmSL.c +++ b/src/mesa/drivers/dri/dri_client/xf86drmSL.c @@ -57,8 +57,6 @@ # endif #endif -#define N(x) drm##x - #define SL_LIST_MAGIC 0xfacade00LU #define SL_ENTRY_MAGIC 0x00fab1edLU #define SL_FREED_MAGIC 0xdecea5edLU @@ -98,15 +96,15 @@ typedef struct SkipList { } SkipList, *SkipListPtr; #if SL_MAIN -extern void *N(SLCreate)(void); -extern int N(SLDestroy)(void *l); -extern int N(SLLookup)(void *l, unsigned long key, void **value); -extern int N(SLInsert)(void *l, unsigned long key, void *value); -extern int N(SLDelete)(void *l, unsigned long key); -extern int N(SLNext)(void *l, unsigned long *key, void **value); -extern int N(SLFirst)(void *l, unsigned long *key, void **value); -extern void N(SLDump)(void *l); -extern int N(SLLookupNeighbors)(void *l, unsigned long key, +extern void *drmSLCreate(void); +extern int drmSLDestroy(void *l); +extern int drmSLLookup(void *l, unsigned long key, void **value); +extern int drmSLInsert(void *l, unsigned long key, void *value); +extern int drmSLDelete(void *l, unsigned long key); +extern int drmSLNext(void *l, unsigned long *key, void **value); +extern int drmSLFirst(void *l, unsigned long *key, void **value); +extern void drmSLDump(void *l); +extern int drmSLLookupNeighbors(void *l, unsigned long key, unsigned long *prev_key, void **prev_value, unsigned long *next_key, void **next_value); #endif @@ -139,7 +137,7 @@ static int SLRandomLevel(void) return level; } -void *N(SLCreate)(void) +void *drmSLCreate(void) { SkipListPtr list; int i; @@ -156,7 +154,7 @@ void *N(SLCreate)(void) return list; } -int N(SLDestroy)(void *l) +int drmSLDestroy(void *l) { SkipListPtr list = (SkipListPtr)l; SLEntryPtr entry; @@ -193,7 +191,7 @@ static SLEntryPtr SLLocate(void *l, unsigned long key, SLEntryPtr *update) return entry->forward[0]; } -int N(SLInsert)(void *l, unsigned long key, void *value) +int drmSLInsert(void *l, unsigned long key, void *value) { SkipListPtr list = (SkipListPtr)l; SLEntryPtr entry; @@ -226,7 +224,7 @@ int N(SLInsert)(void *l, unsigned long key, void *value) return 0; /* Added to table */ } -int N(SLDelete)(void *l, unsigned long key) +int drmSLDelete(void *l, unsigned long key) { SkipListPtr list = (SkipListPtr)l; SLEntryPtr update[SL_MAX_LEVEL + 1]; @@ -253,7 +251,7 @@ int N(SLDelete)(void *l, unsigned long key) return 0; } -int N(SLLookup)(void *l, unsigned long key, void **value) +int drmSLLookup(void *l, unsigned long key, void **value) { SkipListPtr list = (SkipListPtr)l; SLEntryPtr update[SL_MAX_LEVEL + 1]; @@ -269,7 +267,7 @@ int N(SLLookup)(void *l, unsigned long key, void **value) return -1; } -int N(SLLookupNeighbors)(void *l, unsigned long key, +int drmSLLookupNeighbors(void *l, unsigned long key, unsigned long *prev_key, void **prev_value, unsigned long *next_key, void **next_value) { @@ -296,7 +294,7 @@ int N(SLLookupNeighbors)(void *l, unsigned long key, return retcode; } -int N(SLNext)(void *l, unsigned long *key, void **value) +int drmSLNext(void *l, unsigned long *key, void **value) { SkipListPtr list = (SkipListPtr)l; SLEntryPtr entry; @@ -315,18 +313,18 @@ int N(SLNext)(void *l, unsigned long *key, void **value) return 0; } -int N(SLFirst)(void *l, unsigned long *key, void **value) +int drmSLFirst(void *l, unsigned long *key, void **value) { SkipListPtr list = (SkipListPtr)l; if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ list->p0 = list->head->forward[0]; - return N(SLNext)(list, key, value); + return drmSLNext(list, key, value); } /* Dump internal data structures for debugging. */ -void N(SLDump)(void *l) +void drmSLDump(void *l) { SkipListPtr list = (SkipListPtr)l; SLEntryPtr entry; @@ -366,10 +364,10 @@ static void print(SkipListPtr list) unsigned long key; void *value; - if (N(SLFirst)(list, &key, &value)) { + if (drmSLFirst(list, &key, &value)) { do { printf("key = %5lu, value = %p\n", key, value); - } while (N(SLNext)(list, &key, &value)); + } while (drmSLNext(list, &key, &value)); } } @@ -387,27 +385,27 @@ static double do_time(int size, int iter) SL_RANDOM_INIT(12345); - list = N(SLCreate)(); + list = drmSLCreate(); for (i = 0; i < size; i++) { keys[i] = SL_RANDOM; - N(SLInsert)(list, keys[i], NULL); + drmSLInsert(list, keys[i], NULL); } previous = 0; - if (N(SLFirst)(list, &key, &value)) { + if (drmSLFirst(list, &key, &value)) { do { if (key <= previous) { printf( "%lu !< %lu\n", previous, key); } previous = key; - } while (N(SLNext)(list, &key, &value)); + } while (drmSLNext(list, &key, &value)); } gettimeofday(&start, NULL); for (j = 0; j < iter; j++) { for (i = 0; i < size; i++) { - if (N(SLLookup)(list, keys[i], &value)) + if (drmSLLookup(list, keys[i], &value)) printf("Error %lu %d\n", keys[i], i); } } @@ -418,7 +416,7 @@ static double do_time(int size, int iter) printf("%0.2f microseconds for list length %d\n", usec, size); - N(SLDestroy)(list); + drmSLDestroy(list); return usec; } @@ -443,15 +441,15 @@ int main(void) SkipListPtr list; double usec, usec2, usec3, usec4; - list = N(SLCreate)(); + list = drmSLCreate(); printf( "list at %p\n", list); print(list); printf("\n==============================\n\n"); - N(SLInsert)(list, 123, NULL); - N(SLInsert)(list, 213, NULL); - N(SLInsert)(list, 50, NULL); + drmSLInsert(list, 123, NULL); + drmSLInsert(list, 213, NULL); + drmSLInsert(list, 50, NULL); print(list); printf("\n==============================\n\n"); @@ -464,12 +462,12 @@ int main(void) print_neighbors(list, 256); printf("\n==============================\n\n"); - N(SLDelete)(list, 50); + drmSLDelete(list, 50); print(list); printf("\n==============================\n\n"); - N(SLDump)(list); - N(SLDestroy)(list); + drmSLDump(list); + drmSLDestroy(list); printf("\n==============================\n\n"); usec = do_time(100, 10000); |