use qsort_s on solaris feature/array

Wed, 07 Aug 2019 23:23:58 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 07 Aug 2019 23:23:58 +0200
branch
feature/array
changeset 348
3b9b4f6e9fd6
parent 347
62660a4875c9
child 349
05957b1d10a5

use qsort_s on solaris

src/array.c file | annotate | diff | comparison | revisions
--- a/src/array.c	Wed Aug 07 21:44:35 2019 +0200
+++ b/src/array.c	Wed Aug 07 23:23:58 2019 +0200
@@ -27,6 +27,8 @@
  */
 
 #define _GNU_SOURCE /* we want to use qsort_r(), if available */
+#define __STDC_WANT_LIB_EXT1__ 1 /* use qsort_s, if available */
+
 
 #include "ucx/array.h"
 #include "ucx/utils.h"
@@ -42,7 +44,11 @@
 #elif /* not  __GLIBC__ */ defined(__APPLE__) || defined(__FreeBSD__)
 #define ucx_array_sort_impl ucx_qsort_r
 #define USE_UCX_QSORT_R
-#endif /* __GLIBC__, __APLE__, __FreeBSD__ */
+#elif /* not (__APPLE || __FreeBSD__) */ defined(__sun)
+#if __STDC_VERSION__ >= 201112L
+#define ucx_array_sort_impl qsort_s
+#endif
+#endif /* __GLIBC__, __APLE__, __FreeBSD__, __sun */
 #endif /* UCX_ARRAY_DISABLE_QSORT */
 
 #ifndef ucx_array_sort_impl
@@ -298,7 +304,7 @@
 };
 
 static int cmp_func_swap_args(void *data, const void *x, const void *y) {
-    struct cmpfnc_swapargs_info* info = data;
+    cmpfnc_swapargs_info* info = data;
     return info->func(x, y, info->data);
 }
 

mercurial