mjQUICKSORT uses std::sort with C++.

fixes #1638

PiperOrigin-RevId: 660887790
Change-Id: Ia3b493feda98b246d963aa749bc81b96c42fddaa
This commit is contained in:
Taylor Howell
2024-08-08 10:23:35 -07:00
committed by Copybara-Service
parent 5383d1cd44
commit 82c27165f2
10 changed files with 151 additions and 28 deletions
+1 -18
View File
@@ -25,29 +25,12 @@
#endif
// IWYU pragma: end_keep
// Sorting and case-insensitive comparison functions.
// Case-insensitive comparison functions.
#ifdef _WIN32
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define mjQUICKSORT(buf, elnum, elsz, func, context) \
qsort_s(buf, elnum, elsz, func, context)
#define quicksortfunc(name, context, el1, el2) \
static int name(void* context, const void* el1, const void* el2)
#else // assumes POSIX
#include <strings.h>
#ifdef __APPLE__
#define mjQUICKSORT(buf, elnum, elsz, func, context) \
qsort_r(buf, elnum, elsz, context, func)
#define quicksortfunc(name, context, el1, el2) \
static int name(void* context, const void* el1, const void* el2)
#else // non-Apple
#define mjQUICKSORT(buf, elnum, elsz, func, context) \
qsort_r(buf, elnum, elsz, func, context)
#define quicksortfunc(name, context, el1, el2) \
static int name(const void* el1, const void* el2, void* context)
#endif
#endif
// Switch-case fallthrough annotation.