| 52 * |
48 * |
| 53 * For simple comparisons the cx_vcmp family of functions |
49 * For simple comparisons the cx_vcmp family of functions |
| 54 * can be used, but they are NOT compatible with this function |
50 * can be used, but they are NOT compatible with this function |
| 55 * pointer. |
51 * pointer. |
| 56 */ |
52 */ |
| 57 typedef int (*cx_compare_func)(const void *left, const void *right); |
53 CX_FPTR int (*cx_compare_func)(const void *left, const void *right); |
| 58 |
54 |
| 59 /** |
55 /** |
| 60 * A comparator function comparing two arbitrary values. |
56 * A comparator function comparing two arbitrary values. |
| 61 * |
57 * |
| 62 * Functions with this signature allow specifying a pointer to custom data. |
58 * Functions with this signature allow specifying a pointer to custom data. |
| 63 */ |
59 */ |
| 64 typedef int (*cx_compare_func2)(const void *left, const void *right, void *data); |
60 CX_FPTR int (*cx_compare_func2)(const void *left, const void *right, void *data); |
| 65 |
61 |
| 66 /** |
62 /** |
| 67 * Compares two integers of type int. |
63 * Compares two integers of type int. |
| 68 * |
64 * |
| 69 * @note the parameters deliberately have type @c void* to be |
65 * @note the parameters deliberately have type @c void* to be |
| 73 * @param i2 pointer to integer two |
69 * @param i2 pointer to integer two |
| 74 * @retval -1 if the left argument is less than the right argument |
70 * @retval -1 if the left argument is less than the right argument |
| 75 * @retval 0 if both arguments are equal |
71 * @retval 0 if both arguments are equal |
| 76 * @retval 1 if the left argument is greater than the right argument |
72 * @retval 1 if the left argument is greater than the right argument |
| 77 */ |
73 */ |
| 78 cx_attr_nonnull cx_attr_nodiscard |
74 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 79 CX_EXPORT int cx_cmp_int(const void *i1, const void *i2); |
75 int cx_cmp_int(const void *i1, const void *i2); |
| 80 |
76 |
| 81 /** |
77 /** |
| 82 * Compares two integers of type int. |
78 * Compares two integers of type int. |
| 83 * |
79 * |
| 84 * @param i1 integer one |
80 * @param i1 integer one |
| 85 * @param i2 integer two |
81 * @param i2 integer two |
| 86 * @retval -1 if the left argument is less than the right argument |
82 * @retval -1 if the left argument is less than the right argument |
| 87 * @retval 0 if both arguments are equal |
83 * @retval 0 if both arguments are equal |
| 88 * @retval 1 if the left argument is greater than the right argument |
84 * @retval 1 if the left argument is greater than the right argument |
| 89 */ |
85 */ |
| 90 cx_attr_nodiscard |
86 CX_EXTERN CX_NODISCARD |
| 91 CX_EXPORT int cx_vcmp_int(int i1, int i2); |
87 int cx_vcmp_int(int i1, int i2); |
| 92 |
88 |
| 93 /** |
89 /** |
| 94 * Compares two integers of type long int. |
90 * Compares two integers of type long int. |
| 95 * |
91 * |
| 96 * @note the parameters deliberately have type @c void* to be |
92 * @note the parameters deliberately have type @c void* to be |
| 100 * @param i2 pointer to long integer two |
96 * @param i2 pointer to long integer two |
| 101 * @retval -1 if the left argument is less than the right argument |
97 * @retval -1 if the left argument is less than the right argument |
| 102 * @retval 0 if both arguments are equal |
98 * @retval 0 if both arguments are equal |
| 103 * @retval 1 if the left argument is greater than the right argument |
99 * @retval 1 if the left argument is greater than the right argument |
| 104 */ |
100 */ |
| 105 cx_attr_nonnull cx_attr_nodiscard |
101 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 106 CX_EXPORT int cx_cmp_longint(const void *i1, const void *i2); |
102 int cx_cmp_longint(const void *i1, const void *i2); |
| 107 |
103 |
| 108 /** |
104 /** |
| 109 * Compares two integers of type long int. |
105 * Compares two integers of type long int. |
| 110 * |
106 * |
| 111 * @param i1 long integer one |
107 * @param i1 long integer one |
| 112 * @param i2 long integer two |
108 * @param i2 long integer two |
| 113 * @retval -1 if the left argument is less than the right argument |
109 * @retval -1 if the left argument is less than the right argument |
| 114 * @retval 0 if both arguments are equal |
110 * @retval 0 if both arguments are equal |
| 115 * @retval 1 if the left argument is greater than the right argument |
111 * @retval 1 if the left argument is greater than the right argument |
| 116 */ |
112 */ |
| 117 cx_attr_nodiscard |
113 CX_EXTERN CX_NODISCARD |
| 118 CX_EXPORT int cx_vcmp_longint(long int i1, long int i2); |
114 int cx_vcmp_longint(long int i1, long int i2); |
| 119 |
115 |
| 120 /** |
116 /** |
| 121 * Compares two integers of type long long. |
117 * Compares two integers of type long long. |
| 122 * |
118 * |
| 123 * @note the parameters deliberately have type @c void* to be |
119 * @note the parameters deliberately have type @c void* to be |
| 127 * @param i2 pointer to long long two |
123 * @param i2 pointer to long long two |
| 128 * @retval -1 if the left argument is less than the right argument |
124 * @retval -1 if the left argument is less than the right argument |
| 129 * @retval 0 if both arguments are equal |
125 * @retval 0 if both arguments are equal |
| 130 * @retval 1 if the left argument is greater than the right argument |
126 * @retval 1 if the left argument is greater than the right argument |
| 131 */ |
127 */ |
| 132 cx_attr_nonnull cx_attr_nodiscard |
128 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 133 CX_EXPORT int cx_cmp_longlong(const void *i1, const void *i2); |
129 int cx_cmp_longlong(const void *i1, const void *i2); |
| 134 |
130 |
| 135 /** |
131 /** |
| 136 * Compares two integers of type long long. |
132 * Compares two integers of type long long. |
| 137 * |
133 * |
| 138 * @param i1 long long int one |
134 * @param i1 long long int one |
| 139 * @param i2 long long int two |
135 * @param i2 long long int two |
| 140 * @retval -1 if the left argument is less than the right argument |
136 * @retval -1 if the left argument is less than the right argument |
| 141 * @retval 0 if both arguments are equal |
137 * @retval 0 if both arguments are equal |
| 142 * @retval 1 if the left argument is greater than the right argument |
138 * @retval 1 if the left argument is greater than the right argument |
| 143 */ |
139 */ |
| 144 cx_attr_nodiscard |
140 CX_EXTERN CX_NODISCARD |
| 145 CX_EXPORT int cx_vcmp_longlong(long long int i1, long long int i2); |
141 int cx_vcmp_longlong(long long int i1, long long int i2); |
| 146 |
142 |
| 147 /** |
143 /** |
| 148 * Compares two integers of type int16_t. |
144 * Compares two integers of type int16_t. |
| 149 * |
145 * |
| 150 * @note the parameters deliberately have type @c void* to be |
146 * @note the parameters deliberately have type @c void* to be |
| 154 * @param i2 pointer to int16_t two |
150 * @param i2 pointer to int16_t two |
| 155 * @retval -1 if the left argument is less than the right argument |
151 * @retval -1 if the left argument is less than the right argument |
| 156 * @retval 0 if both arguments are equal |
152 * @retval 0 if both arguments are equal |
| 157 * @retval 1 if the left argument is greater than the right argument |
153 * @retval 1 if the left argument is greater than the right argument |
| 158 */ |
154 */ |
| 159 cx_attr_nonnull cx_attr_nodiscard |
155 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 160 CX_EXPORT int cx_cmp_int16(const void *i1, const void *i2); |
156 int cx_cmp_int16(const void *i1, const void *i2); |
| 161 |
157 |
| 162 /** |
158 /** |
| 163 * Compares two integers of type int16_t. |
159 * Compares two integers of type int16_t. |
| 164 * |
160 * |
| 165 * @param i1 int16_t one |
161 * @param i1 int16_t one |
| 166 * @param i2 int16_t two |
162 * @param i2 int16_t two |
| 167 * @retval -1 if the left argument is less than the right argument |
163 * @retval -1 if the left argument is less than the right argument |
| 168 * @retval 0 if both arguments are equal |
164 * @retval 0 if both arguments are equal |
| 169 * @retval 1 if the left argument is greater than the right argument |
165 * @retval 1 if the left argument is greater than the right argument |
| 170 */ |
166 */ |
| 171 cx_attr_nodiscard |
167 CX_EXTERN CX_NODISCARD |
| 172 CX_EXPORT int cx_vcmp_int16(int16_t i1, int16_t i2); |
168 int cx_vcmp_int16(int16_t i1, int16_t i2); |
| 173 |
169 |
| 174 /** |
170 /** |
| 175 * Compares two integers of type int32_t. |
171 * Compares two integers of type int32_t. |
| 176 * |
172 * |
| 177 * @note the parameters deliberately have type @c void* to be |
173 * @note the parameters deliberately have type @c void* to be |
| 181 * @param i2 pointer to int32_t two |
177 * @param i2 pointer to int32_t two |
| 182 * @retval -1 if the left argument is less than the right argument |
178 * @retval -1 if the left argument is less than the right argument |
| 183 * @retval 0 if both arguments are equal |
179 * @retval 0 if both arguments are equal |
| 184 * @retval 1 if the left argument is greater than the right argument |
180 * @retval 1 if the left argument is greater than the right argument |
| 185 */ |
181 */ |
| 186 cx_attr_nonnull cx_attr_nodiscard |
182 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 187 CX_EXPORT int cx_cmp_int32(const void *i1, const void *i2); |
183 int cx_cmp_int32(const void *i1, const void *i2); |
| 188 |
184 |
| 189 /** |
185 /** |
| 190 * Compares two integers of type int32_t. |
186 * Compares two integers of type int32_t. |
| 191 * |
187 * |
| 192 * @param i1 int32_t one |
188 * @param i1 int32_t one |
| 193 * @param i2 int32_t two |
189 * @param i2 int32_t two |
| 194 * @retval -1 if the left argument is less than the right argument |
190 * @retval -1 if the left argument is less than the right argument |
| 195 * @retval 0 if both arguments are equal |
191 * @retval 0 if both arguments are equal |
| 196 * @retval 1 if the left argument is greater than the right argument |
192 * @retval 1 if the left argument is greater than the right argument |
| 197 */ |
193 */ |
| 198 cx_attr_nodiscard |
194 CX_EXTERN CX_NODISCARD |
| 199 CX_EXPORT int cx_vcmp_int32(int32_t i1, int32_t i2); |
195 int cx_vcmp_int32(int32_t i1, int32_t i2); |
| 200 |
196 |
| 201 /** |
197 /** |
| 202 * Compares two integers of type int64_t. |
198 * Compares two integers of type int64_t. |
| 203 * |
199 * |
| 204 * @note the parameters deliberately have type @c void* to be |
200 * @note the parameters deliberately have type @c void* to be |
| 208 * @param i2 pointer to int64_t two |
204 * @param i2 pointer to int64_t two |
| 209 * @retval -1 if the left argument is less than the right argument |
205 * @retval -1 if the left argument is less than the right argument |
| 210 * @retval 0 if both arguments are equal |
206 * @retval 0 if both arguments are equal |
| 211 * @retval 1 if the left argument is greater than the right argument |
207 * @retval 1 if the left argument is greater than the right argument |
| 212 */ |
208 */ |
| 213 cx_attr_nonnull cx_attr_nodiscard |
209 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 214 CX_EXPORT int cx_cmp_int64(const void *i1, const void *i2); |
210 int cx_cmp_int64(const void *i1, const void *i2); |
| 215 |
211 |
| 216 /** |
212 /** |
| 217 * Compares two integers of type int64_t. |
213 * Compares two integers of type int64_t. |
| 218 * |
214 * |
| 219 * @param i1 int64_t one |
215 * @param i1 int64_t one |
| 220 * @param i2 int64_t two |
216 * @param i2 int64_t two |
| 221 * @retval -1 if the left argument is less than the right argument |
217 * @retval -1 if the left argument is less than the right argument |
| 222 * @retval 0 if both arguments are equal |
218 * @retval 0 if both arguments are equal |
| 223 * @retval 1 if the left argument is greater than the right argument |
219 * @retval 1 if the left argument is greater than the right argument |
| 224 */ |
220 */ |
| 225 cx_attr_nodiscard |
221 CX_EXTERN CX_NODISCARD |
| 226 CX_EXPORT int cx_vcmp_int64(int64_t i1, int64_t i2); |
222 int cx_vcmp_int64(int64_t i1, int64_t i2); |
| 227 |
223 |
| 228 /** |
224 /** |
| 229 * Compares two integers of type unsigned int. |
225 * Compares two integers of type unsigned int. |
| 230 * |
226 * |
| 231 * @note the parameters deliberately have type @c void* to be |
227 * @note the parameters deliberately have type @c void* to be |
| 235 * @param i2 pointer to unsigned integer two |
231 * @param i2 pointer to unsigned integer two |
| 236 * @retval -1 if the left argument is less than the right argument |
232 * @retval -1 if the left argument is less than the right argument |
| 237 * @retval 0 if both arguments are equal |
233 * @retval 0 if both arguments are equal |
| 238 * @retval 1 if the left argument is greater than the right argument |
234 * @retval 1 if the left argument is greater than the right argument |
| 239 */ |
235 */ |
| 240 cx_attr_nonnull cx_attr_nodiscard |
236 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 241 CX_EXPORT int cx_cmp_uint(const void *i1, const void *i2); |
237 int cx_cmp_uint(const void *i1, const void *i2); |
| 242 |
238 |
| 243 /** |
239 /** |
| 244 * Compares two integers of type unsigned int. |
240 * Compares two integers of type unsigned int. |
| 245 * |
241 * |
| 246 * @param i1 unsigned integer one |
242 * @param i1 unsigned integer one |
| 247 * @param i2 unsigned integer two |
243 * @param i2 unsigned integer two |
| 248 * @retval -1 if the left argument is less than the right argument |
244 * @retval -1 if the left argument is less than the right argument |
| 249 * @retval 0 if both arguments are equal |
245 * @retval 0 if both arguments are equal |
| 250 * @retval 1 if the left argument is greater than the right argument |
246 * @retval 1 if the left argument is greater than the right argument |
| 251 */ |
247 */ |
| 252 cx_attr_nodiscard |
248 CX_EXTERN CX_NODISCARD |
| 253 CX_EXPORT int cx_vcmp_uint(unsigned int i1, unsigned int i2); |
249 int cx_vcmp_uint(unsigned int i1, unsigned int i2); |
| 254 |
250 |
| 255 /** |
251 /** |
| 256 * Compares two integers of type unsigned long int. |
252 * Compares two integers of type unsigned long int. |
| 257 * |
253 * |
| 258 * @note the parameters deliberately have type @c void* to be |
254 * @note the parameters deliberately have type @c void* to be |
| 262 * @param i2 pointer to unsigned long integer two |
258 * @param i2 pointer to unsigned long integer two |
| 263 * @retval -1 if the left argument is less than the right argument |
259 * @retval -1 if the left argument is less than the right argument |
| 264 * @retval 0 if both arguments are equal |
260 * @retval 0 if both arguments are equal |
| 265 * @retval 1 if the left argument is greater than the right argument |
261 * @retval 1 if the left argument is greater than the right argument |
| 266 */ |
262 */ |
| 267 cx_attr_nonnull cx_attr_nodiscard |
263 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 268 CX_EXPORT int cx_cmp_ulongint(const void *i1, const void *i2); |
264 int cx_cmp_ulongint(const void *i1, const void *i2); |
| 269 |
265 |
| 270 /** |
266 /** |
| 271 * Compares two integers of type unsigned long int. |
267 * Compares two integers of type unsigned long int. |
| 272 * |
268 * |
| 273 * @param i1 unsigned long integer one |
269 * @param i1 unsigned long integer one |
| 274 * @param i2 unsigned long integer two |
270 * @param i2 unsigned long integer two |
| 275 * @retval -1 if the left argument is less than the right argument |
271 * @retval -1 if the left argument is less than the right argument |
| 276 * @retval 0 if both arguments are equal |
272 * @retval 0 if both arguments are equal |
| 277 * @retval 1 if the left argument is greater than the right argument |
273 * @retval 1 if the left argument is greater than the right argument |
| 278 */ |
274 */ |
| 279 cx_attr_nodiscard |
275 CX_EXTERN CX_NODISCARD |
| 280 CX_EXPORT int cx_vcmp_ulongint(unsigned long int i1, unsigned long int i2); |
276 int cx_vcmp_ulongint(unsigned long int i1, unsigned long int i2); |
| 281 |
277 |
| 282 /** |
278 /** |
| 283 * Compares two integers of type unsigned long long. |
279 * Compares two integers of type unsigned long long. |
| 284 * |
280 * |
| 285 * @note the parameters deliberately have type @c void* to be |
281 * @note the parameters deliberately have type @c void* to be |
| 289 * @param i2 pointer to unsigned long long two |
285 * @param i2 pointer to unsigned long long two |
| 290 * @retval -1 if the left argument is less than the right argument |
286 * @retval -1 if the left argument is less than the right argument |
| 291 * @retval 0 if both arguments are equal |
287 * @retval 0 if both arguments are equal |
| 292 * @retval 1 if the left argument is greater than the right argument |
288 * @retval 1 if the left argument is greater than the right argument |
| 293 */ |
289 */ |
| 294 cx_attr_nonnull cx_attr_nodiscard |
290 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 295 CX_EXPORT int cx_cmp_ulonglong(const void *i1, const void *i2); |
291 int cx_cmp_ulonglong(const void *i1, const void *i2); |
| 296 |
292 |
| 297 /** |
293 /** |
| 298 * Compares two integers of type unsigned long long. |
294 * Compares two integers of type unsigned long long. |
| 299 * |
295 * |
| 300 * @param i1 unsigned long long one |
296 * @param i1 unsigned long long one |
| 301 * @param i2 unsigned long long two |
297 * @param i2 unsigned long long two |
| 302 * @retval -1 if the left argument is less than the right argument |
298 * @retval -1 if the left argument is less than the right argument |
| 303 * @retval 0 if both arguments are equal |
299 * @retval 0 if both arguments are equal |
| 304 * @retval 1 if the left argument is greater than the right argument |
300 * @retval 1 if the left argument is greater than the right argument |
| 305 */ |
301 */ |
| 306 cx_attr_nodiscard |
302 CX_EXTERN CX_NODISCARD |
| 307 CX_EXPORT int cx_vcmp_ulonglong(unsigned long long int i1, unsigned long long int i2); |
303 int cx_vcmp_ulonglong(unsigned long long int i1, unsigned long long int i2); |
| 308 |
304 |
| 309 /** |
305 /** |
| 310 * Compares two integers of type uint16_t. |
306 * Compares two integers of type uint16_t. |
| 311 * |
307 * |
| 312 * @note the parameters deliberately have type @c void* to be |
308 * @note the parameters deliberately have type @c void* to be |
| 316 * @param i2 pointer to uint16_t two |
312 * @param i2 pointer to uint16_t two |
| 317 * @retval -1 if the left argument is less than the right argument |
313 * @retval -1 if the left argument is less than the right argument |
| 318 * @retval 0 if both arguments are equal |
314 * @retval 0 if both arguments are equal |
| 319 * @retval 1 if the left argument is greater than the right argument |
315 * @retval 1 if the left argument is greater than the right argument |
| 320 */ |
316 */ |
| 321 cx_attr_nonnull cx_attr_nodiscard |
317 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 322 CX_EXPORT int cx_cmp_uint16(const void *i1, const void *i2); |
318 int cx_cmp_uint16(const void *i1, const void *i2); |
| 323 |
319 |
| 324 /** |
320 /** |
| 325 * Compares two integers of type uint16_t. |
321 * Compares two integers of type uint16_t. |
| 326 * |
322 * |
| 327 * @param i1 uint16_t one |
323 * @param i1 uint16_t one |
| 328 * @param i2 uint16_t two |
324 * @param i2 uint16_t two |
| 329 * @retval -1 if the left argument is less than the right argument |
325 * @retval -1 if the left argument is less than the right argument |
| 330 * @retval 0 if both arguments are equal |
326 * @retval 0 if both arguments are equal |
| 331 * @retval 1 if the left argument is greater than the right argument |
327 * @retval 1 if the left argument is greater than the right argument |
| 332 */ |
328 */ |
| 333 cx_attr_nodiscard |
329 CX_EXTERN CX_NODISCARD |
| 334 CX_EXPORT int cx_vcmp_uint16(uint16_t i1, uint16_t i2); |
330 int cx_vcmp_uint16(uint16_t i1, uint16_t i2); |
| 335 |
331 |
| 336 /** |
332 /** |
| 337 * Compares two integers of type uint32_t. |
333 * Compares two integers of type uint32_t. |
| 338 * |
334 * |
| 339 * @note the parameters deliberately have type @c void* to be |
335 * @note the parameters deliberately have type @c void* to be |
| 343 * @param i2 pointer to uint32_t two |
339 * @param i2 pointer to uint32_t two |
| 344 * @retval -1 if the left argument is less than the right argument |
340 * @retval -1 if the left argument is less than the right argument |
| 345 * @retval 0 if both arguments are equal |
341 * @retval 0 if both arguments are equal |
| 346 * @retval 1 if the left argument is greater than the right argument |
342 * @retval 1 if the left argument is greater than the right argument |
| 347 */ |
343 */ |
| 348 cx_attr_nonnull cx_attr_nodiscard |
344 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 349 CX_EXPORT int cx_cmp_uint32(const void *i1, const void *i2); |
345 int cx_cmp_uint32(const void *i1, const void *i2); |
| 350 |
346 |
| 351 /** |
347 /** |
| 352 * Compares two integers of type uint32_t. |
348 * Compares two integers of type uint32_t. |
| 353 * |
349 * |
| 354 * @param i1 uint32_t one |
350 * @param i1 uint32_t one |
| 355 * @param i2 uint32_t two |
351 * @param i2 uint32_t two |
| 356 * @retval -1 if the left argument is less than the right argument |
352 * @retval -1 if the left argument is less than the right argument |
| 357 * @retval 0 if both arguments are equal |
353 * @retval 0 if both arguments are equal |
| 358 * @retval 1 if the left argument is greater than the right argument |
354 * @retval 1 if the left argument is greater than the right argument |
| 359 */ |
355 */ |
| 360 cx_attr_nodiscard |
356 CX_EXTERN CX_NODISCARD |
| 361 CX_EXPORT int cx_vcmp_uint32(uint32_t i1, uint32_t i2); |
357 int cx_vcmp_uint32(uint32_t i1, uint32_t i2); |
| 362 |
358 |
| 363 /** |
359 /** |
| 364 * Compares two integers of type uint64_t. |
360 * Compares two integers of type uint64_t. |
| 365 * |
361 * |
| 366 * @note the parameters deliberately have type @c void* to be |
362 * @note the parameters deliberately have type @c void* to be |
| 370 * @param i2 pointer to uint64_t two |
366 * @param i2 pointer to uint64_t two |
| 371 * @retval -1 if the left argument is less than the right argument |
367 * @retval -1 if the left argument is less than the right argument |
| 372 * @retval 0 if both arguments are equal |
368 * @retval 0 if both arguments are equal |
| 373 * @retval 1 if the left argument is greater than the right argument |
369 * @retval 1 if the left argument is greater than the right argument |
| 374 */ |
370 */ |
| 375 cx_attr_nonnull cx_attr_nodiscard |
371 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 376 CX_EXPORT int cx_cmp_uint64(const void *i1, const void *i2); |
372 int cx_cmp_uint64(const void *i1, const void *i2); |
| 377 |
373 |
| 378 /** |
374 /** |
| 379 * Compares two integers of type uint64_t. |
375 * Compares two integers of type uint64_t. |
| 380 * |
376 * |
| 381 * @param i1 uint64_t one |
377 * @param i1 uint64_t one |
| 382 * @param i2 uint64_t two |
378 * @param i2 uint64_t two |
| 383 * @retval -1 if the left argument is less than the right argument |
379 * @retval -1 if the left argument is less than the right argument |
| 384 * @retval 0 if both arguments are equal |
380 * @retval 0 if both arguments are equal |
| 385 * @retval 1 if the left argument is greater than the right argument |
381 * @retval 1 if the left argument is greater than the right argument |
| 386 */ |
382 */ |
| 387 cx_attr_nodiscard |
383 CX_EXTERN CX_NODISCARD |
| 388 CX_EXPORT int cx_vcmp_uint64(uint64_t i1, uint64_t i2); |
384 int cx_vcmp_uint64(uint64_t i1, uint64_t i2); |
| 389 |
385 |
| 390 /** |
386 /** |
| 391 * Compares two integers of type size_t. |
387 * Compares two integers of type size_t. |
| 392 * |
388 * |
| 393 * @note the parameters deliberately have type @c void* to be |
389 * @note the parameters deliberately have type @c void* to be |
| 397 * @param i2 pointer to size_t two |
393 * @param i2 pointer to size_t two |
| 398 * @retval -1 if the left argument is less than the right argument |
394 * @retval -1 if the left argument is less than the right argument |
| 399 * @retval 0 if both arguments are equal |
395 * @retval 0 if both arguments are equal |
| 400 * @retval 1 if the left argument is greater than the right argument |
396 * @retval 1 if the left argument is greater than the right argument |
| 401 */ |
397 */ |
| 402 cx_attr_nonnull cx_attr_nodiscard |
398 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 403 CX_EXPORT int cx_cmp_size(const void *i1, const void *i2); |
399 int cx_cmp_size(const void *i1, const void *i2); |
| 404 |
400 |
| 405 /** |
401 /** |
| 406 * Compares two integers of type size_t. |
402 * Compares two integers of type size_t. |
| 407 * |
403 * |
| 408 * @param i1 size_t one |
404 * @param i1 size_t one |
| 409 * @param i2 size_t two |
405 * @param i2 size_t two |
| 410 * @retval -1 if the left argument is less than the right argument |
406 * @retval -1 if the left argument is less than the right argument |
| 411 * @retval 0 if both arguments are equal |
407 * @retval 0 if both arguments are equal |
| 412 * @retval 1 if the left argument is greater than the right argument |
408 * @retval 1 if the left argument is greater than the right argument |
| 413 */ |
409 */ |
| 414 cx_attr_nodiscard |
410 CX_EXTERN CX_NODISCARD |
| 415 CX_EXPORT int cx_vcmp_size(size_t i1, size_t i2); |
411 int cx_vcmp_size(size_t i1, size_t i2); |
| 416 |
412 |
| 417 /** |
413 /** |
| 418 * Compares two real numbers of type float with precision 1e-6f. |
414 * Compares two real numbers of type float with precision 1e-6f. |
| 419 * |
415 * |
| 420 * @note the parameters deliberately have type @c void* to be |
416 * @note the parameters deliberately have type @c void* to be |
| 424 * @param f2 pointer to float two |
420 * @param f2 pointer to float two |
| 425 * @retval -1 if the left argument is less than the right argument |
421 * @retval -1 if the left argument is less than the right argument |
| 426 * @retval 0 if both arguments are equal |
422 * @retval 0 if both arguments are equal |
| 427 * @retval 1 if the left argument is greater than the right argument |
423 * @retval 1 if the left argument is greater than the right argument |
| 428 */ |
424 */ |
| 429 cx_attr_nonnull cx_attr_nodiscard |
425 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 430 CX_EXPORT int cx_cmp_float(const void *f1, const void *f2); |
426 int cx_cmp_float(const void *f1, const void *f2); |
| 431 |
427 |
| 432 /** |
428 /** |
| 433 * Compares two real numbers of type float with precision 1e-6f. |
429 * Compares two real numbers of type float with precision 1e-6f. |
| 434 * |
430 * |
| 435 * @param f1 float one |
431 * @param f1 float one |
| 436 * @param f2 float two |
432 * @param f2 float two |
| 437 * @retval -1 if the left argument is less than the right argument |
433 * @retval -1 if the left argument is less than the right argument |
| 438 * @retval 0 if both arguments are equal |
434 * @retval 0 if both arguments are equal |
| 439 * @retval 1 if the left argument is greater than the right argument |
435 * @retval 1 if the left argument is greater than the right argument |
| 440 */ |
436 */ |
| 441 cx_attr_nodiscard |
437 CX_EXTERN CX_NODISCARD |
| 442 CX_EXPORT int cx_vcmp_float(float f1, float f2); |
438 int cx_vcmp_float(float f1, float f2); |
| 443 |
439 |
| 444 /** |
440 /** |
| 445 * Compares two real numbers of type double with precision 1e-14. |
441 * Compares two real numbers of type double with precision 1e-14. |
| 446 * |
442 * |
| 447 * @note the parameters deliberately have type @c void* to be |
443 * @note the parameters deliberately have type @c void* to be |
| 451 * @param d2 pointer to double two |
447 * @param d2 pointer to double two |
| 452 * @retval -1 if the left argument is less than the right argument |
448 * @retval -1 if the left argument is less than the right argument |
| 453 * @retval 0 if both arguments are equal |
449 * @retval 0 if both arguments are equal |
| 454 * @retval 1 if the left argument is greater than the right argument |
450 * @retval 1 if the left argument is greater than the right argument |
| 455 */ |
451 */ |
| 456 cx_attr_nonnull cx_attr_nodiscard |
452 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 457 CX_EXPORT int cx_cmp_double(const void *d1, const void *d2); |
453 int cx_cmp_double(const void *d1, const void *d2); |
| 458 |
454 |
| 459 /** |
455 /** |
| 460 * Compares two real numbers of type double with precision 1e-14. |
456 * Compares two real numbers of type double with precision 1e-14. |
| 461 * |
457 * |
| 462 * @param d1 double one |
458 * @param d1 double one |
| 463 * @param d2 double two |
459 * @param d2 double two |
| 464 * @retval -1 if the left argument is less than the right argument |
460 * @retval -1 if the left argument is less than the right argument |
| 465 * @retval 0 if both arguments are equal |
461 * @retval 0 if both arguments are equal |
| 466 * @retval 1 if the left argument is greater than the right argument |
462 * @retval 1 if the left argument is greater than the right argument |
| 467 */ |
463 */ |
| 468 cx_attr_nodiscard |
464 CX_EXTERN CX_NODISCARD |
| 469 CX_EXPORT int cx_vcmp_double(double d1, double d2); |
465 int cx_vcmp_double(double d1, double d2); |
| 470 |
466 |
| 471 /** |
467 /** |
| 472 * Compares the integer representation of two pointers. |
468 * Compares the integer representation of two pointers. |
| 473 * |
469 * |
| 474 * @note the parameters deliberately have type @c void* to be |
470 * @note the parameters deliberately have type @c void* to be |
| 478 * @param ptr2 pointer to pointer two (const intptr_t*) |
474 * @param ptr2 pointer to pointer two (const intptr_t*) |
| 479 * @retval -1 if the left argument is less than the right argument |
475 * @retval -1 if the left argument is less than the right argument |
| 480 * @retval 0 if both arguments are equal |
476 * @retval 0 if both arguments are equal |
| 481 * @retval 1 if the left argument is greater than the right argument |
477 * @retval 1 if the left argument is greater than the right argument |
| 482 */ |
478 */ |
| 483 cx_attr_nonnull cx_attr_nodiscard |
479 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 484 CX_EXPORT int cx_cmp_intptr(const void *ptr1, const void *ptr2); |
480 int cx_cmp_intptr(const void *ptr1, const void *ptr2); |
| 485 |
481 |
| 486 /** |
482 /** |
| 487 * Compares the integer representation of two pointers. |
483 * Compares the integer representation of two pointers. |
| 488 * |
484 * |
| 489 * @param ptr1 pointer one |
485 * @param ptr1 pointer one |
| 490 * @param ptr2 pointer two |
486 * @param ptr2 pointer two |
| 491 * @retval -1 if the left argument is less than the right argument |
487 * @retval -1 if the left argument is less than the right argument |
| 492 * @retval 0 if both arguments are equal |
488 * @retval 0 if both arguments are equal |
| 493 * @retval 1 if the left argument is greater than the right argument |
489 * @retval 1 if the left argument is greater than the right argument |
| 494 */ |
490 */ |
| 495 cx_attr_nodiscard |
491 CX_EXTERN CX_NODISCARD |
| 496 CX_EXPORT int cx_vcmp_intptr(intptr_t ptr1, intptr_t ptr2); |
492 int cx_vcmp_intptr(intptr_t ptr1, intptr_t ptr2); |
| 497 |
493 |
| 498 /** |
494 /** |
| 499 * Compares the unsigned integer representation of two pointers. |
495 * Compares the unsigned integer representation of two pointers. |
| 500 * |
496 * |
| 501 * @note the parameters deliberately have type @c void* to be |
497 * @note the parameters deliberately have type @c void* to be |
| 505 * @param ptr2 pointer to pointer two (const uintptr_t*) |
501 * @param ptr2 pointer to pointer two (const uintptr_t*) |
| 506 * @retval -1 if the left argument is less than the right argument |
502 * @retval -1 if the left argument is less than the right argument |
| 507 * @retval 0 if both arguments are equal |
503 * @retval 0 if both arguments are equal |
| 508 * @retval 1 if the left argument is greater than the right argument |
504 * @retval 1 if the left argument is greater than the right argument |
| 509 */ |
505 */ |
| 510 cx_attr_nonnull cx_attr_nodiscard |
506 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 511 CX_EXPORT int cx_cmp_uintptr(const void *ptr1, const void *ptr2); |
507 int cx_cmp_uintptr(const void *ptr1, const void *ptr2); |
| 512 |
508 |
| 513 /** |
509 /** |
| 514 * Compares the unsigned integer representation of two pointers. |
510 * Compares the unsigned integer representation of two pointers. |
| 515 * |
511 * |
| 516 * @param ptr1 pointer one |
512 * @param ptr1 pointer one |
| 517 * @param ptr2 pointer two |
513 * @param ptr2 pointer two |
| 518 * @retval -1 if the left argument is less than the right argument |
514 * @retval -1 if the left argument is less than the right argument |
| 519 * @retval 0 if both arguments are equal |
515 * @retval 0 if both arguments are equal |
| 520 * @retval 1 if the left argument is greater than the right argument |
516 * @retval 1 if the left argument is greater than the right argument |
| 521 */ |
517 */ |
| 522 cx_attr_nodiscard |
518 CX_EXTERN CX_NODISCARD |
| 523 CX_EXPORT int cx_vcmp_uintptr(uintptr_t ptr1, uintptr_t ptr2); |
519 int cx_vcmp_uintptr(uintptr_t ptr1, uintptr_t ptr2); |
| 524 |
520 |
| 525 /** |
521 /** |
| 526 * Compares the pointers specified in the arguments without dereferencing. |
522 * Compares the pointers specified in the arguments without dereferencing. |
| 527 * |
523 * |
| 528 * @param ptr1 pointer one |
524 * @param ptr1 pointer one |
| 529 * @param ptr2 pointer two |
525 * @param ptr2 pointer two |
| 530 * @retval -1 if the left argument is less than the right argument |
526 * @retval -1 if the left argument is less than the right argument |
| 531 * @retval 0 if both arguments are equal |
527 * @retval 0 if both arguments are equal |
| 532 * @retval 1 if the left argument is greater than the right argument |
528 * @retval 1 if the left argument is greater than the right argument |
| 533 */ |
529 */ |
| 534 cx_attr_nonnull cx_attr_nodiscard |
530 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 535 CX_EXPORT int cx_cmp_ptr(const void *ptr1, const void *ptr2); |
531 int cx_cmp_ptr(const void *ptr1, const void *ptr2); |
| 536 |
532 |
| 537 /** Wraps a compare function for cx_cmp_wrap. */ |
533 /** Wraps a compare function for cx_cmp_wrap. */ |
| 538 typedef struct { |
534 typedef struct { |
| 539 /** The wrapped compare function */ |
535 /** The wrapped compare function */ |
| 540 cx_compare_func cmp; |
536 cx_compare_func cmp; |
| 547 * @param ptr2 pointer two |
543 * @param ptr2 pointer two |
| 548 * @param cmp_wrapper a pointer to a @c cx_compare_func_wrapper |
544 * @param cmp_wrapper a pointer to a @c cx_compare_func_wrapper |
| 549 * @return the result of the invoked compare function |
545 * @return the result of the invoked compare function |
| 550 * @see cx_compare_func_wrapper |
546 * @see cx_compare_func_wrapper |
| 551 */ |
547 */ |
| 552 cx_attr_nonnull cx_attr_nodiscard |
548 CX_EXTERN CX_NONNULL CX_NODISCARD |
| 553 CX_EXPORT int cx_cmp_wrap(const void *ptr1, const void *ptr2, void* cmp_wrapper); |
549 int cx_cmp_wrap(const void *ptr1, const void *ptr2, void* cmp_wrapper); |
| 554 |
|
| 555 #ifdef __cplusplus |
|
| 556 } // extern "C" |
|
| 557 #endif |
|
| 558 |
550 |
| 559 #endif //UCX_COMPARE_H |
551 #endif //UCX_COMPARE_H |