From: Dmitry Antipov Date: Fri, 29 Aug 2014 16:21:30 +0000 (+0400) Subject: Fix last change to support Darwin/OSX (Bug#18354). X-Git-Tag: emacs-25.0.90~2635^2~679^2~402 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=42d819e9de99996f09c124244dc577bf264ac350;p=emacs.git Fix last change to support Darwin/OSX (Bug#18354). * sysdep.c (sort_vector_compare) [DARWIN_OS || __FreeBSD__]: Conditionally define to match system's qsort_r signature. (sort_vector) [DARWIN_OS || __FreeBSD__]: Likewise in call to qsort_r. --- diff --git a/src/ChangeLog b/src/ChangeLog index c24ca69536f..2a78c4b4fa9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -9,6 +9,11 @@ * lisp.h (enum Lisp_Save_Type): New member SAVE_TYPE_INT_OBJ. (make_save_int_obj): Add prototype. + Fix last change to support Darwin/OSX (Bug#18354). + * sysdep.c (sort_vector_compare) [DARWIN_OS || __FreeBSD__]: + Conditionally define to match system's qsort_r signature. + (sort_vector) [DARWIN_OS || __FreeBSD__]: Likewise in call to qsort_r. + 2014-08-28 Ken Brown Add support for HYBRID_MALLOC, allowing the use of gmalloc before diff --git a/src/fns.c b/src/fns.c index a454341fce6..2b1fb86419d 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1876,7 +1876,8 @@ sort_list (Lisp_Object list, Lisp_Object predicate) return merge (front, back, predicate); } -/* Using GNU qsort_r, we can pass this as a parameter. */ +/* Using GNU qsort_r, we can pass this as a parameter. This also + exists on FreeBSD and Darwin/OSX, but with a different signature. */ #ifndef HAVE_QSORT_R static Lisp_Object sort_vector_predicate; #endif @@ -1885,16 +1886,22 @@ static Lisp_Object sort_vector_predicate; static int #ifdef HAVE_QSORT_R +#if defined (DARWIN_OS) || defined (__FreeBSD__) +sort_vector_compare (void *arg, const void *p, const void *q) +#elif defined (GNU_LINUX) sort_vector_compare (const void *p, const void *q, void *arg) -#else +#else /* neither darwin/bsd nor gnu/linux */ +#error "check how qsort_r comparison function works on your platform" +#endif /* DARWIN_OS || __FreeBSD__ */ +#else /* not HAVE_QSORT_R */ sort_vector_compare (const void *p, const void *q) -#endif /* HAVE_QSORT_R */ +#endif /* HAVE_QSORT_R */ { bool more, less; Lisp_Object op, oq, vp, vq; #ifdef HAVE_QSORT_R Lisp_Object sort_vector_predicate = *(Lisp_Object *) arg; -#endif +#endif op = *(Lisp_Object *) p; oq = *(Lisp_Object *) q; @@ -1928,8 +1935,14 @@ sort_vector (Lisp_Object vector, Lisp_Object predicate) /* Setup predicate and sort. */ #ifdef HAVE_QSORT_R +#if defined (DARWIN_OS) || defined (__FreeBSD__) + qsort_r (v, len, word_size, (void *) &predicate, sort_vector_compare); +#elif defined (GNU_LINUX) qsort_r (v, len, word_size, sort_vector_compare, (void *) &predicate); -#else +#else /* neither darwin/bsd nor gnu/linux */ +#error "check how qsort_r works on your platform" +#endif /* DARWIN_OS || __FreeBSD__ */ +#else /* not HAVE_QSORT_R */ sort_vector_predicate = predicate; qsort (v, len, word_size, sort_vector_compare); #endif /* HAVE_QSORT_R */