src/cx/hash_key.h

changeset 1426
3a89b31f0724
parent 1424
563033aa998c
--- a/src/cx/hash_key.h	Wed Oct 15 22:45:21 2025 +0200
+++ b/src/cx/hash_key.h	Thu Oct 16 19:57:47 2025 +0200
@@ -79,8 +79,7 @@
  * @see cx_hash_key()
  */
 cx_attr_nonnull
-cx_attr_export
-void cx_hash_murmur(CxHashKey *key);
+CX_EXPORT void cx_hash_murmur(CxHashKey *key);
 
 /**
  * Mixes up a 32-bit integer to be used as a hash.
@@ -90,8 +89,7 @@
  * @param x the integer
  * @return the hash
  */
-cx_attr_export
-uint32_t cx_hash_u32(uint32_t x);
+CX_EXPORT uint32_t cx_hash_u32(uint32_t x);
 
 /**
  * Mixes up a 64-bit integer to be used as a hash.
@@ -101,8 +99,7 @@
  * @param x the integer
  * @return the hash
  */
-cx_attr_export
-uint64_t cx_hash_u64(uint64_t x);
+CX_EXPORT uint64_t cx_hash_u64(uint64_t x);
 
 /**
  * Computes a hash key from a 32-bit integer.
@@ -111,8 +108,7 @@
  * @return the hash key
  */
 cx_attr_nodiscard
-cx_attr_export
-CxHashKey cx_hash_key_u32(uint32_t x);
+CX_EXPORT CxHashKey cx_hash_key_u32(uint32_t x);
 
 /**
  * Computes a hash key from a 64-bit integer.
@@ -121,8 +117,7 @@
  * @return the hash key
  */
 cx_attr_nodiscard
-cx_attr_export
-CxHashKey cx_hash_key_u64(uint64_t x);
+CX_EXPORT CxHashKey cx_hash_key_u64(uint64_t x);
 
 /**
  * Computes a hash key from a string.
@@ -132,10 +127,8 @@
  * @param str the string
  * @return the hash key
  */
-cx_attr_nodiscard
-cx_attr_cstr_arg(1)
-cx_attr_export
-CxHashKey cx_hash_key_str(const char *str);
+cx_attr_nodiscard cx_attr_cstr_arg(1)
+CX_EXPORT CxHashKey cx_hash_key_str(const char *str);
 
 /**
  * Computes a hash key from a string.
@@ -148,12 +141,8 @@
  * @param str the string
  * @return the hash key
  */
-cx_attr_nodiscard
-cx_attr_cstr_arg(1)
-cx_attr_export
-static inline CxHashKey cx_hash_key_ustr(const unsigned char *str) {
-    return cx_hash_key_str((const char*)str);
-}
+cx_attr_nodiscard cx_attr_cstr_arg(1)
+CX_EXPORT CxHashKey cx_hash_key_ustr(const unsigned char *str);
 
 /**
  * Computes a hash key from a byte array.
@@ -162,13 +151,8 @@
  * @param len the length
  * @return the hash key
  */
-cx_attr_nodiscard
-cx_attr_access_r(1, 2)
-cx_attr_export
-CxHashKey cx_hash_key_bytes(
-        const unsigned char *bytes,
-        size_t len
-);
+cx_attr_nodiscard cx_attr_access_r(1, 2)
+CX_EXPORT CxHashKey cx_hash_key_bytes(const unsigned char *bytes, size_t len);
 
 /**
  * Computes a hash key for an arbitrary object.
@@ -183,11 +167,7 @@
  */
 cx_attr_nodiscard
 cx_attr_access_r(1, 2)
-cx_attr_export
-CxHashKey cx_hash_key(
-        const void *obj,
-        size_t len
-);
+CX_EXPORT CxHashKey cx_hash_key(const void *obj, size_t len);
 
 /**
  * Computes a hash key from a UCX string.
@@ -196,9 +176,7 @@
  * @return the hash key
  */
 cx_attr_nodiscard
-static inline CxHashKey cx_hash_key_cxstr(cxstring str) {
-    return cx_hash_key(str.ptr, str.length);
-}
+CX_EXPORT CxHashKey cx_hash_key_cxstr(cxstring str);
 
 /**
  * Computes a hash key from a UCX string.
@@ -207,9 +185,7 @@
  * @return the hash key
  */
 cx_attr_nodiscard
-static inline CxHashKey cx_hash_key_mutstr(cxmutstr str) {
-    return cx_hash_key(str.ptr, str.length);
-}
+CX_EXPORT CxHashKey cx_hash_key_mutstr(cxmutstr str);
 
 /**
  * The identity function for the CX_HASH_KEY() macro.
@@ -219,7 +195,7 @@
  * @return a copy of the key
  */
 cx_attr_nodiscard
-static inline CxHashKey cx_hash_key_identity(CxHashKey key) {
+CX_INLINE CxHashKey cx_hash_key_identity(CxHashKey key) {
     return key;
 }
 
@@ -249,25 +225,14 @@
 #endif // __cplusplus
 
 /**
- * Computes a hash key from a UCX string.
- * Convenience macro that accepts both cxstring and cxmutstr.
- * @deprecated use the CX_HASH_KEY() macro instead
- * @param str (@c cxstring or @c cxmutstr) the string
- * @return (@c CxHashKey) the hash key
- */
-#define cx_hash_key_cxstr(str) cx_hash_key_cxstr(cx_strcast(str))
-
-/**
  * Compare function for hash keys.
  *
  * @param left the first key
  * @param right the second key
  * @return zero when the keys equal, non-zero when they differ
  */
-cx_attr_nodiscard
-cx_attr_nonnull
-cx_attr_export
-int cx_hash_key_cmp(const CxHashKey *left, const CxHashKey *right);
+cx_attr_nodiscard cx_attr_nonnull
+CX_EXPORT int cx_hash_key_cmp(const CxHashKey *left, const CxHashKey *right);
 
 #ifdef __cplusplus
 } // extern "C"
@@ -276,31 +241,31 @@
 // Overloads of CX_HASH_KEY (the C++ version of a _Generic)
 // ----------------------------------------------------------
 
-static inline CxHashKey CX_HASH_KEY(CxHashKey key) {
+CX_CPPDECL CxHashKey CX_HASH_KEY(CxHashKey key) {
     return key;
 }
 
-static inline CxHashKey CX_HASH_KEY(cxstring str) {
+CX_CPPDECL CxHashKey CX_HASH_KEY(cxstring str) {
     return cx_hash_key_cxstr(str);
 }
 
-static inline CxHashKey CX_HASH_KEY(cxmutstr str) {
+CX_CPPDECL CxHashKey CX_HASH_KEY(cxmutstr str) {
     return cx_hash_key_mutstr(str);
 }
 
-static inline CxHashKey CX_HASH_KEY(const char *str) {
+CX_CPPDECL CxHashKey CX_HASH_KEY(const char *str) {
     return cx_hash_key_str(str);
 }
 
-static inline CxHashKey CX_HASH_KEY(const unsigned char *str) {
+CX_CPPDECL CxHashKey CX_HASH_KEY(const unsigned char *str) {
     return cx_hash_key_ustr(str);
 }
 
-static inline CxHashKey CX_HASH_KEY(uint32_t key) {
+CX_CPPDECL CxHashKey CX_HASH_KEY(uint32_t key) {
     return cx_hash_key_u32(key);
 }
 
-static inline CxHashKey CX_HASH_KEY(uint64_t key) {
+CX_CPPDECL CxHashKey CX_HASH_KEY(uint64_t key) {
     return cx_hash_key_u64(key);
 }
 #endif

mercurial