]> git.kaiwu.me - klib.git/commitdiff
Add khash wrapper around inline
authorRussell Belfer <rb@github.com>
Fri, 31 Aug 2012 23:10:12 +0000 (16:10 -0700)
committerRussell Belfer <rb@github.com>
Fri, 31 Aug 2012 23:10:12 +0000 (16:10 -0700)
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.

khash.h

diff --git a/khash.h b/khash.h
index 1bc327c1c1d83131786eb27642b9a24cc41ddcb9..afa2e16585ca027d3e220ca61de2e574e88470ba 100644 (file)
--- 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);