|
Added
Link Here
|
| 1 |
--- stellarsolver/astrometry/util/os-features-test.c.orig 2022-07-29 16:11:55 UTC |
| 2 |
+++ stellarsolver/astrometry/util/os-features-test.c |
| 3 |
@@ -14,7 +14,11 @@ int main() { |
| 4 |
} |
| 5 |
#endif |
| 6 |
|
| 7 |
-#ifdef TEST_QSORT_R |
| 8 |
+#ifdef TEST_BSD_QSORT_R |
| 9 |
+void (qsort_r)(void *base, size_t nmemb, size_t sz, |
| 10 |
+ void *userdata, |
| 11 |
+ int (*compar)(void *, const void *, const void *)); |
| 12 |
+ |
| 13 |
static int cmp(void* u, const void* a, const void* b) { |
| 14 |
return 0; |
| 15 |
} |
| 16 |
@@ -22,51 +26,22 @@ int main() { |
| 17 |
int array; |
| 18 |
int baton; |
| 19 |
qsort_r(&array, 1, sizeof(int), &baton, cmp); |
| 20 |
- //printf("#define NEED_QSORT_R 0\n"); |
| 21 |
return 0; |
| 22 |
} |
| 23 |
#endif |
| 24 |
|
| 25 |
-#ifdef TEST_DECLARE_QSORT_R |
| 26 |
-// Test whether just declaring qsort_r as we do causes a compile failure. |
| 27 |
+#ifdef TEST_GNU_QSORT_R |
| 28 |
+void (qsort_r)(void *base, size_t nmemb, size_t sz, |
| 29 |
+ int (*compar)(const void *, const void *, void *), |
| 30 |
+ void *userdata); |
| 31 |
|
| 32 |
-void qsort_r(void *base, size_t nmemb, size_t sz, |
| 33 |
- void *userdata, |
| 34 |
- int (*compar)(void *, const void *, const void *)); |
| 35 |
- |
| 36 |
-int main() { |
| 37 |
- //printf("#define NEED_DECLARE_QSORT_R 1\n"); |
| 38 |
+static int cmp(const void* a, const void* b, void* u) { |
| 39 |
return 0; |
| 40 |
} |
| 41 |
-#endif |
| 42 |
- |
| 43 |
-#ifdef TEST_SWAP_QSORT_R |
| 44 |
-// Use the result of TEST_DECLARE_QSORT_R and TEST_NEED_QSORT_R, or else |
| 45 |
-// this test will fail with a warning about undefined qsort_r |
| 46 |
-// Include .c rather than .h because we test with: |
| 47 |
-// gcc -o (exec) os-features-test.c |
| 48 |
-// and if NEED_QSORT_R, os-features.c includes qsort_reentrant.c |
| 49 |
-#include "os-features-config.h.tmp" |
| 50 |
-#define DONT_INCLUDE_OS_FEATURES_CONFIG_H 1 |
| 51 |
-#include "os-features.c" |
| 52 |
-#undef DONT_INCLUDE_OS_FEATURES_CONFIG_H |
| 53 |
-// Test whether qsort_r works unswapped. (ie, qsort_r matches the definition of |
| 54 |
-// QSORT_R defined in the os-features.h documentation.) |
| 55 |
-static int sortfunc(void* thunk, const void* v1, const void* v2) { |
| 56 |
- const int* i1 = v1; |
| 57 |
- const int* i2 = v2; |
| 58 |
- if (*i1 < *i2) |
| 59 |
- return -1; |
| 60 |
- if (*i1 > *i2) |
| 61 |
- return 1; |
| 62 |
- return 0; |
| 63 |
-} |
| 64 |
int main() { |
| 65 |
- int array[] = { 4, 17, 88, 34, 12, 12, 17 }; |
| 66 |
- int N = sizeof(array)/sizeof(int); |
| 67 |
- int mythunk = 42; |
| 68 |
- qsort_r(array, N, sizeof(int), &mythunk, sortfunc); |
| 69 |
- //printf("#define NEED_SWAP_QSORT_R 0\n"); |
| 70 |
+ int array; |
| 71 |
+ int baton; |
| 72 |
+ qsort_r(&array, 1, sizeof(int), cmp, &baton); |
| 73 |
return 0; |
| 74 |
} |
| 75 |
#endif |