| 110 * @param len the length of object in memory |
111 * @param len the length of object in memory |
| 111 * @return the hash key |
112 * @return the hash key |
| 112 */ |
113 */ |
| 113 cx_attr_nodiscard |
114 cx_attr_nodiscard |
| 114 cx_attr_access_r(1, 2) |
115 cx_attr_access_r(1, 2) |
| 115 __attribute__((__warn_unused_result__)) |
|
| 116 CxHashKey cx_hash_key( |
116 CxHashKey cx_hash_key( |
| 117 const void *obj, |
117 const void *obj, |
| 118 size_t len |
118 size_t len |
| 119 ); |
119 ); |
| 120 |
120 |
| |
121 #ifdef __cplusplus |
| |
122 } // extern "C" |
| |
123 |
| |
124 cx_attr_nodiscard |
| |
125 static inline CxHashKey cx_hash_key_cxstr(cxstring str) { |
| |
126 return cx_hash_key(str.ptr, str.length); |
| |
127 } |
| |
128 |
| |
129 cx_attr_nodiscard |
| |
130 static inline CxHashKey cx_hash_key_cxstr(cxmutstr str) { |
| |
131 return cx_hash_key(str.ptr, str.length); |
| |
132 } |
| |
133 |
| |
134 #else |
| 121 /** |
135 /** |
| 122 * Computes a hash key from a UCX string. |
136 * Computes a hash key from a UCX string. |
| 123 * |
137 * |
| 124 * @param str the string |
138 * @param str the string |
| 125 * @return the hash key |
139 * @return the hash key |
| 126 */ |
140 */ |
| 127 #define cx_hash_key_cxstr(str) cx_hash_key((void*)(str).ptr, (str).length) |
141 #define cx_hash_key_cxstr(str) _Generic((str), \ |
| |
142 cxstring: cx_hash_key_cxstring, \ |
| |
143 cxmutstr: cx_hash_key_cxmutstr) \ |
| |
144 (str) |
| 128 |
145 |
| 129 #ifdef __cplusplus |
146 /** |
| 130 } // extern "C" |
147 * @copydoc cx_hash_key_cxstr() |
| |
148 */ |
| |
149 cx_attr_nodiscard |
| |
150 static inline CxHashKey cx_hash_key_cxstring(cxstring str) { |
| |
151 return cx_hash_key(str.ptr, str.length); |
| |
152 } |
| |
153 |
| |
154 /** |
| |
155 * @copydoc cx_hash_key_cxstr() |
| |
156 */ |
| |
157 cx_attr_nodiscard |
| |
158 static inline CxHashKey cx_hash_key_cxmutstr(cxmutstr str) { |
| |
159 return cx_hash_key(str.ptr, str.length); |
| |
160 } |
| 131 #endif |
161 #endif |
| 132 |
162 |
| 133 #endif // UCX_HASH_KEY_H |
163 #endif // UCX_HASH_KEY_H |