From 71bdfae94122fff6f245c47721d284f78c286164 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 29 Sep 2012 17:11:03 -0400 Subject: Replacing 'st_table' by 'st__table' to resolve linker problems. --- src/misc/st/st.c | 186 ++++++++++++++++++++++++++--------------------------- src/misc/st/st.h | 104 +++++++++++++++--------------- src/misc/st/stmm.c | 6 +- src/misc/st/stmm.h | 12 ++-- 4 files changed, 154 insertions(+), 154 deletions(-) (limited to 'src/misc/st') diff --git a/src/misc/st/st.c b/src/misc/st/st.c index 2e2edc53..cbdac8be 100644 --- a/src/misc/st/st.c +++ b/src/misc/st/st.c @@ -16,34 +16,34 @@ ABC_NAMESPACE_IMPL_START -#define ST_NUMCMP(x,y) ((x) != (y)) -#define ST_NUMHASH(x,size) (Abc_AbsInt((long)x)%(size)) -//#define ST_PTRHASH(x,size) ((int)((ABC_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007 -#define ST_PTRHASH(x,size) ((int)(((ABC_PTRUINT_T)(x)>>2)%size)) +#define st__NUMCMP(x,y) ((x) != (y)) +#define st__NUMHASH(x,size) (Abc_AbsInt((long)x)%(size)) +//#define st__PTRHASH(x,size) ((int)((ABC_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007 +#define st__PTRHASH(x,size) ((int)(((ABC_PTRUINT_T)(x)>>2)%size)) #define EQUAL(func, x, y) \ - ((((func) == st_numcmp) || ((func) == st_ptrcmp)) ?\ - (ST_NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0)) + ((((func) == st__numcmp) || ((func) == st__ptrcmp)) ?\ + (st__NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0)) #define do_hash(key, table)\ - ((table->hash == st_ptrhash) ? ST_PTRHASH((key),(table)->num_bins) :\ - (table->hash == st_numhash) ? ST_NUMHASH((key), (table)->num_bins) :\ + ((table->hash == st__ptrhash) ? st__PTRHASH((key),(table)->num_bins) :\ + (table->hash == st__numhash) ? st__NUMHASH((key), (table)->num_bins) :\ (*table->hash)((key), (table)->num_bins)) -static int rehash(st_table *table); +static int rehash( st__table *table); -int st_numhash(const char*, int); -int st_ptrhash(const char*, int); -int st_numcmp(const char*, const char*); -int st_ptrcmp(const char*, const char*); +int st__numhash(const char*, int); +int st__ptrhash(const char*, int); +int st__numcmp(const char*, const char*); +int st__ptrcmp(const char*, const char*); -st_table * -st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag) + st__table * + st__init_table_with_params( st__compare_func_type compare, st__hash_func_type hash, int size, int density, double grow_factor, int reorder_flag) { int i; - st_table *newTable; + st__table *newTable; - newTable = ABC_ALLOC(st_table, 1); + newTable = ABC_ALLOC( st__table, 1); if (newTable == NULL) { return NULL; } @@ -57,7 +57,7 @@ st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash, size = 1; } newTable->num_bins = size; - newTable->bins = ABC_ALLOC(st_table_entry *, size); + newTable->bins = ABC_ALLOC( st__table_entry *, size); if (newTable->bins == NULL) { ABC_FREE(newTable); return NULL; @@ -68,19 +68,19 @@ st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash, return newTable; } -st_table * -st_init_table(st_compare_func_type compare, st_hash_func_type hash) + st__table * + st__init_table( st__compare_func_type compare, st__hash_func_type hash) { - return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE, - ST_DEFAULT_MAX_DENSITY, - ST_DEFAULT_GROW_FACTOR, - ST_DEFAULT_REORDER_FLAG); + return st__init_table_with_params(compare, hash, st__DEFAULT_INIT_TABLE_SIZE, + st__DEFAULT_MAX_DENSITY, + st__DEFAULT_GROW_FACTOR, + st__DEFAULT_REORDER_FLAG); } void -st_free_table(st_table *table) + st__free_table( st__table *table) { - st_table_entry *ptr, *next; + st__table_entry *ptr, *next; int i; for(i = 0; i < table->num_bins ; i++) { @@ -111,10 +111,10 @@ st_free_table(st_table *table) } int -st_lookup(st_table *table, const char *key, char **value) + st__lookup( st__table *table, const char *key, char **value) { int hash_val; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -131,10 +131,10 @@ st_lookup(st_table *table, const char *key, char **value) } int -st_lookup_int(st_table *table, char *key, int *value) + st__lookup_int( st__table *table, char *key, int *value) { int hash_val; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -158,7 +158,7 @@ st_lookup_int(st_table *table, char *key, int *value) hash_val = do_hash(key,table);\ }\ \ - new = ABC_ALLOC(st_table_entry, 1);\ + new = ABC_ALLOC( st__table_entry, 1);\ \ new->key = key;\ new->record = value;\ @@ -168,11 +168,11 @@ st_lookup_int(st_table *table, char *key, int *value) } int -st_insert(st_table *table, const char *key, char *value) + st__insert( st__table *table, const char *key, char *value) { int hash_val; - st_table_entry *newEntry; - st_table_entry *ptr, **last; + st__table_entry *newEntry; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -180,14 +180,14 @@ st_insert(st_table *table, const char *key, char *value) if (ptr == NULL) { if (table->num_entries/table->num_bins >= table->max_density) { - if (rehash(table) == ST_OUT_OF_MEM) { - return ST_OUT_OF_MEM; + if (rehash(table) == st__OUT_OF_MEM) { + return st__OUT_OF_MEM; } hash_val = do_hash(key, table); } - newEntry = ABC_ALLOC(st_table_entry, 1); + newEntry = ABC_ALLOC( st__table_entry, 1); if (newEntry == NULL) { - return ST_OUT_OF_MEM; + return st__OUT_OF_MEM; } newEntry->key = (char *)key; newEntry->record = value; @@ -202,21 +202,21 @@ st_insert(st_table *table, const char *key, char *value) } int -st_add_direct(st_table *table, char *key, char *value) + st__add_direct( st__table *table, char *key, char *value) { int hash_val; - st_table_entry *newEntry; + st__table_entry *newEntry; hash_val = do_hash(key, table); if (table->num_entries / table->num_bins >= table->max_density) { - if (rehash(table) == ST_OUT_OF_MEM) { - return ST_OUT_OF_MEM; + if (rehash(table) == st__OUT_OF_MEM) { + return st__OUT_OF_MEM; } } hash_val = do_hash(key, table); - newEntry = ABC_ALLOC(st_table_entry, 1); + newEntry = ABC_ALLOC( st__table_entry, 1); if (newEntry == NULL) { - return ST_OUT_OF_MEM; + return st__OUT_OF_MEM; } newEntry->key = key; newEntry->record = value; @@ -227,10 +227,10 @@ st_add_direct(st_table *table, char *key, char *value) } int -st_find_or_add(st_table *table, char *key, char ***slot) + st__find_or_add( st__table *table, char *key, char ***slot) { int hash_val; - st_table_entry *newEntry, *ptr, **last; + st__table_entry *newEntry, *ptr, **last; hash_val = do_hash(key, table); @@ -238,14 +238,14 @@ st_find_or_add(st_table *table, char *key, char ***slot) if (ptr == NULL) { if (table->num_entries / table->num_bins >= table->max_density) { - if (rehash(table) == ST_OUT_OF_MEM) { - return ST_OUT_OF_MEM; + if (rehash(table) == st__OUT_OF_MEM) { + return st__OUT_OF_MEM; } hash_val = do_hash(key, table); } - newEntry = ABC_ALLOC(st_table_entry, 1); + newEntry = ABC_ALLOC( st__table_entry, 1); if (newEntry == NULL) { - return ST_OUT_OF_MEM; + return st__OUT_OF_MEM; } newEntry->key = key; newEntry->record = (char *) 0; @@ -261,10 +261,10 @@ st_find_or_add(st_table *table, char *key, char ***slot) } int -st_find(st_table *table, char *key, char ***slot) + st__find( st__table *table, char *key, char ***slot) { int hash_val; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -281,9 +281,9 @@ st_find(st_table *table, char *key, char ***slot) } static int -rehash(st_table *table) +rehash( st__table *table) { - st_table_entry *ptr, *next, **old_bins; + st__table_entry *ptr, *next, **old_bins; int i, old_num_bins, hash_val, old_num_entries; /* save old values */ @@ -297,12 +297,12 @@ rehash(st_table *table) table->num_bins += 1; } table->num_entries = 0; - table->bins = ABC_ALLOC(st_table_entry *, table->num_bins); + table->bins = ABC_ALLOC( st__table_entry *, table->num_bins); if (table->bins == NULL) { table->bins = old_bins; table->num_bins = old_num_bins; table->num_entries = old_num_entries; - return ST_OUT_OF_MEM; + return st__OUT_OF_MEM; } /* initialize */ for (i = 0; i < table->num_bins; i++) { @@ -326,20 +326,20 @@ rehash(st_table *table) return 1; } -st_table * -st_copy(st_table *old_table) + st__table * + st__copy( st__table *old_table) { - st_table *newEntry_table; - st_table_entry *ptr, *newEntryptr, *next, *newEntry; + st__table *newEntry_table; + st__table_entry *ptr, *newEntryptr, *next, *newEntry; int i, j, num_bins = old_table->num_bins; - newEntry_table = ABC_ALLOC(st_table, 1); + newEntry_table = ABC_ALLOC( st__table, 1); if (newEntry_table == NULL) { return NULL; } *newEntry_table = *old_table; - newEntry_table->bins = ABC_ALLOC(st_table_entry *, num_bins); + newEntry_table->bins = ABC_ALLOC( st__table_entry *, num_bins); if (newEntry_table->bins == NULL) { ABC_FREE(newEntry_table); return NULL; @@ -348,7 +348,7 @@ st_copy(st_table *old_table) newEntry_table->bins[i] = NULL; ptr = old_table->bins[i]; while (ptr != NULL) { - newEntry = ABC_ALLOC(st_table_entry, 1); + newEntry = ABC_ALLOC( st__table_entry, 1); if (newEntry == NULL) { for (j = 0; j <= i; j++) { newEntryptr = newEntry_table->bins[j]; @@ -372,11 +372,11 @@ st_copy(st_table *old_table) } int -st_delete(st_table *table, const char **keyp, char **value) + st__delete( st__table *table, const char **keyp, char **value) { int hash_val; const char *key = *keyp; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -395,11 +395,11 @@ st_delete(st_table *table, const char **keyp, char **value) } int -st_delete_int(st_table *table, long *keyp, char **value) + st__delete_int( st__table *table, long *keyp, char **value) { int hash_val; char *key = (char *) *keyp; - st_table_entry *ptr, **last; + st__table_entry *ptr, **last; hash_val = do_hash(key, table); @@ -418,10 +418,10 @@ st_delete_int(st_table *table, long *keyp, char **value) } int -st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char *arg) + st__foreach( st__table *table, enum st__retval (*func)(char *, char *, char *), char *arg) { - st_table_entry *ptr, **last; - enum st_retval retval; + st__table_entry *ptr, **last; + enum st__retval retval; int i; for(i = 0; i < table->num_bins; i++) { @@ -429,14 +429,14 @@ st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char while (ptr != NULL) { retval = (*func)(ptr->key, ptr->record, arg); switch (retval) { - case ST_CONTINUE: + case st__CONTINUE: last = &ptr->next; ptr = *last; break; - case ST_STOP: + case st__STOP: return 0; - case ST_DELETE: + case st__DELETE: *last = ptr->next; - table->num_entries--; /* cstevens@ic */ + table->num_entries--; /* cstevens@ic */ ABC_FREE(ptr); ptr = *last; } @@ -446,7 +446,7 @@ st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char } int -st_strhash(const char *string, int modulus) + st__strhash(const char *string, int modulus) { int val = 0; int c; @@ -459,35 +459,35 @@ st_strhash(const char *string, int modulus) } int -st_numhash(const char *x, int size) + st__numhash(const char *x, int size) { - return ST_NUMHASH(x, size); + return st__NUMHASH(x, size); } int -st_ptrhash(const char *x, int size) + st__ptrhash(const char *x, int size) { - return ST_PTRHASH(x, size); + return st__PTRHASH(x, size); } int -st_numcmp(const char *x, const char *y) + st__numcmp(const char *x, const char *y) { - return ST_NUMCMP(x, y); + return st__NUMCMP(x, y); } int -st_ptrcmp(const char *x, const char *y) + st__ptrcmp(const char *x, const char *y) { - return ST_NUMCMP(x, y); + return st__NUMCMP(x, y); } -st_generator * -st_init_gen(st_table *table) + st__generator * + st__init_gen( st__table *table) { - st_generator *gen; + st__generator *gen; - gen = ABC_ALLOC(st_generator, 1); + gen = ABC_ALLOC( st__generator, 1); if (gen == NULL) { return NULL; } @@ -499,7 +499,7 @@ st_init_gen(st_table *table) int -st_gen(st_generator *gen, const char **key_p, char **value_p) + st__gen( st__generator *gen, const char **key_p, char **value_p) { int i; @@ -513,7 +513,7 @@ st_gen(st_generator *gen, const char **key_p, char **value_p) } } if (gen->entry == NULL) { - return 0; /* that's all folks ! */ + return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; @@ -526,7 +526,7 @@ st_gen(st_generator *gen, const char **key_p, char **value_p) int -st_gen_int(st_generator *gen, const char **key_p, long *value_p) + st__gen_int( st__generator *gen, const char **key_p, long *value_p) { int i; @@ -540,12 +540,12 @@ st_gen_int(st_generator *gen, const char **key_p, long *value_p) } } if (gen->entry == NULL) { - return 0; /* that's all folks ! */ + return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; if (value_p != 0) { - *value_p = (long) gen->entry->record; + *value_p = (long) gen->entry->record; } gen->entry = gen->entry->next; return 1; @@ -553,7 +553,7 @@ st_gen_int(st_generator *gen, const char **key_p, long *value_p) void -st_free_gen(st_generator *gen) + st__free_gen( st__generator *gen) { ABC_FREE(gen); } diff --git a/src/misc/st/st.h b/src/misc/st/st.h index 2cdebcec..07c6ef3b 100644 --- a/src/misc/st/st.h +++ b/src/misc/st/st.h @@ -13,7 +13,7 @@ #ifndef ABC__misc__st__st_h #define ABC__misc__st__st_h -#define ST_INCLUDED +#define st__INCLUDED #include "misc/util/abc_global.h" @@ -38,79 +38,79 @@ ABC_NAMESPACE_HEADER_START #endif -typedef int (*st_compare_func_type)(const char*, const char*); -typedef int (*st_hash_func_type)(const char*, int); +typedef int (* st__compare_func_type)(const char*, const char*); +typedef int (* st__hash_func_type)(const char*, int); -typedef struct st_table_entry st_table_entry; -struct st_table_entry { +typedef struct st__table_entry st__table_entry; +struct st__table_entry { char *key; char *record; - st_table_entry *next; + st__table_entry *next; }; -typedef struct st_table st_table; -struct st_table { - st_compare_func_type compare; - st_hash_func_type hash; +typedef struct st__table st__table; +struct st__table { + st__compare_func_type compare; + st__hash_func_type hash; int num_bins; int num_entries; int max_density; int reorder_flag; double grow_factor; - st_table_entry **bins; + st__table_entry **bins; }; -typedef struct st_generator st_generator; -struct st_generator { - st_table *table; - st_table_entry *entry; +typedef struct st__generator st__generator; +struct st__generator { + st__table *table; + st__table_entry *entry; int index; }; -#define st_is_member(table,key) st_lookup(table,key,(char **) 0) -#define st_count(table) ((table)->num_entries) +#define st__is_member(table,key) st__lookup(table,key,(char **) 0) +#define st__count(table) ((table)->num_entries) -enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE}; +enum st__retval { st__CONTINUE, st__STOP, st__DELETE}; -typedef enum st_retval (*ST_PFSR)(char *, char *, char *); -typedef int (*ST_PFI)(); +typedef enum st__retval (* st__PFSR)(char *, char *, char *); +typedef int (* st__PFI)(); -extern st_table *st_init_table_with_params (st_compare_func_type compare, st_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag); -extern st_table *st_init_table (st_compare_func_type, st_hash_func_type); -extern void st_free_table (st_table *); -extern int st_lookup (st_table *, const char *, char **); -extern int st_lookup_int (st_table *, char *, int *); -extern int st_insert (st_table *, const char *, char *); -extern int st_add_direct (st_table *, char *, char *); -extern int st_find_or_add (st_table *, char *, char ***); -extern int st_find (st_table *, char *, char ***); -extern st_table *st_copy (st_table *); -extern int st_delete (st_table *, const char **, char **); -extern int st_delete_int (st_table *, long *, char **); -extern int st_foreach (st_table *, ST_PFSR, char *); -extern int st_strhash (const char *, int); -extern int st_numhash (const char *, int); -extern int st_ptrhash (const char *, int); -extern int st_numcmp (const char *, const char *); -extern int st_ptrcmp (const char *, const char *); -extern st_generator *st_init_gen (st_table *); -extern int st_gen (st_generator *, const char **, char **); -extern int st_gen_int (st_generator *, const char **, long *); -extern void st_free_gen (st_generator *); +extern st__table * st__init_table_with_params ( st__compare_func_type compare, st__hash_func_type hash, int size, int density, double grow_factor, int reorder_flag); +extern st__table * st__init_table ( st__compare_func_type, st__hash_func_type); +extern void st__free_table ( st__table *); +extern int st__lookup ( st__table *, const char *, char **); +extern int st__lookup_int ( st__table *, char *, int *); +extern int st__insert ( st__table *, const char *, char *); +extern int st__add_direct ( st__table *, char *, char *); +extern int st__find_or_add ( st__table *, char *, char ***); +extern int st__find ( st__table *, char *, char ***); +extern st__table * st__copy ( st__table *); +extern int st__delete ( st__table *, const char **, char **); +extern int st__delete_int ( st__table *, long *, char **); +extern int st__foreach ( st__table *, st__PFSR, char *); +extern int st__strhash (const char *, int); +extern int st__numhash (const char *, int); +extern int st__ptrhash (const char *, int); +extern int st__numcmp (const char *, const char *); +extern int st__ptrcmp (const char *, const char *); +extern st__generator * st__init_gen ( st__table *); +extern int st__gen ( st__generator *, const char **, char **); +extern int st__gen_int ( st__generator *, const char **, long *); +extern void st__free_gen ( st__generator *); -#define ST_DEFAULT_MAX_DENSITY 5 -#define ST_DEFAULT_INIT_TABLE_SIZE 11 -#define ST_DEFAULT_GROW_FACTOR 2.0 -#define ST_DEFAULT_REORDER_FLAG 0 +#define st__DEFAULT_MAX_DENSITY 5 +#define st__DEFAULT_INIT_TABLE_SIZE 11 +#define st__DEFAULT_GROW_FACTOR 2.0 +#define st__DEFAULT_REORDER_FLAG 0 -#define st_foreach_item(table, gen, key, value) \ - for(gen=st_init_gen(table); st_gen(gen,key,value) || (st_free_gen(gen),0);) +#define st__foreach_item(table, gen, key, value) \ + for(gen= st__init_gen(table); st__gen(gen,key,value) || ( st__free_gen(gen),0);) -#define st_foreach_item_int(table, gen, key, value) \ - for(gen=st_init_gen(table); st_gen_int(gen,key,value) || (st_free_gen(gen),0);) +#define st__foreach_item_int(table, gen, key, value) \ + for(gen= st__init_gen(table); st__gen_int(gen,key,value) || ( st__free_gen(gen),0);) -#define ST_OUT_OF_MEM -10000 +#define st__OUT_OF_MEM -10000 @@ -118,4 +118,4 @@ ABC_NAMESPACE_HEADER_END -#endif /* ST_INCLUDED */ +#endif /* st__INCLUDED */ diff --git a/src/misc/st/stmm.c b/src/misc/st/stmm.c index b7f5b87e..99d78ae1 100644 --- a/src/misc/st/stmm.c +++ b/src/misc/st/stmm.c @@ -499,7 +499,7 @@ stmm_foreach (stmm_table *table, enum stmm_retval (*func) (char *, char *, char return 0; case STMM_DELETE: *last = ptr->next; - table->num_entries--; /* cstevens@ic */ + table->num_entries--; /* cstevens@ic */ // ABC_FREE( ptr ); Extra_MmFixedEntryRecycle ((Extra_MmFixed_t *)table->pMemMan, (char *) ptr); @@ -578,7 +578,7 @@ stmm_gen (stmm_generator *gen, char **key_p, char **value_p) } } if (gen->entry == NULL) { - return 0; /* that's all folks ! */ + return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; @@ -605,7 +605,7 @@ stmm_gen_int (stmm_generator *gen, char **key_p, long *value_p) } } if (gen->entry == NULL) { - return 0; /* that's all folks ! */ + return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; diff --git a/src/misc/st/stmm.h b/src/misc/st/stmm.h index 87daea19..36c3b8c4 100644 --- a/src/misc/st/stmm.h +++ b/src/misc/st/stmm.h @@ -129,12 +129,12 @@ EXTERN void stmm_clean ARGS ((stmm_table *)); /* // consider adding these other other similar definitions -#define st_table stmm_table -#define st_insert stmm_insert -#define st_delete stmm_delete -#define st_lookup stmm_lookup -#define st_init_table stmm_init_table -#define st_free_table stmm_free_table +#define st__table stmm_table +#define st__insert stmm_insert +#define st__delete stmm_delete +#define st__lookup stmm_lookup +#define st__init_table stmm_init_table +#define st__free_table stmm_free_table */ -- cgit v1.2.3