src/cx/compare.h

Tue, 07 Feb 2023 20:08:45 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 07 Feb 2023 20:08:45 +0100
changeset 650
77021e06b1a8
parent 631
406376e64fd8
child 759
475335643af4
permissions
-rw-r--r--

fix code not compiling under windows+mingw

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

mercurial