From: Duncan Mac-Vicar P Date: Mon, 16 May 2011 13:08:40 +0000 (+0200) Subject: decide which qsort_r to use based on what it is available X-Git-Tag: BASE-SuSE-Code-12_1-Branch~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9ff4820c732e729af61f19d00986bb6cab79a26;p=platform%2Fupstream%2Flibsolv.git decide which qsort_r to use based on what it is available Conflicts: src/util.c --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9bd0fde..87fc4b4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,16 @@ +INCLUDE(CheckFunctionExists) +CHECK_FUNCTION_EXISTS(qsort_r HAVE_QSORT_R) +CHECK_FUNCTION_EXISTS(__qsort_r HAVE___QSORT_R) + +IF (HAVE_QSORT_R) + ADD_DEFINITIONS(-DHAVE_QSORT_R=1) +ENDIF (HAVE_QSORT_R) + +IF (HAVE___QSORT_R) + ADD_DEFINITIONS(-DHAVE___QSORT_R=1) +ENDIF (HAVE___QSORT_R) + SET(libsatsolver_SRCS bitmap.c poolarch.c poolvendor.c poolid.c strpool.c dirpool.c solver.c solverdebug.c repo_solv.c evr.c pool.c diff --git a/src/util.c b/src/util.c index b04771e..a08f4ce 100644 --- a/src/util.c +++ b/src/util.c @@ -98,29 +98,31 @@ sat_timems(unsigned int subtract) return r - subtract; } -#ifdef USE_OWN_QSORT -#include "qsort_r.c" -#else - /* bsd's qsort_r has different arguments, so we define our own version in case we need to do some clever mapping - + see also: http://sources.redhat.com/ml/libc-alpha/2008-12/msg00003.html */ #if defined(__GLIBC__) +# if HAVE_QSORT_R || HAVE___QSORT_R void sat_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard) { -# if __GLIBC_PREREQ(2, 8) +# if HAVE_QSORT_R qsort_r(base, nmemb, size, compar, compard); # else /* backported for SLE10-SP2 */ __qsort_r(base, nmemb, size, compar, compard); # endif + } +#else /* qsort_r or __qsort_r on glibc */ +/* use own version of qsort if none available */ +#include "qsort_r.c" +#endif -#else +#else /* not glibc */ struct sat_sort_data { int (*compar)(const void *, const void *, void *); @@ -145,8 +147,6 @@ sat_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, cons #endif -#endif /* USE_OWN_QSORT */ - char * sat_dupjoin(const char *str1, const char *str2, const char *str3) {