18dffb485Schristos /* Declarations for missing functions. 2*c9055873Schristos Copyright (C) 2019-2024 Free Software Foundation, Inc. 38dffb485Schristos 48dffb485Schristos This file is part of libctf. 58dffb485Schristos 68dffb485Schristos libctf is free software; you can redistribute it and/or modify it under 78dffb485Schristos the terms of the GNU General Public License as published by the Free 88dffb485Schristos Software Foundation; either version 3, or (at your option) any later 98dffb485Schristos version. 108dffb485Schristos 118dffb485Schristos This program is distributed in the hope that it will be useful, but 128dffb485Schristos WITHOUT ANY WARRANTY; without even the implied warranty of 138dffb485Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 148dffb485Schristos See the GNU General Public License for more details. 158dffb485Schristos 168dffb485Schristos You should have received a copy of the GNU General Public License 178dffb485Schristos along with this program; see the file COPYING. If not see 188dffb485Schristos <http://www.gnu.org/licenses/>. */ 198dffb485Schristos 208dffb485Schristos #ifndef _CTF_DECLS_H 218dffb485Schristos #define _CTF_DECLS_H 228dffb485Schristos 238dffb485Schristos #include "config.h" 248dffb485Schristos 258dffb485Schristos #include <stddef.h> 268dffb485Schristos #include <stdlib.h> 278dffb485Schristos #include "libiberty.h" 288dffb485Schristos 298dffb485Schristos #if HAVE_QSORT_R_ARG_LAST 308dffb485Schristos static inline void 318dffb485Schristos ctf_qsort_r (void *base, size_t nmemb, size_t size, 328dffb485Schristos int (*compar)(const void *, const void *, void *), 338dffb485Schristos void *arg) 348dffb485Schristos { 358dffb485Schristos qsort_r (base, nmemb, size, compar, arg); 368dffb485Schristos } 378dffb485Schristos #elif HAVE_QSORT_R_COMPAR_LAST 388dffb485Schristos struct ctf_qsort_arg 398dffb485Schristos { 408dffb485Schristos int (*compar) (const void *, const void *, void *); 418dffb485Schristos void *arg; 428dffb485Schristos }; 438dffb485Schristos 448dffb485Schristos static int 458dffb485Schristos ctf_qsort_compar_thunk (void *arg, const void *a, const void *b) 468dffb485Schristos { 478dffb485Schristos struct ctf_qsort_arg *qsort_arg = (struct ctf_qsort_arg *) arg; 488dffb485Schristos 498dffb485Schristos return qsort_arg->compar (a, b, qsort_arg->arg); 508dffb485Schristos } 518dffb485Schristos 528dffb485Schristos static inline void 538dffb485Schristos ctf_qsort_r (void *base, size_t nmemb, size_t size, 548dffb485Schristos int (*compar)(const void *, const void *, void *), 558dffb485Schristos void *arg) 568dffb485Schristos { 578dffb485Schristos struct ctf_qsort_arg thunk = { compar, arg }; 588dffb485Schristos qsort_r (base, nmemb, size, &thunk, ctf_qsort_compar_thunk); 598dffb485Schristos } 608dffb485Schristos #else 618dffb485Schristos void ctf_qsort_r (void *base, size_t nmemb, size_t size, 628dffb485Schristos int (*compar)(const void *, const void *, void *), 638dffb485Schristos void *arg); 648dffb485Schristos #endif 658dffb485Schristos 668dffb485Schristos #ifndef HAVE_O_CLOEXEC 678dffb485Schristos # define O_CLOEXEC 0 688dffb485Schristos #endif 698dffb485Schristos 708dffb485Schristos #undef MAX 718dffb485Schristos #undef MIN 728dffb485Schristos #define MAX(a, b) ((a) > (b) ? (a) : (b)) 738dffb485Schristos #define MIN(a, b) ((a) < (b) ? (a) : (b)) 748dffb485Schristos 758dffb485Schristos #if !HAVE_DECL_STPCPY 768dffb485Schristos extern char *stpcpy (char *, const char *); 778dffb485Schristos #endif 788dffb485Schristos 798dffb485Schristos #endif /* _CTF_DECLS_H */ 80