Skip to content

Commit

Permalink
Rename kh_inline to klib_inline and use in kdq, klist
Browse files Browse the repository at this point in the history
  • Loading branch information
dpward committed Oct 4, 2018
1 parent 2629253 commit 9b39800
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
10 changes: 9 additions & 1 deletion kdq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand All @@ -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) \
Expand Down
14 changes: 7 additions & 7 deletions khash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 --- */

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions klist.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@

#include <stdlib.h>

#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__))
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9b39800

Please sign in to comment.