diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h index 96f0c21f60..f93809a482 100644 --- a/src/include/lib/simplehash.h +++ b/src/include/lib/simplehash.h @@ -51,7 +51,8 @@ * - SH_STORE_HASH - if defined the hash is stored in the elements * - SH_GET_HASH(tb, a) - return the field to store the hash in * - * The element type is required to contain a "uint32 status" member. + * The element type is required to contain a "status" member which must be + * an integer type of at least char in width. * * While SH_STORE_HASH (and subsequently SH_GET_HASH) are optional, because * the hash table implementation needs to compare hashes to move elements @@ -98,9 +99,6 @@ /* type declarations */ #define SH_TYPE SH_MAKE_NAME(hash) -#define SH_STATUS SH_MAKE_NAME(status) -#define SH_STATUS_EMPTY SH_MAKE_NAME(SH_EMPTY) -#define SH_STATUS_IN_USE SH_MAKE_NAME(SH_IN_USE) #define SH_ITERATOR SH_MAKE_NAME(iterator) /* function declarations */ @@ -130,6 +128,17 @@ #define SH_INSERT_HASH_INTERNAL SH_MAKE_NAME(insert_hash_internal) #define SH_LOOKUP_HASH_INTERNAL SH_MAKE_NAME(lookup_hash_internal) +/* Undef these for cases where users include simplehash.h twice */ +#undef SH_STATUS_EMPTY +#undef SH_STATUS_IN_USE + +/* + * Values for SH_ELEMENT_TYPE->status field. Values must fit in char data + * type. + */ +#define SH_STATUS_EMPTY 0 +#define SH_STATUS_IN_USE 1 + /* generate forward declarations necessary to use the hash table */ #ifdef SH_DECLARE @@ -164,12 +173,6 @@ typedef struct SH_TYPE void *private_data; } SH_TYPE; -typedef enum SH_STATUS -{ - SH_STATUS_EMPTY = 0x00, - SH_STATUS_IN_USE = 0x01 -} SH_STATUS; - typedef struct SH_ITERATOR { uint32 cur; /* current element */ @@ -1090,9 +1093,6 @@ SH_STAT(SH_TYPE * tb) /* types */ #undef SH_TYPE -#undef SH_STATUS -#undef SH_STATUS_EMPTY -#undef SH_STATUS_IN_USE #undef SH_ITERATOR /* external function names */