214#define CX_HASH_KEY(key) _Generic((key), \
215 CxHashKey: cx_hash_key_identity, \
216 cxstring: cx_hash_key_cxstr, \
217 cxmutstr: cx_hash_key_mutstr, \
218 char*: cx_hash_key_str, \
219 const char*: cx_hash_key_str, \
220 unsigned char*: cx_hash_key_ustr, \
221 const unsigned char*: cx_hash_key_ustr, \
222 uint32_t: cx_hash_key_u32, \
223 uint64_t: cx_hash_key_u64) \
Common definitions and feature checks.
#define CX_INLINE
Declares a function to be inlined.
Definition common.h:290
#define cx_attr_nonnull
All pointer arguments must be non-NULL.
Definition common.h:141
#define CX_EXPORT
Only used for building Windows DLLs.
Definition common.h:278
#define cx_attr_nodiscard
Warn about discarded return value.
Definition common.h:256
#define cx_attr_access_r(...)
Specifies that the function will only read through the given pointer.
Definition common.h:230
#define cx_attr_cstr_arg(idx)
No support for null_terminated_string_arg in clang or GCC below 14.
Definition common.h:211
#define CX_CPPDECL
Declares a compatibility function for C++ builds.
Definition common.h:295
CxHashKey cx_hash_key_bytes(const unsigned char *bytes, size_t len)
Computes a hash key from a byte array.
CxHashKey cx_hash_key_str(const char *str)
Computes a hash key from a string.
CxHashKey cx_hash_key_u64(uint64_t x)
Computes a hash key from a 64-bit integer.
uint64_t cx_hash_u64(uint64_t x)
Mixes up a 64-bit integer to be used as a hash.
void cx_hash_murmur(CxHashKey *key)
Computes a murmur2 32-bit hash.
CxHashKey cx_hash_key_cxstr(cxstring str)
Computes a hash key from a UCX string.
uint32_t cx_hash_u32(uint32_t x)
Mixes up a 32-bit integer to be used as a hash.
#define CX_HASH_KEY(key)
Creates a hash key from any of the supported types with implicit length.
Definition hash_key.h:214
CxHashKey cx_hash_key_u32(uint32_t x)
Computes a hash key from a 32-bit integer.
CxHashKey cx_hash_key(const void *obj, size_t len)
Computes a hash key for an arbitrary object.
struct cx_hash_key_s CxHashKey
Type for a hash key.
Definition hash_key.h:65
static CxHashKey cx_hash_key_identity(CxHashKey key)
The identity function for the CX_HASH_KEY() macro.
Definition hash_key.h:198
int cx_hash_key_cmp(const void *left, const void *right)
Compare function for hash keys.
CxHashKey cx_hash_key_mutstr(cxmutstr str)
Computes a hash key from a UCX string.
CxHashKey cx_hash_key_ustr(const unsigned char *str)
Computes a hash key from a string.
Strings that know their length.
struct cx_string_s cxstring
An immutable string.
Definition string.h:87
struct cx_mutstr_s cxmutstr
A mutable string.
Definition string.h:69
Internal structure for a key within a hash map.
Definition hash_key.h:48
const void * data
The key data.
Definition hash_key.h:53
uint64_t hash
The hash value of the key data.
Definition hash_key.h:59
size_t len
The key data length.
Definition hash_key.h:57