Commit 42d819e9 authored by Dmitry Antipov's avatar Dmitry Antipov

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.
parent 69149b6c
......@@ -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
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment