From bf9897549dabfe002ebc8048e910706995383ae9 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Fri, 5 Dec 2014 16:21:04 +0000 Subject: * libc/include/stdlib.h (__bsd_qsort_r): Declare. (qsort_r): Declare. * libc/search/Makefile.am (ELIX_2_SOURCES): Rename from ELIX_SOURCES. (ELIX_4_SOURCES): Define. Add bsd_qsort_r.c and qsort_r.c. (libsearch_la_SOURCES): Adapt accordingly. (lib_a_SOURCES): Adapt accordingly. (CHEWOUT_FILES): Add qsort_r.def. * libc/search/Makefile.in: Regenerate. * libc/search/bsd_qsort_r.c: New file. * libc/search/qsort.c: Update from FreeBSD HEAD. Adapt for both BSD and GNU qsort_r flavors. * libc/search/qsort_r.c: New file. --- newlib/libc/include/stdlib.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'newlib/libc/include/stdlib.h') diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h index 9fc14fa3b..ffbb44349 100644 --- a/newlib/libc/include/stdlib.h +++ b/newlib/libc/include/stdlib.h @@ -248,6 +248,22 @@ int _EXFUN(_system_r,(struct _reent *, const char *)); _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); +/* There are two common qsort_r variants. If you request + _BSD_SOURCE, you get the BSD version; otherwise you get the GNU + version. We want that #undef qsort_r will still let you + invoke the underlying function, but that requires gcc support. */ +#ifdef _BSD_SOURCE +# ifdef __GNUC__ +_VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR))) + __asm__ (__ASMNAME ("__bsd_qsort_r")); +# else +_VOID _EXFUN(__bsd_qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR))); +# define qsort_r __bsd_qsort_r +# endif +#elif __GNU_VISIBLE +_VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, int (*_compar)(const _PTR, const _PTR, _PTR), _PTR __thunk)); +#endif + /* On platforms where long double equals double. */ #ifdef _HAVE_LONG_DOUBLE #if !defined(__STRICT_ANSI__) || \ -- cgit v1.2.3