From: Russell Belfer Date: Fri, 31 Aug 2012 23:10:12 +0000 (-0700) Subject: Add khash wrapper around inline X-Git-Tag: spawn-final~43^2~2 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=bfb7a7457766e1016f272ac70a0107f45a4ee331;p=klib.git Add khash wrapper around inline As with allocation functions, when embedding khash inside another library, the use of the non-portable "inline" keyword can be tricky. Instead of adding a #define of inline, this adds "kh_inline" which can be defined as needed inside khash with better isolation. --- diff --git a/khash.h b/khash.h index 1bc327c..afa2e16 100644 --- a/khash.h +++ b/khash.h @@ -131,7 +131,9 @@ typedef unsigned long long khint64_t; #endif #ifdef _MSC_VER -#define inline __inline +#define kh_inline __inline +#else +#define kh_inline inline #endif typedef khint32_t khint_t; @@ -374,7 +376,7 @@ static const double __ac_HASH_UPPER = 0.77; @param s Pointer to a null terminated string @return The hash value */ -static inline khint_t __ac_X31_hash_string(const char *s) +static kh_inline khint_t __ac_X31_hash_string(const char *s) { khint_t h = *s; if (h) for (++s ; *s; ++s) h = (h << 5) - h + *s; @@ -391,7 +393,7 @@ static inline khint_t __ac_X31_hash_string(const char *s) */ #define kh_str_hash_equal(a, b) (strcmp(a, b) == 0) -static inline khint_t __ac_Wang_hash(khint_t key) +static kh_inline khint_t __ac_Wang_hash(khint_t key) { key += ~(key << 15); key ^= (key >> 10);