diff options
author | Bruno Haible <bruno@clisp.org> | 2016-10-16 22:11:32 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2016-10-27 09:22:29 +0200 |
commit | ae23caf43875cd2aba829a4d5ba6f24f261fe7df (patch) | |
tree | 73c4fd3148218df441c876947da36afb211f6cc4 /lib/stdlib.in.h | |
parent | 174653f46049dab7b2d78b2849a8f518b0f7aeb2 (diff) | |
download | gnulib-ae23caf43875cd2aba829a4d5ba6f24f261fe7df.tar.gz |
qsort_r: Fix macrology for platforms that lack the function.
* m4/stdlib_h.m4 (gl_STDLIB_H): Check for qsort_r.
(gl_STDLIB_H_DEFAULTS): Initialize HAVE_QSORT_R.
* modules/stdlib (Makefile.am): Substitute HAVE_QSORT_R.
* lib/stdlib.in.h (qsort_r): Provide declaration if the function does
not exist.
* m4/qsort_r.m4 (gl_FUNC_QSORT_R): Use AC_CHECK_FUNCS to test whether
the function exists.
* modules/qsort_r: Add comments.
Diffstat (limited to 'lib/stdlib.in.h')
-rw-r--r-- | lib/stdlib.in.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 70dc88db75..db3253bd97 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -521,6 +521,9 @@ _GL_CXXALIASWARN (putenv); #endif #if @GNULIB_QSORT_R@ +/* Sort an array of NMEMB elements, starting at address BASE, each element + occupying SIZE bytes, in ascending order according to the comparison + function COMPARE. */ # if @REPLACE_QSORT_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef qsort_r @@ -535,12 +538,24 @@ _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, void *), void *arg)); # else +# if !@HAVE_QSORT_R@ +_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, + int (*compare) (void const *, void const *, + void *), + void *arg) _GL_ARG_NONNULL ((1, 4))); +# endif _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, int (*compare) (void const *, void const *, void *), void *arg)); # endif _GL_CXXALIASWARN (qsort_r); +#elif defined GNULIB_POSIXCHECK +# undef qsort_r +# if HAVE_RAW_DECL_QSORT_R +_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - " + "use gnulib module qsort_r for portability"); +# endif #endif |