diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-10-23 05:23:27 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2025-10-23 05:23:27 +0000 |
| commit | e32b4b69cdf55bb73638021b01f2be7d4b165be9 (patch) | |
| tree | 9fdd043c58b3e71b4882f1054992c84e5d934876 | |
| parent | 35e02f440241b8f4ded53cf00d8c2b5c6d3327e2 (diff) | |
| download | skalibs-e32b4b69cdf55bb73638021b01f2be7d4b165be9.tar.gz | |
Fix qsort_r sysdep detection
| -rw-r--r-- | src/libposixplz/qsortr.c | 1 | ||||
| -rw-r--r-- | src/sysdeps/tryqsortr_freebsd.c | 14 | ||||
| -rw-r--r-- | src/sysdeps/tryqsortr_posix.c | 14 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/libposixplz/qsortr.c b/src/libposixplz/qsortr.c index 5fa7dd1..5d95ec4 100644 --- a/src/libposixplz/qsortr.c +++ b/src/libposixplz/qsortr.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <skalibs/sysdeps.h> +#include <skalibs/nonposix.h> #include <stdlib.h> diff --git a/src/sysdeps/tryqsortr_freebsd.c b/src/sysdeps/tryqsortr_freebsd.c index 6bf090a..41ed2fc 100644 --- a/src/sysdeps/tryqsortr_freebsd.c +++ b/src/sysdeps/tryqsortr_freebsd.c @@ -1,19 +1,25 @@ /* ISC license. */ +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif + #include <stdlib.h> static int f (void const *a, void const *b, void *c) { - int aa = *(int *)a ; - int bb = *(int *)b ; + int aa = *(int const *)a ; + int bb = *(int const *)b ; (void)c ; return aa < bb ? -1 : aa > bb ; } int main (void) { - char *x = "blah" ; + char *arg = "blah" ; int x[2] = { 2, 1 } ; - qsort_r(x, 2, sizeof(int), x, &f) ; + qsort_r(x, 2, sizeof(int), arg, &f) ; return 0 ; } diff --git a/src/sysdeps/tryqsortr_posix.c b/src/sysdeps/tryqsortr_posix.c index 63c1d60..81af081 100644 --- a/src/sysdeps/tryqsortr_posix.c +++ b/src/sysdeps/tryqsortr_posix.c @@ -1,19 +1,25 @@ /* ISC license. */ +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include <stdlib.h> static int f (void const *a, void const *b, void *c) { - int aa = *(int *)a ; - int bb = *(int *)b ; + int aa = *(int const *)a ; + int bb = *(int const *)b ; (void)c ; return aa < bb ? -1 : aa > bb ; } int main (void) { - char *x = "blah" ; + char *arg = "blah" ; int x[2] = { 2, 1 } ; - qsort_r(x, 2, sizeof(int), &f, x) ; + qsort_r(x, 2, sizeof(int), &f, arg) ; return 0 ; } |
