[Bf-blender-cvs] [df1c400] master: Use gnu-libc arg order for BLI_sort_r
Campbell Barton
noreply at git.blender.org
Tue Jun 24 20:05:12 CEST 2014
Commit: df1c400420b39506e38745bb0db3d4f9797de424
Author: Campbell Barton
Date: Wed Jun 25 04:01:38 2014 +1000
https://developer.blender.org/rBdf1c400420b39506e38745bb0db3d4f9797de424
Use gnu-libc arg order for BLI_sort_r
When building on gnu-libc don't use our own implementation.
===================================================================
M source/blender/blenkernel/intern/navmesh_conversion.c
M source/blender/blenkernel/intern/particle_system.c
M source/blender/blenlib/BLI_sort.h
M source/blender/blenlib/intern/sort.c
===================================================================
diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c
index 64d59b1..8ab9cdd 100644
--- a/source/blender/blenkernel/intern/navmesh_conversion.c
+++ b/source/blender/blenkernel/intern/navmesh_conversion.c
@@ -305,7 +305,7 @@ struct SortContext {
const int *trisToFacesMap;
};
-static int compareByData(void *ctx, const void *a, const void *b)
+static int compareByData(const void *a, const void *b, void *ctx)
{
return (((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int *)a]] -
((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int *)b]]);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 665bf2a..1cc89d5 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1011,7 +1011,7 @@ static void *distribute_threads_exec_cb(void *data)
return 0;
}
-static int distribute_compare_orig_index(void *user_data, const void *p1, const void *p2)
+static int distribute_compare_orig_index(const void *p1, const void *p2, void *user_data)
{
int *orig_index = (int *) user_data;
int index1 = orig_index[*(const int *)p1];
diff --git a/source/blender/blenlib/BLI_sort.h b/source/blender/blenlib/BLI_sort.h
index 4df17d9..0108ae1 100644
--- a/source/blender/blenlib/BLI_sort.h
+++ b/source/blender/blenlib/BLI_sort.h
@@ -33,8 +33,14 @@
* \ingroup bli
*/
+#include <stdlib.h>
+
+#ifdef __GLIBC__
+# define BLI_qsort_r qsort_r
+#endif
+
/* Quick sort reentrant */
-typedef int (*BLI_sort_cmp_t)(void *ctx, const void *a, const void *b);
+typedef int (*BLI_sort_cmp_t)(const void *a, const void *b, void *ctx);
void BLI_qsort_r(void *a, size_t n, size_t es, void *thunk, BLI_sort_cmp_t cmp)
#ifdef __GNUC__
diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c
index a1b7296..9913374 100644
--- a/source/blender/blenlib/intern/sort.c
+++ b/source/blender/blenlib/intern/sort.c
@@ -32,10 +32,13 @@
#include <stdlib.h>
+#ifndef __GLIBC__
+
#include "BLI_utildefines.h"
#include "BLI_sort.h"
+/* note: modified to use glibc arg order for callback */
/* **** qsort based on FreeBSD source (libkern\qsort.c) **** */
BLI_INLINE char *med3(char *, char *, char *, BLI_sort_cmp_t, void *);
BLI_INLINE void swapfunc(char *, char *, int, int);
@@ -72,7 +75,7 @@ BLI_INLINE void swapfunc(char *a, char *b, int n, int swaptype)
swapfunc(a, b, es, swaptype)
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
-#define CMP(t, x, y) (cmp((t), (x), (y)))
+#define CMP(t, x, y) (cmp((x), (y), (t)))
BLI_INLINE char *med3(char *a, char *b, char *c, BLI_sort_cmp_t cmp, void *thunk)
{
@@ -171,3 +174,5 @@ loop:
goto loop;
}
}
+
+#endif /* __GLIBC__ */
More information about the Bf-blender-cvs
mailing list