From 1294791f0c1e1814a2c742da6be325df179bdf4b Mon Sep 17 00:00:00 2001 From: Matthew Brush Date: Thu, 7 Mar 2013 12:31:52 -0800 Subject: [PATCH] Replace non-standard 'u_int32_t' with 'unsigned int' Rather than standard uint32_t from stdint.h since it's C99. Also adjust configure.ac to provide a uint64_t if one isn't available for use in ctimer.c. --- configure.ac | 1 + src/cfuhash.c | 24 ++++++++++++------------ src/cfuhash.h | 13 ++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index c07d46e..4016127 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,7 @@ AC_CHECK_HEADERS([stdarg.h sys/time.h]) AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T +AC_TYPE_UINT64_T # Checks for library functions. AC_FUNC_MALLOC diff --git a/src/cfuhash.c b/src/cfuhash.c index 0b9ae2d..6c5d68f 100644 --- a/src/cfuhash.c +++ b/src/cfuhash.c @@ -101,7 +101,7 @@ struct cfuhash_table { #ifdef HAVE_PTHREAD_H pthread_mutex_t mutex; #endif - u_int32_t flags; + unsigned int flags; cfuhash_function_t hash_func; size_t each_bucket_index; cfuhash_entry *each_chain_entry; @@ -113,7 +113,7 @@ struct cfuhash_table { }; /* Perl's hash function */ -static u_int32_t +static unsigned int hash_func(const void *key, size_t length) { register size_t i = length; register unsigned int hv = 0; /* could put a seed here instead of zero */ @@ -177,7 +177,7 @@ hash_value(cfuhash_table_t *ht, const void *key, size_t key_size, size_t num_buc } static cfuhash_table_t * -_cfuhash_new(size_t size, u_int32_t flags) { +_cfuhash_new(size_t size, unsigned int flags) { cfuhash_table_t *ht; size = hash_size(size); @@ -213,7 +213,7 @@ cfuhash_new_with_initial_size(size_t size) { } cfuhash_table_t * -cfuhash_new_with_flags(u_int32_t flags) { +cfuhash_new_with_flags(unsigned int flags) { return _cfuhash_new(8, CFUHASH_FROZEN_UNTIL_GROWS|flags); } @@ -248,7 +248,7 @@ cfuhash_copy(cfuhash_table_t *src, cfuhash_table_t *dst) { } cfuhash_table_t * -cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2, u_int32_t flags) { +cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2, unsigned int flags) { cfuhash_table_t *new_ht = NULL; flags |= CFUHASH_FROZEN_UNTIL_GROWS; @@ -260,22 +260,22 @@ cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2, u_int32_t flags) { } /* returns the flags */ -u_int32_t +unsigned int cfuhash_get_flags(cfuhash_table_t *ht) { return ht->flags; } /* sets the given flag and returns the old flags value */ -u_int32_t -cfuhash_set_flag(cfuhash_table_t *ht, u_int32_t new_flag) { - u_int32_t flags = ht->flags; +unsigned int +cfuhash_set_flag(cfuhash_table_t *ht, unsigned int new_flag) { + unsigned int flags = ht->flags; ht->flags = flags | new_flag; return flags; } -u_int32_t -cfuhash_clear_flag(cfuhash_table_t *ht, u_int32_t new_flag) { - u_int32_t flags = ht->flags; +unsigned int +cfuhash_clear_flag(cfuhash_table_t *ht, unsigned int new_flag) { + unsigned int flags = ht->flags; ht->flags = flags & ~new_flag; return flags; } diff --git a/src/cfuhash.h b/src/cfuhash.h index efeaf71..b6c561b 100644 --- a/src/cfuhash.h +++ b/src/cfuhash.h @@ -40,7 +40,6 @@ #include #include -#include CFU_BEGIN_DECLS @@ -48,7 +47,7 @@ CFU_BEGIN_DECLS typedef struct cfuhash_table cfuhash_table_t; /* Prototype for a pointer to a hashing function. */ -typedef u_int32_t (*cfuhash_function_t)(const void *key, size_t length); +typedef unsigned int (*cfuhash_function_t)(const void *key, size_t length); /* Prototype for a pointer to a free function. */ typedef void (*cfuhash_free_fn_t)(void *data); @@ -77,7 +76,7 @@ cfuhash_table_t * cfuhash_new_with_initial_size(size_t size); /* Creates a new hash table with the specified flags. Pass zero * for flags if you want the defaults. */ -cfuhash_table_t * cfuhash_new_with_flags(u_int32_t flags); +cfuhash_table_t * cfuhash_new_with_flags(unsigned int flags); /* Same as cfuhash_new() except automatically calls cfuhash_set_free_fn(). */ cfuhash_table_t * cfuhash_new_with_free_fn(cfuhash_free_fn_t ff); @@ -89,7 +88,7 @@ int cfuhash_copy(cfuhash_table_t *src, cfuhash_table_t *dst); * For any entries with the same key, the one from ht2 wins. */ cfuhash_table_t * cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2, - u_int32_t flags); + unsigned int flags); /* Sets the hashing function to use when computing which bucket to add * entries to. It should return a 32-bit unsigned integer. By @@ -112,13 +111,13 @@ int cfuhash_set_thresholds(cfuhash_table_t *ht, float low, float high); int cfuhash_set_free_function(cfuhash_table_t * ht, cfuhash_free_fn_t ff); /* Returns the hash's flags. See below for flag definitions. */ -u_int32_t cfuhash_get_flags(cfuhash_table_t *ht); +unsigned int cfuhash_get_flags(cfuhash_table_t *ht); /* Sets a flag. */ -u_int32_t cfuhash_set_flag(cfuhash_table_t *ht, u_int32_t flag); +unsigned int cfuhash_set_flag(cfuhash_table_t *ht, unsigned int flag); /* Clears a flag. */ -u_int32_t cfuhash_clear_flag(cfuhash_table_t *ht, u_int32_t new_flag); +unsigned int cfuhash_clear_flag(cfuhash_table_t *ht, unsigned int new_flag); /* Returns the value for the entry with given key. If key_size is -1, * key is assumed to be a null-terminated string. If data_size is not