ucx
UAP Common Extensions
Loading...
Searching...
No Matches
compare.h
Go to the documentation of this file.
1/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
35
36#ifndef UCX_COMPARE_H
37#define UCX_COMPARE_H
38
39#include "common.h"
40
53CX_FPTR int (*cx_compare_func)(const void *left, const void *right);
54
60CX_FPTR int (*cx_compare_func2)(const void *left, const void *right, void *data);
61
75int cx_cmp_int(const void *i1, const void *i2);
76
87int cx_vcmp_int(int i1, int i2);
88
102int cx_cmp_longint(const void *i1, const void *i2);
103
114int cx_vcmp_longint(long int i1, long int i2);
115
129int cx_cmp_longlong(const void *i1, const void *i2);
130
141int cx_vcmp_longlong(long long int i1, long long int i2);
142
156int cx_cmp_int16(const void *i1, const void *i2);
157
168int cx_vcmp_int16(int16_t i1, int16_t i2);
169
183int cx_cmp_int32(const void *i1, const void *i2);
184
195int cx_vcmp_int32(int32_t i1, int32_t i2);
196
210int cx_cmp_int64(const void *i1, const void *i2);
211
222int cx_vcmp_int64(int64_t i1, int64_t i2);
223
237int cx_cmp_uint(const void *i1, const void *i2);
238
249int cx_vcmp_uint(unsigned int i1, unsigned int i2);
250
264int cx_cmp_ulongint(const void *i1, const void *i2);
265
276int cx_vcmp_ulongint(unsigned long int i1, unsigned long int i2);
277
291int cx_cmp_ulonglong(const void *i1, const void *i2);
292
303int cx_vcmp_ulonglong(unsigned long long int i1, unsigned long long int i2);
304
318int cx_cmp_uint16(const void *i1, const void *i2);
319
330int cx_vcmp_uint16(uint16_t i1, uint16_t i2);
331
345int cx_cmp_uint32(const void *i1, const void *i2);
346
357int cx_vcmp_uint32(uint32_t i1, uint32_t i2);
358
372int cx_cmp_uint64(const void *i1, const void *i2);
373
384int cx_vcmp_uint64(uint64_t i1, uint64_t i2);
385
399int cx_cmp_size(const void *i1, const void *i2);
400
411int cx_vcmp_size(size_t i1, size_t i2);
412
426int cx_cmp_float(const void *f1, const void *f2);
427
438int cx_vcmp_float(float f1, float f2);
439
453int cx_cmp_double(const void *d1, const void *d2);
454
465int cx_vcmp_double(double d1, double d2);
466
480int cx_cmp_intptr(const void *ptr1, const void *ptr2);
481
492int cx_vcmp_intptr(intptr_t ptr1, intptr_t ptr2);
493
507int cx_cmp_uintptr(const void *ptr1, const void *ptr2);
508
519int cx_vcmp_uintptr(uintptr_t ptr1, uintptr_t ptr2);
520
531int cx_cmp_ptr(const void *ptr1, const void *ptr2);
532
538
549int cx_cmp_wrap(const void *ptr1, const void *ptr2, void* cmp_wrapper);
550
551#endif //UCX_COMPARE_H
Common definitions and feature checks.
#define CX_NONNULL
All pointer arguments must be non-NULL.
Definition common.h:141
#define CX_NODISCARD
Warn about discarded return value.
Definition common.h:256
#define CX_FPTR
Defines a function pointer.
Definition common.h:299
#define CX_EXTERN
Declares a function with external linkage.
Definition common.h:297
int cx_cmp_uint16(const void *i1, const void *i2)
Compares two integers of type uint16_t.
int cx_cmp_longlong(const void *i1, const void *i2)
Compares two integers of type long long.
int cx_vcmp_uint(unsigned int i1, unsigned int i2)
Compares two integers of type unsigned int.
int cx_vcmp_size(size_t i1, size_t i2)
Compares two integers of type size_t.
int cx_vcmp_int(int i1, int i2)
Compares two integers of type int.
int cx_cmp_longint(const void *i1, const void *i2)
Compares two integers of type long int.
int cx_cmp_int16(const void *i1, const void *i2)
Compares two integers of type int16_t.
int cx_vcmp_int32(int32_t i1, int32_t i2)
Compares two integers of type int32_t.
int(* cx_compare_func)(const void *left, const void *right)
A comparator function comparing two arbitrary values.
Definition compare.h:53
int cx_vcmp_double(double d1, double d2)
Compares two real numbers of type double with precision 1e-14.
int cx_cmp_uintptr(const void *ptr1, const void *ptr2)
Compares the unsigned integer representation of two pointers.
int cx_vcmp_int64(int64_t i1, int64_t i2)
Compares two integers of type int64_t.
int cx_vcmp_uint32(uint32_t i1, uint32_t i2)
Compares two integers of type uint32_t.
int cx_cmp_int32(const void *i1, const void *i2)
Compares two integers of type int32_t.
int cx_vcmp_longint(long int i1, long int i2)
Compares two integers of type long int.
int cx_cmp_int64(const void *i1, const void *i2)
Compares two integers of type int64_t.
int cx_cmp_uint(const void *i1, const void *i2)
Compares two integers of type unsigned int.
int cx_cmp_ulonglong(const void *i1, const void *i2)
Compares two integers of type unsigned long long.
int cx_cmp_uint64(const void *i1, const void *i2)
Compares two integers of type uint64_t.
int cx_cmp_uint32(const void *i1, const void *i2)
Compares two integers of type uint32_t.
int cx_cmp_int(const void *i1, const void *i2)
Compares two integers of type int.
int cx_vcmp_ulongint(unsigned long int i1, unsigned long int i2)
Compares two integers of type unsigned long int.
int cx_cmp_ptr(const void *ptr1, const void *ptr2)
Compares the pointers specified in the arguments without dereferencing.
int cx_cmp_float(const void *f1, const void *f2)
Compares two real numbers of type float with precision 1e-6f.
int cx_vcmp_uint16(uint16_t i1, uint16_t i2)
Compares two integers of type uint16_t.
int cx_vcmp_ulonglong(unsigned long long int i1, unsigned long long int i2)
Compares two integers of type unsigned long long.
int(* cx_compare_func2)(const void *left, const void *right, void *data)
A comparator function comparing two arbitrary values.
Definition compare.h:60
int cx_vcmp_intptr(intptr_t ptr1, intptr_t ptr2)
Compares the integer representation of two pointers.
int cx_vcmp_uintptr(uintptr_t ptr1, uintptr_t ptr2)
Compares the unsigned integer representation of two pointers.
int cx_vcmp_float(float f1, float f2)
Compares two real numbers of type float with precision 1e-6f.
int cx_vcmp_longlong(long long int i1, long long int i2)
Compares two integers of type long long.
int cx_cmp_wrap(const void *ptr1, const void *ptr2, void *cmp_wrapper)
A cx_compare_func2 wrapper for a cx_compare_func().
int cx_cmp_size(const void *i1, const void *i2)
Compares two integers of type size_t.
int cx_cmp_double(const void *d1, const void *d2)
Compares two real numbers of type double with precision 1e-14.
int cx_cmp_ulongint(const void *i1, const void *i2)
Compares two integers of type unsigned long int.
int cx_vcmp_int16(int16_t i1, int16_t i2)
Compares two integers of type int16_t.
int cx_cmp_intptr(const void *ptr1, const void *ptr2)
Compares the integer representation of two pointers.
int cx_vcmp_uint64(uint64_t i1, uint64_t i2)
Compares two integers of type uint64_t.
Wraps a compare function for cx_cmp_wrap.
Definition compare.h:534
cx_compare_func cmp
The wrapped compare function.
Definition compare.h:536