diff --git a/configure b/configure index 07704b09..4446e349 100755 --- a/configure +++ b/configure @@ -103,6 +103,15 @@ int test ( void ) return ok; }' -lpthread +check_cc_snippet qsort_r ' +#include +#define TEST test +int test(void) +{ + qsort_r(NULL, 0, 0, NULL, NULL); + return 0; +} +' # # Python # diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index 258bc2bd..4793e97d 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -74,9 +74,8 @@ #define CW_DUMP(buf, len, format, ...) \ printf(format, __VA_ARGS__); int j; for (j = 0; j < len; ++j) printf("%02X ", buf[j]); printf("\n"); -#if defined(__GNUC__) && defined(PLATFORM_LINUX) -#include -#if __GNUC_PREREQ(4, 3) +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +#if 100*__GNUC__+__GNUC_MINOR >=403 #pragma GCC diagnostic ignored "-Warray-bounds" #endif #endif diff --git a/src/trap.c b/src/trap.c index 00664724..b0f1c358 100644 --- a/src/trap.c +++ b/src/trap.c @@ -175,7 +175,7 @@ traphandler(int sig, siginfo_t *si, void *UC) tvhlog_spawn(LOG_ALERT, "CRASH", "Loaded libraries: %s ", libs); #ifdef NGREG - snprintf(tmpbuf, sizeof(tmpbuf), "Register dump [%d]: ", NGREG); + snprintf(tmpbuf, sizeof(tmpbuf), "Register dump [%d]: ", (int)NGREG); for(i = 0; i < NGREG; i++) { sappend(tmpbuf, sizeof(tmpbuf), "%016" PRIx64, uc->uc_mcontext.gregs[i]); diff --git a/src/tvheadend.h b/src/tvheadend.h index 0bb2be80..a5218510 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -31,6 +31,7 @@ #include #include #include +#include #if ENABLE_LOCKOWNER #include #endif @@ -603,16 +604,22 @@ 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 */ +#ifndef __WORDSIZE +# if ULONG_MAX == 0xffffffffffffffff +# define __WORDSIZE 64 +# elif ULONG_MAX == 0xffffffff +# define __WORDSIZE 32 +# endif /* ULONG_MAX */ +#endif /* __WORDSIZE */ + # if __WORDSIZE == 64 #define PRIsword_t PRId64 #define PRIuword_t PRIu64 diff --git a/src/wrappers.c b/src/wrappers.c index 4343fc50..f3ed9b1a 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -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 */