src/cx/compare.h

Sat, 30 Dec 2023 14:58:06 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 30 Dec 2023 14:58:06 +0100
changeset 783
7ca8cf155489
parent 762
4523f6d42512
child 786
b0ebb3d88407
permissions
-rw-r--r--

add command to remove outdated coverage data

601
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 * \file compare.h
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 * \brief A collection of simple compare functions.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 * \author Mike Becker
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 * \author Olaf Wintermann
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 * \copyright 2-Clause BSD License
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 #ifndef UCX_COMPARE_H
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 #define UCX_COMPARE_H
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38
650
77021e06b1a8 fix code not compiling under windows+mingw
Mike Becker <universe@uap-core.de>
parents: 631
diff changeset
39 #include "common.h"
77021e06b1a8 fix code not compiling under windows+mingw
Mike Becker <universe@uap-core.de>
parents: 631
diff changeset
40
601
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 #ifdef __cplusplus
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 extern "C" {
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 #endif
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 * Compares two integers of type int.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 * @param i1 pointer to integer one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 * @param i2 pointer to integer two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 int cx_cmp_int(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 * Compares two integers of type long int.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 * @param i1 pointer to long integer one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 * @param i2 pointer to long integer two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 int cx_cmp_longint(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66 * Compares two integers of type long long.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 * @param i1 pointer to long long one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 * @param i2 pointer to long long two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 int cx_cmp_longlong(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 * Compares two integers of type int16_t.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 * @param i1 pointer to int16_t one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 * @param i2 pointer to int16_t two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 int cx_cmp_int16(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 * Compares two integers of type int32_t.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 * @param i1 pointer to int32_t one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 * @param i2 pointer to int32_t two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 int cx_cmp_int32(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 * Compares two integers of type int64_t.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 * @param i1 pointer to int64_t one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99 * @param i2 pointer to int64_t two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 int cx_cmp_int64(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 * Compares two integers of type unsigned int.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108 * @param i1 pointer to unsigned integer one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 * @param i2 pointer to unsigned integer two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 int cx_cmp_uint(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116 * Compares two integers of type unsigned long int.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118 * @param i1 pointer to unsigned long integer one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119 * @param i2 pointer to unsigned long integer two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
120 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123 int cx_cmp_ulongint(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 * Compares two integers of type unsigned long long.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128 * @param i1 pointer to unsigned long long one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129 * @param i2 pointer to unsigned long long two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
131 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 int cx_cmp_ulonglong(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
136 * Compares two integers of type uint16_t.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
137 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
138 * @param i1 pointer to uint16_t one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139 * @param i2 pointer to uint16_t two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
140 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
141 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 int cx_cmp_uint16(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
144
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
145 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
146 * Compares two integers of type uint32_t.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
147 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148 * @param i1 pointer to uint32_t one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
149 * @param i2 pointer to uint32_t two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
150 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
151 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
153 int cx_cmp_uint32(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
154
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 * Compares two integers of type uint64_t.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158 * @param i1 pointer to uint64_t one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
159 * @param i2 pointer to uint64_t two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
160 * @return -1, if *i1 is less than *i2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
161 * 1 if *i1 is greater than *i2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
162 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
163 int cx_cmp_uint64(void const *i1, void const *i2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
165 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 * Compares two real numbers of type float with precision 1e-6f.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 * @param f1 pointer to float one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 * @param f2 pointer to float two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 * @return -1, if *f1 is less than *f2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
171 * 1 if *f1 is greater than *f2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172 */
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 int cx_cmp_float(void const *f1, void const *f2);
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
175
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176 /**
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
177 * Compares two real numbers of type double with precision 1e-14.
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
178 *
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
179 * @param d1 pointer to double one
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
180 * @param d2 pointer to double two
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181 * @return -1, if *d1 is less than *d2, 0 if both are equal,
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
182 * 1 if *d1 is greater than *d2
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
183 */
631
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
184 int cx_cmp_double(
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
185 void const *d1,
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
186 void const *d2
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
187 );
601
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
188
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
189 /**
631
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
190 * Compares the integer representation of two pointers.
601
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 *
631
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
192 * @param ptr1 pointer to pointer one (intptr_t const*)
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
193 * @param ptr2 pointer to pointer two (intptr_t const*)
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
194 * @return -1 if *ptr1 is less than *ptr2, 0 if both are equal,
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
195 * 1 if *ptr1 is greater than *ptr2
601
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
196 */
631
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
197 int cx_cmp_intptr(
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
198 void const *ptr1,
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
199 void const *ptr2
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
200 );
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
201
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
202 /**
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
203 * Compares the unsigned integer representation of two pointers.
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
204 *
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
205 * @param ptr1 pointer to pointer one (uintptr_t const*)
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
206 * @param ptr2 pointer to pointer two (uintptr_t const*)
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
207 * @return -1 if *ptr1 is less than *ptr2, 0 if both are equal,
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
208 * 1 if *ptr1 is greater than *ptr2
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
209 */
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
210 int cx_cmp_uintptr(
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
211 void const *ptr1,
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
212 void const *ptr2
406376e64fd8 tests for compare functions
Mike Becker <universe@uap-core.de>
parents: 605
diff changeset
213 );
601
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
214
762
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
215 /**
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
216 * Compares the pointers specified in the arguments without de-referencing.
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
217 *
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
218 * @param ptr1 pointer one
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
219 * @param ptr2 pointer two
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
220 * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
221 * 1 if ptr1 is greater than ptr2
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
222 */
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
223 int cx_cmp_ptr(
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
224 void const *ptr1,
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
225 void const *ptr2
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
226 );
4523f6d42512 add cx_cmp_ptr() - fix #340
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
227
601
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
228 #ifdef __cplusplus
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
229 } // extern "C"
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
230 #endif
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
231
95ba6014041b add compare functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
232 #endif //UCX_COMPARE_H

mercurial