]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix last change to support Darwin/OSX (Bug#18354).
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 29 Aug 2014 16:21:30 +0000 (20:21 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Fri, 29 Aug 2014 16:21:30 +0000 (20:21 +0400)
* 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.

src/ChangeLog
src/fns.c

index c24ca69536fca3cc901c9922adb393fea2fedb66..2a78c4b4fa94033dd0b64637a23345e5cde11e1a 100644 (file)
@@ -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  <kbrown@cornell.edu>
 
        Add support for HYBRID_MALLOC, allowing the use of gmalloc before
index a454341fce692bb79d7ad3ddf026dd81be7954df..2b1fb86419d432ec7f26949111f490775a40148a 100644 (file)
--- 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 */