]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
build: check for qsort_r independent of platform
authorNatanael Copa <ncopa@alpinelinux.org>
Tue, 4 Mar 2014 11:49:34 +0000 (11:49 +0000)
committerNatanael Copa <ncopa@alpinelinux.org>
Tue, 4 Mar 2014 12:01:26 +0000 (12:01 +0000)
Rather than check for specific glibc version on PLATFORM_LINUX, check
the existance of qsort_r.

This fixes the following compile error with musl libc:

CC              src/main.o
In file included from src/main.c:39:0:
src/tvheadend.h:608:20: error: missing binary operator before token "("
 #if !__GLIBC_PREREQ(2,8)
                    ^

configure
src/tvheadend.h
src/wrappers.c

index 07704b09d559650fb081da6b59009404e63af2a3..4446e349d8eb0c67f900cbe0fb26200f701abd4d 100755 (executable)
--- a/configure
+++ b/configure
@@ -103,6 +103,15 @@ int test ( void )
   return ok;
 }' -lpthread
 
+check_cc_snippet qsort_r '
+#include <stdlib.h>
+#define TEST test
+int test(void)
+{
+  qsort_r(NULL, 0, 0, NULL, NULL);
+  return 0;
+}
+'
 #
 # Python
 #
index 0bb2be80004da10c38aa48e9fa134713f70d93e2..218ac5db786a8303bc333d356fad58d80d1df9a7 100644 (file)
@@ -603,14 +603,12 @@ int rmtree ( const char *path );
 
 char *regexp_escape ( const char *str );
 
-#ifdef PLATFORM_LINUX
 /* glibc wrapper */
-#if !__GLIBC_PREREQ(2,8)
+#if ! ENABLE_QSORT_R
 void
 qsort_r(void *base, size_t nmemb, size_t size,
        int (*cmp)(const void *, const void *, void *), void *aux);
-#endif
-#endif /* PLATFORM_LINUX */
+#endif /* ENABLE_QSORT_R */
 
 /* printing */
 # if __WORDSIZE == 64
index 4343fc505bf4fe03006c101412293bdfd19d7335..f3ed9b1a233deca45ef86a39414b6364ef47675e 100644 (file)
@@ -135,12 +135,11 @@ tvhthread_create0
   return r;
 }
 
-#ifdef PLATFORM_LINUX
+#if ! ENABLE_QSORT_R
 /*
  * qsort_r wrapper for pre GLIBC 2.8
  */
 
-#if !__GLIBC_PREREQ(2,8)
 static __thread struct {
   int (*cmp) ( const void *a, const void *b, void *p );
   void *aux;
@@ -160,5 +159,4 @@ qsort_r(void *base, size_t nmemb, size_t size,
   qsort_r_data.aux = aux;
   qsort(base, nmemb, size, qsort_r_wrap);
 }
-#endif /* GLIBC < 2.8 */
-#endif /* PLATFORM_LINUX */
+#endif /* ENABLE_QSORT_R */