gmp-utils: Convert the read/write methods to using gdb::array_view
[binutils-gdb.git] / libctf / ctf-decls.h
blobe1ada3b9592e1583b17f7f43694e8496630d80f5
1 /* Declarations for missing functions.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
4 This file is part of libctf.
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.
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.
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/>. */
20 #ifndef _CTF_DECLS_H
21 #define _CTF_DECLS_H
23 #include "config.h"
25 #include <stddef.h>
26 #include <stdlib.h>
27 #include "libiberty.h"
29 #if HAVE_QSORT_R_ARG_LAST
30 static inline void
31 ctf_qsort_r (void *base, size_t nmemb, size_t size,
32 int (*compar)(const void *, const void *, void *),
33 void *arg)
35 qsort_r (base, nmemb, size, compar, arg);
37 #elif HAVE_QSORT_R_COMPAR_LAST
38 struct ctf_qsort_arg
40 int (*compar) (const void *, const void *, void *);
41 void *arg;
44 static int
45 ctf_qsort_compar_thunk (void *arg, const void *a, const void *b)
47 struct ctf_qsort_arg *qsort_arg = (struct ctf_qsort_arg *) arg;
49 return qsort_arg->compar (a, b, qsort_arg->arg);
52 static inline void
53 ctf_qsort_r (void *base, size_t nmemb, size_t size,
54 int (*compar)(const void *, const void *, void *),
55 void *arg)
57 struct ctf_qsort_arg thunk = { compar, arg };
58 qsort_r (base, nmemb, size, &thunk, ctf_qsort_compar_thunk);
60 #else
61 void ctf_qsort_r (void *base, size_t nmemb, size_t size,
62 int (*compar)(const void *, const void *, void *),
63 void *arg);
64 #endif
66 #ifndef HAVE_O_CLOEXEC
67 # define O_CLOEXEC 0
68 #endif
70 #undef MAX
71 #undef MIN
72 #define MAX(a, b) ((a) > (b) ? (a) : (b))
73 #define MIN(a, b) ((a) < (b) ? (a) : (b))
75 #if !HAVE_DECL_STPCPY
76 extern char *stpcpy (char *, const char *);
77 #endif
79 #endif /* _CTF_DECLS_H */