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