90 x = ((x >> 16) ^ x) * 0x45d9f3bu;
91 x = ((x >> 16) ^ x) * 0x45d9f3bu;
106 x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);
107 x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb);
166 return cx_hash_key((
const void*)str, str == NULL ? 0 : strlen(str));
182 return cx_hash_key((
const void*)str, str == NULL ? 0 : strlen((
const char*)str));
255#define CX_HASH_KEY(key) _Generic((key), \
256 CxHashKey*: cx_hash_key_deref, \
257 const CxHashKey*: cx_hash_key_deref, \
258 CxHashKey: cx_hash_key_identity, \
259 cxstring: cx_hash_key_cxstr, \
260 cxmutstr: cx_hash_key_mutstr, \
261 char*: cx_hash_key_str, \
262 const char*: cx_hash_key_str, \
263 unsigned char*: cx_hash_key_ustr, \
264 const unsigned char*: cx_hash_key_ustr, \
265 uint32_t: cx_hash_key_u32, \
266 uint64_t: cx_hash_key_u64) \
Common definitions and feature checks.
#define CX_INLINE
Declares a function to be inlined.
Definition common.h:311
#define CX_CSTR_ARG(idx)
No support for null_terminated_string_arg in clang or GCC below 14.
Definition common.h:211
#define CX_NONNULL
All pointer arguments must be non-NULL.
Definition common.h:141
#define CX_NODISCARD
Warn about discarded return value.
Definition common.h:256
#define CX_EXTERN
Declares a function with external linkage.
Definition common.h:297
#define CX_ACCESS_R(...)
Specifies that the function will only read through the given pointer.
Definition common.h:230
#define CX_CPPDECL
Declares a compatibility function for C++ builds.
Definition common.h:316
static CxHashKey cx_hash_key_bytes(const unsigned char *bytes, size_t len)
Computes a hash key from a byte array.
Definition hash_key.h:193
static CxHashKey cx_hash_key_deref(const CxHashKey *key)
The dereference function for the CX_HASH_KEY() macro.
Definition hash_key.h:239
void cx_hash_murmur(CxHashKey *key)
Computes a murmur2 32-bit hash.
static uint64_t cx_hash_u64(uint64_t x)
Mixes up a 64-bit integer to be used as a hash.
Definition hash_key.h:105
static CxHashKey cx_hash_key_u32(uint32_t x)
Computes a hash key from a 32-bit integer.
Definition hash_key.h:133
#define CX_HASH_KEY(key)
Creates a hash key from any of the supported types with implicit length.
Definition hash_key.h:255
static uint32_t cx_hash_u32(uint32_t x)
Mixes up a 32-bit integer to be used as a hash.
Definition hash_key.h:89
CxHashKey cx_hash_key(const void *obj, size_t len)
Computes a hash key for an arbitrary object.
static CxHashKey cx_hash_key_ustr(const unsigned char *str)
Computes a hash key from a string.
Definition hash_key.h:181
struct cx_hash_key_s CxHashKey
Type for a hash key.
Definition hash_key.h:61
static CxHashKey cx_hash_key_identity(CxHashKey key)
The identity function for the CX_HASH_KEY() macro.
Definition hash_key.h:227
static CxHashKey cx_hash_key_u64(uint64_t x)
Computes a hash key from a 64-bit integer.
Definition hash_key.h:148
int cx_hash_key_cmp(const void *left, const void *right)
Compare function for hash keys.
static CxHashKey cx_hash_key_mutstr(cxmutstr str)
Computes a hash key from a UCX string.
Definition hash_key.h:215
static CxHashKey cx_hash_key_cxstr(cxstring str)
Computes a hash key from a UCX string.
Definition hash_key.h:204
static CxHashKey cx_hash_key_str(const char *str)
Computes a hash key from a string.
Definition hash_key.h:165
cxstring cx_hash_key_as_string(const CxHashKey *key)
Interprets the key data as a string and returns it.
Strings that know their length.
struct cx_string_s cxstring
An immutable string.
Definition string.h:92
struct cx_mutstr_s cxmutstr
A mutable string.
Definition string.h:74
Internal structure for a key within a hash map.
Definition hash_key.h:44
const void * data
The key data.
Definition hash_key.h:49
uint64_t hash
The hash value of the key data.
Definition hash_key.h:55
size_t len
The key data length.
Definition hash_key.h:53
char * ptr
A pointer to the string.
Definition string.h:66
size_t length
The length of the string.
Definition string.h:68
size_t length
The length of the string.
Definition string.h:86
const char * ptr
A pointer to the immutable string.
Definition string.h:84