From 6e77e712012b96c2377cab09d0271fe3bf3cfb54 Mon Sep 17 00:00:00 2001 From: David Ward Date: Sat, 18 Aug 2018 17:35:41 -0400 Subject: [PATCH 1/2] Rename kh_inline to klib_inline and use in kdq, klist --- kdq.h | 10 +++++++++- khash.h | 14 +++++++------- klist.h | 12 ++++++++++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/kdq.h b/kdq.h index edd55b57..6cef5a7a 100644 --- a/kdq.h +++ b/kdq.h @@ -93,6 +93,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 +109,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 From ddf3e3a67723d9fc7280449f49030697ca641974 Mon Sep 17 00:00:00 2001 From: David Ward Date: Mon, 3 Dec 2018 19:02:31 -0500 Subject: [PATCH 2/2] Fix definition of kdq_*_t for non-64-bit platforms --- kdq.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kdq.h b/kdq.h index 6cef5a7a..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;