Fix paths to ChangeLog files
[deliverable/binutils-gdb.git] / libctf / ctf-decls.h
CommitLineData
a0486bac
JM
1/* Declarations for missing functions.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3
4 This file is part of libctf.
5
6 libctf is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef _CTF_DECLS_H
21#define _CTF_DECLS_H
22
23#include "config.h"
24
a0486bac 25#include <stddef.h>
6b22174f
NA
26#include <stdlib.h>
27
28#if HAVE_QSORT_R_ARG_LAST
29static inline void
30ctf_qsort_r (void *base, size_t nmemb, size_t size,
31 int (*compar)(const void *, const void *, void *),
32 void *arg)
33{
34 qsort_r (base, nmemb, size, compar, arg);
35}
36#elif HAVE_QSORT_R_COMPAR_LAST
37struct ctf_qsort_arg
38{
39 int (*compar) (const void *, const void *, void *);
40 void *arg;
41};
42
43static int
44ctf_qsort_compar_thunk (void *arg, const void *a, const void *b)
45{
46 struct ctf_qsort_arg *qsort_arg = (struct ctf_qsort_arg *) arg;
47
48 return qsort_arg->compar (a, b, arg);
49}
50
51static inline void
52ctf_qsort_r (void *base, size_t nmemb, size_t size,
53 int (*compar)(const void *, const void *, void *),
54 void *arg)
55{
56 struct ctf_qsort_arg thunk = { compar, arg };
57 qsort_r (base, nmemb, size, &thunk, ctf_qsort_compar_thunk);
58}
59#else
60void ctf_qsort_r (void *base, size_t nmemb, size_t size,
a0486bac
JM
61 int (*compar)(const void *, const void *, void *),
62 void *arg);
6b22174f 63#endif
a0486bac 64
ad118caa
NA
65#ifndef HAVE_O_CLOEXEC
66# define O_CLOEXEC 0
67#endif
68
a0486bac
JM
69#undef MAX
70#undef MIN
71#define MAX(a, b) ((a) > (b) ? (a) : (b))
72#define MIN(a, b) ((a) < (b) ? (a) : (b))
73
74#endif /* _CTF_DECLS_H */
This page took 0.027421 seconds and 4 git commands to generate.