Check that alignment is power of 2 in mj_stackAlloc.
PiperOrigin-RevId: 562024496 Change-Id: I9230c6dc05ebb78e935f9b2f606aa77c921d67e5
This commit is contained in:
committed by
Copybara-Service
parent
29aa5e4a41
commit
33f51856c1
@@ -25,7 +25,7 @@
|
||||
#endif
|
||||
// IWYU pragma: end_keep
|
||||
|
||||
// Windows
|
||||
// Sorting and case-insensitive comparison functions.
|
||||
#ifdef _WIN32
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
@@ -34,20 +34,15 @@
|
||||
qsort_s(buf, elnum, elsz, func, context)
|
||||
#define quicksortfunc(name, context, el1, el2) \
|
||||
static int name(void* context, const void* el1, const void* el2)
|
||||
|
||||
// Unix-common
|
||||
#else
|
||||
#else // assumes POSIX
|
||||
#include <strings.h>
|
||||
|
||||
// Apple
|
||||
#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)
|
||||
|
||||
// non-Apple
|
||||
#else
|
||||
#else // non-Apple
|
||||
#define mjQUICKSORT(buf, elnum, elsz, func, context) \
|
||||
qsort_r(buf, elnum, elsz, func, context)
|
||||
#define quicksortfunc(name, context, el1, el2) \
|
||||
@@ -55,6 +50,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Switch-case fallthrough annotation.
|
||||
#if defined(__cplusplus)
|
||||
#define mjFALLTHROUGH [[fallthrough]]
|
||||
#elif defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 7)
|
||||
@@ -63,10 +59,20 @@
|
||||
#define mjFALLTHROUGH ((void) 0)
|
||||
#endif
|
||||
|
||||
// MSVC only provides max_align_t in C++.
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && !defined(__cplusplus)
|
||||
typedef long double mjtMaxAlign;
|
||||
#else
|
||||
typedef max_align_t mjtMaxAlign;
|
||||
#endif
|
||||
|
||||
// Branch prediction hints.
|
||||
#if defined(__GNUC__)
|
||||
#define mjLIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#define mjUNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define mjLIKELY(x) (x)
|
||||
#define mjUNLIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
#endif // MUJOCO_SRC_ENGINE_ENGINE_CROSSPLATFORM_H_
|
||||
|
||||
Reference in New Issue
Block a user