From 6b22174ff163b828a2069f22353018ca97fc0fb4 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Mon, 3 Jun 2019 14:02:09 +0100 Subject: libctf: look for BSD versus GNU qsort_r signatures We cannot just look for any declaration of qsort_r, because some operating systems have a qsort_r that has a different prototype but which still has a pair of pointers in the right places (the last two args are interchanged): so use AC_LINK_IFELSE to check for both known variants of qsort_r(), and swap their args into a consistent order in a suitable inline function. (The code for this is taken almost unchanged from gnulib.) (Now we are not using AC_LIBOBJ any more, we can use a better name for the qsort_r replacement as well.) libctf/ * qsort_r.c: Rename to... * ctf-qsort_r.c: ... this. (_quicksort): Define to ctf_qsort_r. * ctf-decls.h (qsort_r): Remove. (ctf_qsort_r): Add. (struct ctf_qsort_arg): New, transport the real ARG and COMPAR. (ctf_qsort_compar_thunk): Rearrange the arguments to COMPAR. * Makefile.am (libctf_a_LIBADD): Remove. (libctf_a_SOURCES): New, add ctf-qsort_r.c. * ctf-archive.c (ctf_arc_write): Call ctf_qsort_r, not qsort_r. * ctf-create.c (ctf_update): Likewise. * configure.ac: Check for BSD versus GNU qsort_r signature. * Makefile.in: Regenerate. * config.h.in: Likewise. * configure: Likewise. --- libctf/ctf-create.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libctf/ctf-create.c') diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c index 227f62d..3beed88 100644 --- a/libctf/ctf-create.c +++ b/libctf/ctf-create.c @@ -344,7 +344,7 @@ ctf_update (ctf_file_t *fp) } assert (i == nvars); - qsort_r (dvarents, nvars, sizeof (ctf_varent_t), ctf_sort_var, s0); + ctf_qsort_r (dvarents, nvars, sizeof (ctf_varent_t), ctf_sort_var, s0); t += sizeof (ctf_varent_t) * nvars; assert (t == (unsigned char *) buf + sizeof (ctf_header_t) + hdr.cth_typeoff); -- cgit v1.1