Tue, 03 Feb 2026 19:09:53 +0100
use bool instead of WSBool in strreplace
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | /** |
| 579 | 29 | * @file compare.h |
| 30 | * @brief A collection of simple compare functions. | |
| 31 | * @author Mike Becker | |
| 32 | * @author Olaf Wintermann | |
| 33 | * @copyright 2-Clause BSD License | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | */ |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #ifndef UCX_COMPARE_H |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | #define UCX_COMPARE_H |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | |
| 490 | 39 | #include "common.h" |
| 40 | ||
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | /** |
| 579 | 42 | * A comparator function comparing two arbitrary values. |
| 43 | * | |
| 44 | * All functions from compare.h with the cx_cmp prefix are | |
| 45 | * compatible with this signature and can be used as | |
| 621 | 46 | * compare function for collections or other implementations |
| 579 | 47 | * that need to be type-agnostic. |
| 48 | * | |
| 49 | * For simple comparisons the cx_vcmp family of functions | |
| 50 | * can be used, but they are NOT compatible with this function | |
| 51 | * pointer. | |
| 52 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
53 | CX_FPTR int (*cx_compare_func)(const void *left, const void *right); |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
54 | |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
55 | /** |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
56 | * A comparator function comparing two arbitrary values. |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
57 | * |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
58 | * Functions with this signature allow specifying a pointer to custom data. |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
59 | */ |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
60 | CX_FPTR int (*cx_compare_func2)(const void *left, const void *right, void *data); |
| 579 | 61 | |
| 62 | /** | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | * Compares two integers of type int. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | * |
| 579 | 65 | * @note the parameters deliberately have type @c void* to be |
| 66 | * compatible with #cx_compare_func without the need of a cast. | |
| 67 | * | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | * @param i1 pointer to integer one |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | * @param i2 pointer to integer two |
| 579 | 70 | * @retval -1 if the left argument is less than the right argument |
| 71 | * @retval 0 if both arguments are equal | |
| 72 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
74 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
75 | int cx_cmp_int(const void *i1, const void *i2); |
| 579 | 76 | |
| 77 | /** | |
| 78 | * Compares two integers of type int. | |
| 79 | * | |
| 80 | * @param i1 integer one | |
| 81 | * @param i2 integer two | |
| 82 | * @retval -1 if the left argument is less than the right argument | |
| 83 | * @retval 0 if both arguments are equal | |
| 84 | * @retval 1 if the left argument is greater than the right argument | |
| 85 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
86 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
87 | int cx_vcmp_int(int i1, int i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | * Compares two integers of type long int. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | * |
| 579 | 92 | * @note the parameters deliberately have type @c void* to be |
| 93 | * compatible with #cx_compare_func without the need of a cast. | |
| 94 | * | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | * @param i1 pointer to long integer one |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | * @param i2 pointer to long integer two |
| 579 | 97 | * @retval -1 if the left argument is less than the right argument |
| 98 | * @retval 0 if both arguments are equal | |
| 99 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
101 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
102 | int cx_cmp_longint(const void *i1, const void *i2); |
| 579 | 103 | |
| 104 | /** | |
| 105 | * Compares two integers of type long int. | |
| 106 | * | |
| 107 | * @param i1 long integer one | |
| 108 | * @param i2 long integer two | |
| 109 | * @retval -1 if the left argument is less than the right argument | |
| 110 | * @retval 0 if both arguments are equal | |
| 111 | * @retval 1 if the left argument is greater than the right argument | |
| 112 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
113 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
114 | int cx_vcmp_longint(long int i1, long int i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | * Compares two integers of type long long. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | * |
| 579 | 119 | * @note the parameters deliberately have type @c void* to be |
| 120 | * compatible with #cx_compare_func without the need of a cast. | |
| 121 | * | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | * @param i1 pointer to long long one |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | * @param i2 pointer to long long two |
| 579 | 124 | * @retval -1 if the left argument is less than the right argument |
| 125 | * @retval 0 if both arguments are equal | |
| 126 | * @retval 1 if the left argument is greater than the right argument | |
| 127 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
128 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
129 | int cx_cmp_longlong(const void *i1, const void *i2); |
| 579 | 130 | |
| 131 | /** | |
| 132 | * Compares two integers of type long long. | |
| 133 | * | |
| 134 | * @param i1 long long int one | |
| 135 | * @param i2 long long int two | |
| 136 | * @retval -1 if the left argument is less than the right argument | |
| 137 | * @retval 0 if both arguments are equal | |
| 138 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
140 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
141 | int cx_vcmp_longlong(long long int i1, long long int i2); |
| 579 | 142 | |
| 143 | /** | |
| 144 | * Compares two integers of type int16_t. | |
| 145 | * | |
| 146 | * @note the parameters deliberately have type @c void* to be | |
| 147 | * compatible with #cx_compare_func without the need of a cast. | |
| 148 | * | |
| 149 | * @param i1 pointer to int16_t one | |
| 150 | * @param i2 pointer to int16_t two | |
| 151 | * @retval -1 if the left argument is less than the right argument | |
| 152 | * @retval 0 if both arguments are equal | |
| 153 | * @retval 1 if the left argument is greater than the right argument | |
| 154 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
155 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
156 | int cx_cmp_int16(const void *i1, const void *i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
157 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | * Compares two integers of type int16_t. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | * |
| 579 | 161 | * @param i1 int16_t one |
| 162 | * @param i2 int16_t two | |
| 163 | * @retval -1 if the left argument is less than the right argument | |
| 164 | * @retval 0 if both arguments are equal | |
| 165 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
167 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
168 | int cx_vcmp_int16(int16_t i1, int16_t i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | * Compares two integers of type int32_t. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | * |
| 579 | 173 | * @note the parameters deliberately have type @c void* to be |
| 174 | * compatible with #cx_compare_func without the need of a cast. | |
| 175 | * | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | * @param i1 pointer to int32_t one |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | * @param i2 pointer to int32_t two |
| 579 | 178 | * @retval -1 if the left argument is less than the right argument |
| 179 | * @retval 0 if both arguments are equal | |
| 180 | * @retval 1 if the left argument is greater than the right argument | |
| 181 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
182 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
183 | int cx_cmp_int32(const void *i1, const void *i2); |
| 579 | 184 | |
| 185 | /** | |
| 186 | * Compares two integers of type int32_t. | |
| 187 | * | |
| 188 | * @param i1 int32_t one | |
| 189 | * @param i2 int32_t two | |
| 190 | * @retval -1 if the left argument is less than the right argument | |
| 191 | * @retval 0 if both arguments are equal | |
| 192 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
194 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
195 | int cx_vcmp_int32(int32_t i1, int32_t i2); |
| 579 | 196 | |
| 197 | /** | |
| 198 | * Compares two integers of type int64_t. | |
| 199 | * | |
| 200 | * @note the parameters deliberately have type @c void* to be | |
| 201 | * compatible with #cx_compare_func without the need of a cast. | |
| 202 | * | |
| 203 | * @param i1 pointer to int64_t one | |
| 204 | * @param i2 pointer to int64_t two | |
| 205 | * @retval -1 if the left argument is less than the right argument | |
| 206 | * @retval 0 if both arguments are equal | |
| 207 | * @retval 1 if the left argument is greater than the right argument | |
| 208 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
209 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
210 | int cx_cmp_int64(const void *i1, const void *i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
212 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | * Compares two integers of type int64_t. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | * |
| 579 | 215 | * @param i1 int64_t one |
| 216 | * @param i2 int64_t two | |
| 217 | * @retval -1 if the left argument is less than the right argument | |
| 218 | * @retval 0 if both arguments are equal | |
| 219 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
220 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
221 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
222 | int cx_vcmp_int64(int64_t i1, int64_t i2); |
| 579 | 223 | |
| 224 | /** | |
| 225 | * Compares two integers of type unsigned int. | |
| 226 | * | |
| 227 | * @note the parameters deliberately have type @c void* to be | |
| 228 | * compatible with #cx_compare_func without the need of a cast. | |
| 229 | * | |
| 230 | * @param i1 pointer to unsigned integer one | |
| 231 | * @param i2 pointer to unsigned integer two | |
| 232 | * @retval -1 if the left argument is less than the right argument | |
| 233 | * @retval 0 if both arguments are equal | |
| 234 | * @retval 1 if the left argument is greater than the right argument | |
| 235 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
236 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
237 | int cx_cmp_uint(const void *i1, const void *i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
238 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
239 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
240 | * Compares two integers of type unsigned int. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
241 | * |
| 579 | 242 | * @param i1 unsigned integer one |
| 243 | * @param i2 unsigned integer two | |
| 244 | * @retval -1 if the left argument is less than the right argument | |
| 245 | * @retval 0 if both arguments are equal | |
| 246 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
247 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
248 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
249 | int cx_vcmp_uint(unsigned int i1, unsigned int i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
250 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
251 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
252 | * Compares two integers of type unsigned long int. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
253 | * |
| 579 | 254 | * @note the parameters deliberately have type @c void* to be |
| 255 | * compatible with #cx_compare_func without the need of a cast. | |
| 256 | * | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
257 | * @param i1 pointer to unsigned long integer one |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
258 | * @param i2 pointer to unsigned long integer two |
| 579 | 259 | * @retval -1 if the left argument is less than the right argument |
| 260 | * @retval 0 if both arguments are equal | |
| 261 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
262 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
263 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
264 | int cx_cmp_ulongint(const void *i1, const void *i2); |
| 579 | 265 | |
| 266 | /** | |
| 267 | * Compares two integers of type unsigned long int. | |
| 268 | * | |
| 269 | * @param i1 unsigned long integer one | |
| 270 | * @param i2 unsigned long integer two | |
| 271 | * @retval -1 if the left argument is less than the right argument | |
| 272 | * @retval 0 if both arguments are equal | |
| 273 | * @retval 1 if the left argument is greater than the right argument | |
| 274 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
275 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
276 | int cx_vcmp_ulongint(unsigned long int i1, unsigned long int i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
277 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
278 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
279 | * Compares two integers of type unsigned long long. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
280 | * |
| 579 | 281 | * @note the parameters deliberately have type @c void* to be |
| 282 | * compatible with #cx_compare_func without the need of a cast. | |
| 283 | * | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
284 | * @param i1 pointer to unsigned long long one |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
285 | * @param i2 pointer to unsigned long long two |
| 579 | 286 | * @retval -1 if the left argument is less than the right argument |
| 287 | * @retval 0 if both arguments are equal | |
| 288 | * @retval 1 if the left argument is greater than the right argument | |
| 289 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
290 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
291 | int cx_cmp_ulonglong(const void *i1, const void *i2); |
| 579 | 292 | |
| 293 | /** | |
| 294 | * Compares two integers of type unsigned long long. | |
| 295 | * | |
| 296 | * @param i1 unsigned long long one | |
| 297 | * @param i2 unsigned long long two | |
| 298 | * @retval -1 if the left argument is less than the right argument | |
| 299 | * @retval 0 if both arguments are equal | |
| 300 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
301 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
302 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
303 | int cx_vcmp_ulonglong(unsigned long long int i1, unsigned long long int i2); |
| 579 | 304 | |
| 305 | /** | |
| 306 | * Compares two integers of type uint16_t. | |
| 307 | * | |
| 308 | * @note the parameters deliberately have type @c void* to be | |
| 309 | * compatible with #cx_compare_func without the need of a cast. | |
| 310 | * | |
| 311 | * @param i1 pointer to uint16_t one | |
| 312 | * @param i2 pointer to uint16_t two | |
| 313 | * @retval -1 if the left argument is less than the right argument | |
| 314 | * @retval 0 if both arguments are equal | |
| 315 | * @retval 1 if the left argument is greater than the right argument | |
| 316 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
317 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
318 | int cx_cmp_uint16(const void *i1, const void *i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
319 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
320 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
321 | * Compares two integers of type uint16_t. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
322 | * |
| 579 | 323 | * @param i1 uint16_t one |
| 324 | * @param i2 uint16_t two | |
| 325 | * @retval -1 if the left argument is less than the right argument | |
| 326 | * @retval 0 if both arguments are equal | |
| 327 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
328 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
329 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
330 | int cx_vcmp_uint16(uint16_t i1, uint16_t i2); |
| 579 | 331 | |
| 332 | /** | |
| 333 | * Compares two integers of type uint32_t. | |
| 334 | * | |
| 335 | * @note the parameters deliberately have type @c void* to be | |
| 336 | * compatible with #cx_compare_func without the need of a cast. | |
| 337 | * | |
| 338 | * @param i1 pointer to uint32_t one | |
| 339 | * @param i2 pointer to uint32_t two | |
| 340 | * @retval -1 if the left argument is less than the right argument | |
| 341 | * @retval 0 if both arguments are equal | |
| 342 | * @retval 1 if the left argument is greater than the right argument | |
| 343 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
344 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
345 | int cx_cmp_uint32(const void *i1, const void *i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
346 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
347 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
348 | * Compares two integers of type uint32_t. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
349 | * |
| 579 | 350 | * @param i1 uint32_t one |
| 351 | * @param i2 uint32_t two | |
| 352 | * @retval -1 if the left argument is less than the right argument | |
| 353 | * @retval 0 if both arguments are equal | |
| 354 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
355 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
356 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
357 | int cx_vcmp_uint32(uint32_t i1, uint32_t i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
358 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
359 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
360 | * Compares two integers of type uint64_t. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
361 | * |
| 579 | 362 | * @note the parameters deliberately have type @c void* to be |
| 363 | * compatible with #cx_compare_func without the need of a cast. | |
| 364 | * | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
365 | * @param i1 pointer to uint64_t one |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
366 | * @param i2 pointer to uint64_t two |
| 579 | 367 | * @retval -1 if the left argument is less than the right argument |
| 368 | * @retval 0 if both arguments are equal | |
| 369 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
370 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
371 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
372 | int cx_cmp_uint64(const void *i1, const void *i2); |
| 579 | 373 | |
| 374 | /** | |
| 375 | * Compares two integers of type uint64_t. | |
| 376 | * | |
| 377 | * @param i1 uint64_t one | |
| 378 | * @param i2 uint64_t two | |
| 379 | * @retval -1 if the left argument is less than the right argument | |
| 380 | * @retval 0 if both arguments are equal | |
| 381 | * @retval 1 if the left argument is greater than the right argument | |
| 382 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
383 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
384 | int cx_vcmp_uint64(uint64_t i1, uint64_t i2); |
| 621 | 385 | |
| 386 | /** | |
| 387 | * Compares two integers of type size_t. | |
| 388 | * | |
| 389 | * @note the parameters deliberately have type @c void* to be | |
| 390 | * compatible with #cx_compare_func without the need of a cast. | |
| 391 | * | |
| 392 | * @param i1 pointer to size_t one | |
| 393 | * @param i2 pointer to size_t two | |
| 394 | * @retval -1 if the left argument is less than the right argument | |
| 395 | * @retval 0 if both arguments are equal | |
| 396 | * @retval 1 if the left argument is greater than the right argument | |
| 397 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
398 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
399 | int cx_cmp_size(const void *i1, const void *i2); |
| 621 | 400 | |
| 401 | /** | |
| 402 | * Compares two integers of type size_t. | |
| 403 | * | |
| 404 | * @param i1 size_t one | |
| 405 | * @param i2 size_t two | |
| 406 | * @retval -1 if the left argument is less than the right argument | |
| 407 | * @retval 0 if both arguments are equal | |
| 408 | * @retval 1 if the left argument is greater than the right argument | |
| 409 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
410 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
411 | int cx_vcmp_size(size_t i1, size_t i2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
412 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
413 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
414 | * Compares two real numbers of type float with precision 1e-6f. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
415 | * |
| 579 | 416 | * @note the parameters deliberately have type @c void* to be |
| 417 | * compatible with #cx_compare_func without the need of a cast. | |
| 418 | * | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
419 | * @param f1 pointer to float one |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
420 | * @param f2 pointer to float two |
| 579 | 421 | * @retval -1 if the left argument is less than the right argument |
| 422 | * @retval 0 if both arguments are equal | |
| 423 | * @retval 1 if the left argument is greater than the right argument | |
| 424 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
425 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
426 | int cx_cmp_float(const void *f1, const void *f2); |
| 579 | 427 | |
| 428 | /** | |
| 429 | * Compares two real numbers of type float with precision 1e-6f. | |
| 430 | * | |
| 431 | * @param f1 float one | |
| 432 | * @param f2 float two | |
| 433 | * @retval -1 if the left argument is less than the right argument | |
| 434 | * @retval 0 if both arguments are equal | |
| 435 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
436 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
437 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
438 | int cx_vcmp_float(float f1, float f2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
439 | |
| 579 | 440 | /** |
| 441 | * Compares two real numbers of type double with precision 1e-14. | |
| 442 | * | |
| 443 | * @note the parameters deliberately have type @c void* to be | |
| 444 | * compatible with #cx_compare_func without the need of a cast. | |
| 445 | * | |
| 446 | * @param d1 pointer to double one | |
| 447 | * @param d2 pointer to double two | |
| 448 | * @retval -1 if the left argument is less than the right argument | |
| 449 | * @retval 0 if both arguments are equal | |
| 450 | * @retval 1 if the left argument is greater than the right argument | |
| 451 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
452 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
453 | int cx_cmp_double(const void *d1, const void *d2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
454 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
455 | /** |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
456 | * Compares two real numbers of type double with precision 1e-14. |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
457 | * |
| 579 | 458 | * @param d1 double one |
| 459 | * @param d2 double two | |
| 460 | * @retval -1 if the left argument is less than the right argument | |
| 461 | * @retval 0 if both arguments are equal | |
| 462 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
463 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
464 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
465 | int cx_vcmp_double(double d1, double d2); |
| 579 | 466 | |
| 467 | /** | |
| 468 | * Compares the integer representation of two pointers. | |
| 469 | * | |
| 470 | * @note the parameters deliberately have type @c void* to be | |
| 471 | * compatible with #cx_compare_func without the need of a cast. | |
| 472 | * | |
| 473 | * @param ptr1 pointer to pointer one (const intptr_t*) | |
| 474 | * @param ptr2 pointer to pointer two (const intptr_t*) | |
| 475 | * @retval -1 if the left argument is less than the right argument | |
| 476 | * @retval 0 if both arguments are equal | |
| 477 | * @retval 1 if the left argument is greater than the right argument | |
| 478 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
479 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
480 | int cx_cmp_intptr(const void *ptr1, const void *ptr2); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
481 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
482 | /** |
| 490 | 483 | * Compares the integer representation of two pointers. |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
484 | * |
| 579 | 485 | * @param ptr1 pointer one |
| 486 | * @param ptr2 pointer two | |
| 487 | * @retval -1 if the left argument is less than the right argument | |
| 488 | * @retval 0 if both arguments are equal | |
| 489 | * @retval 1 if the left argument is greater than the right argument | |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
490 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
491 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
492 | int cx_vcmp_intptr(intptr_t ptr1, intptr_t ptr2); |
| 490 | 493 | |
| 494 | /** | |
| 495 | * Compares the unsigned integer representation of two pointers. | |
| 496 | * | |
| 579 | 497 | * @note the parameters deliberately have type @c void* to be |
| 498 | * compatible with #cx_compare_func without the need of a cast. | |
| 499 | * | |
| 500 | * @param ptr1 pointer to pointer one (const uintptr_t*) | |
| 501 | * @param ptr2 pointer to pointer two (const uintptr_t*) | |
| 502 | * @retval -1 if the left argument is less than the right argument | |
| 503 | * @retval 0 if both arguments are equal | |
| 504 | * @retval 1 if the left argument is greater than the right argument | |
| 490 | 505 | */ |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
506 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
507 | int cx_cmp_uintptr(const void *ptr1, const void *ptr2); |
| 579 | 508 | |
| 509 | /** | |
| 510 | * Compares the unsigned integer representation of two pointers. | |
| 511 | * | |
| 512 | * @param ptr1 pointer one | |
| 513 | * @param ptr2 pointer two | |
| 514 | * @retval -1 if the left argument is less than the right argument | |
| 515 | * @retval 0 if both arguments are equal | |
| 516 | * @retval 1 if the left argument is greater than the right argument | |
| 517 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
518 | CX_EXTERN CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
519 | int cx_vcmp_uintptr(uintptr_t ptr1, uintptr_t ptr2); |
| 579 | 520 | |
| 521 | /** | |
| 522 | * Compares the pointers specified in the arguments without dereferencing. | |
| 523 | * | |
| 524 | * @param ptr1 pointer one | |
| 525 | * @param ptr2 pointer two | |
| 526 | * @retval -1 if the left argument is less than the right argument | |
| 527 | * @retval 0 if both arguments are equal | |
| 528 | * @retval 1 if the left argument is greater than the right argument | |
| 529 | */ | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
530 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
531 | int cx_cmp_ptr(const void *ptr1, const void *ptr2); |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
532 | |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
533 | /** Wraps a compare function for cx_cmp_wrap. */ |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
534 | typedef struct { |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
535 | /** The wrapped compare function */ |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
536 | cx_compare_func cmp; |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
537 | } cx_compare_func_wrapper; |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
538 | |
|
660
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
539 | /** |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
540 | * A @c cx_compare_func2 wrapper for a @c cx_compare_func(). |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
541 | * |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
542 | * @param ptr1 pointer one |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
543 | * @param ptr2 pointer two |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
544 | * @param cmp_wrapper a pointer to a @c cx_compare_func_wrapper |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
545 | * @return the result of the invoked compare function |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
546 | * @see cx_compare_func_wrapper |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
547 | */ |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
548 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
f00d03835dd9
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
621
diff
changeset
|
549 | int cx_cmp_wrap(const void *ptr1, const void *ptr2, void* cmp_wrapper); |
|
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
550 | |
|
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
551 | #endif //UCX_COMPARE_H |