UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
qsort_s.h
Go to the documentation of this file.
1
8/*
9 * Copyright (c) 2022-2023 CESNET z.s.p.o.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, is permitted provided that the following conditions
14 * are met:
15 *
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * 3. Neither the name of CESNET nor the names of its contributors may be
24 * used to endorse or promote products derived from this software without
25 * specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
29 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
30 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
31 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
32 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
37 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
38 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef COMPAT_QSORT_S_H_81DF21DE_370E_4C70_8559_600C1A9B6059
42#define COMPAT_QSORT_S_H_81DF21DE_370E_4C70_8559_600C1A9B6059
43
44#if !defined EXIT_SUCCESS // stdlib.h not yet included
45#if defined __STDC_LIB_EXT1__
46#define __STDC_WANT_LIB_EXT1__ 1 // we want qsort_s
47#endif
48#ifdef __cplusplus
49#include <cstdlib>
50#else
51#include <stdlib.h>
52#endif // !defined __cplusplus
53#endif // !defined EXIT_SUCCESS
54
55#if !defined __STDC_LIB_EXT1__
56# if defined _WIN32
57# define QSORT_S_COMP_FIRST 1 // MS version of qsort_s with comparator as first arg
58# else
59# ifdef __APPLE__
60# define QSORT_S_COMP_FIRST 1 // BSD version of qsort_r() as well
61# define qsort_s(ptr, count, size, comp, context) qsort_r(ptr, count, size, context, comp)
62# else
63# define qsort_s qsort_r // GNU version
64# endif
65# endif
66#endif
67
68#ifdef QSORT_S_COMP_FIRST
69#define QSORT_S_COMP_DEFINE(name, a, b, context) int name(void *context, const void *a, const void *b)
70#else
71#define QSORT_S_COMP_DEFINE(name, a, b, context) int name(const void *a, const void *b, void *context)
72#endif
73
74#endif // ! defined COMPAT_QSORT_S_H_81DF21DE_370E_4C70_8559_600C1A9B6059
75