diff --git a/kdq.h b/kdq.h index edd55b57..52e1fc3d 100644 --- a/kdq.h +++ b/kdq.h @@ -3,10 +3,11 @@ #include #include +#include #define __KDQ_TYPE(type) \ typedef struct { \ - size_t front:58, bits:6, count, mask; \ + size_t front:((CHAR_BIT * sizeof(size_t)) - 6), bits:6, count, mask; \ type *a; \ } kdq_##type##_t; @@ -93,6 +94,14 @@ __KDQ_TYPE(type) \ __KDQ_IMPL(type, SCOPE) +#ifndef klib_inline +#ifdef _MSC_VER +#define klib_inline __inline +#else +#define klib_inline inline +#endif +#endif /* klib_inline */ + #ifndef klib_unused #if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3) #define klib_unused __attribute__ ((__unused__)) @@ -101,7 +110,7 @@ #endif #endif /* klib_unused */ -#define KDQ_INIT(type) KDQ_INIT2(type, static inline klib_unused) +#define KDQ_INIT(type) KDQ_INIT2(type, static klib_inline klib_unused) #define KDQ_DECLARE(type) \ __KDQ_TYPE(type) \ diff --git a/khash.h b/khash.h index f75f3474..170237ec 100644 --- a/khash.h +++ b/khash.h @@ -143,13 +143,13 @@ typedef unsigned long khint64_t; typedef unsigned long long khint64_t; #endif -#ifndef kh_inline +#ifndef klib_inline #ifdef _MSC_VER -#define kh_inline __inline +#define klib_inline __inline #else -#define kh_inline inline +#define klib_inline inline #endif -#endif /* kh_inline */ +#endif /* klib_inline */ #ifndef klib_unused #if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3) @@ -363,7 +363,7 @@ static const double __ac_HASH_UPPER = 0.77; __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) #define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ - KHASH_INIT2(name, static kh_inline klib_unused, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) + KHASH_INIT2(name, static klib_inline klib_unused, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) /* --- BEGIN OF HASH FUNCTIONS --- */ @@ -392,7 +392,7 @@ static const double __ac_HASH_UPPER = 0.77; @param s Pointer to a null terminated string @return The hash value */ -static kh_inline khint_t __ac_X31_hash_string(const char *s) +static klib_inline khint_t __ac_X31_hash_string(const char *s) { khint_t h = (khint_t)*s; if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)*s; @@ -409,7 +409,7 @@ static kh_inline khint_t __ac_X31_hash_string(const char *s) */ #define kh_str_hash_equal(a, b) (strcmp(a, b) == 0) -static kh_inline khint_t __ac_Wang_hash(khint_t key) +static klib_inline khint_t __ac_Wang_hash(khint_t key) { key += ~(key << 15); key ^= (key >> 10); diff --git a/klist.h b/klist.h index adc3db1e..72ab3e5f 100644 --- a/klist.h +++ b/klist.h @@ -28,6 +28,14 @@ #include +#ifndef klib_inline +#ifdef _MSC_VER +#define klib_inline __inline +#else +#define klib_inline inline +#endif +#endif /* klib_inline */ + #ifndef klib_unused #if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3) #define klib_unused __attribute__ ((__unused__)) @@ -66,7 +74,7 @@ } #define KMEMPOOL_INIT(name, kmptype_t, kmpfree_f) \ - KMEMPOOL_INIT2(static inline klib_unused, name, kmptype_t, kmpfree_f) + KMEMPOOL_INIT2(static klib_inline klib_unused, name, kmptype_t, kmpfree_f) #define kmempool_t(name) kmp_##name##_t #define kmp_init(name) kmp_init_##name() @@ -118,7 +126,7 @@ } #define KLIST_INIT(name, kltype_t, kmpfree_t) \ - KLIST_INIT2(static inline klib_unused, name, kltype_t, kmpfree_t) + KLIST_INIT2(static klib_inline klib_unused, name, kltype_t, kmpfree_t) #define kliter_t(name) kl1_##name #define klist_t(name) kl_##name##_t