]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - libctf/ctf-decls.h
bus error with fuzzed archive element
[thirdparty/binutils-gdb.git] / libctf / ctf-decls.h
CommitLineData
a0486bac 1/* Declarations for missing functions.
fd67aa11 2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
a0486bac
JM
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 26#include <stdlib.h>
942d35f7 27#include "libiberty.h"
6b22174f
NA
28
29#if HAVE_QSORT_R_ARG_LAST
30static inline void
31ctf_qsort_r (void *base, size_t nmemb, size_t size,
32 int (*compar)(const void *, const void *, void *),
33 void *arg)
34{
35 qsort_r (base, nmemb, size, compar, arg);
36}
37#elif HAVE_QSORT_R_COMPAR_LAST
38struct ctf_qsort_arg
39{
40 int (*compar) (const void *, const void *, void *);
41 void *arg;
42};
43
44static int
45ctf_qsort_compar_thunk (void *arg, const void *a, const void *b)
46{
47 struct ctf_qsort_arg *qsort_arg = (struct ctf_qsort_arg *) arg;
48
67d4cc67 49 return qsort_arg->compar (a, b, qsort_arg->arg);
6b22174f
NA
50}
51
52static inline void
53ctf_qsort_r (void *base, size_t nmemb, size_t size,
54 int (*compar)(const void *, const void *, void *),
55 void *arg)
56{
57 struct ctf_qsort_arg thunk = { compar, arg };
58 qsort_r (base, nmemb, size, &thunk, ctf_qsort_compar_thunk);
59}
60#else
61void ctf_qsort_r (void *base, size_t nmemb, size_t size,
a0486bac
JM
62 int (*compar)(const void *, const void *, void *),
63 void *arg);
6b22174f 64#endif
a0486bac 65
ad118caa
NA
66#ifndef HAVE_O_CLOEXEC
67# define O_CLOEXEC 0
68#endif
69
a0486bac
JM
70#undef MAX
71#undef MIN
72#define MAX(a, b) ((a) > (b) ? (a) : (b))
73#define MIN(a, b) ((a) < (b) ? (a) : (b))
74
0f0c11f7
NA
75#if !HAVE_DECL_STPCPY
76extern char *stpcpy (char *, const char *);
77#endif
78
a0486bac 79#endif /* _CTF_DECLS_H */