malloc_debug: Set default alignment to max_align_t if available.
For it to be available we build malloc_debug in C++11 mode when not using GCC2. Note that max_align_t is not in the std namespace in GCC4 versions prior to GCC 4.9. The extra "using namespace std" is there to be forward compatible once we update.
This commit is contained in:
parent
e25776bd83
commit
abf230a9ac
@ -7,6 +7,10 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
||||
on $(architectureObject) {
|
||||
local architecture = $(TARGET_PACKAGING_ARCH) ;
|
||||
|
||||
if $(architecture) != x86_gcc2 {
|
||||
SubDirC++Flags -std=gnu++11 ;
|
||||
}
|
||||
|
||||
UsePrivateSystemHeaders ;
|
||||
|
||||
MergeObject <$(architecture)>posix_malloc_debug.o :
|
||||
|
@ -19,7 +19,14 @@
|
||||
|
||||
|
||||
static bool sDebuggerCalls = true;
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#include <cstddef>
|
||||
using namespace std;
|
||||
static size_t sDefaultAlignment = alignof(max_align_t);
|
||||
#else
|
||||
static size_t sDefaultAlignment = 0;
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
@ -950,7 +957,7 @@ __init_heap_post_env(void)
|
||||
const char *argument = strchr(mode, 'a');
|
||||
if (argument != NULL
|
||||
&& sscanf(argument, "a%" B_SCNuSIZE, &defaultAlignment) == 1
|
||||
&& defaultAlignment > 0) {
|
||||
&& defaultAlignment >= 0) {
|
||||
heap_debug_set_default_alignment(defaultAlignment);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,14 @@ static bool sParanoidValidation = false;
|
||||
static thread_id sWallCheckThread = -1;
|
||||
static bool sStopWallChecking = false;
|
||||
static bool sUseGuardPage = false;
|
||||
static bool sDefaultAlignment = 0;
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#include <cstddef>
|
||||
using namespace std;
|
||||
static size_t sDefaultAlignment = alignof(max_align_t);
|
||||
#else
|
||||
static size_t sDefaultAlignment = 0;
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
@ -1852,7 +1859,7 @@ __init_heap_post_env(void)
|
||||
const char *argument = strchr(mode, 'a');
|
||||
if (argument != NULL
|
||||
&& sscanf(argument, "a%" B_SCNuSIZE, &defaultAlignment) == 1
|
||||
&& defaultAlignment > 0) {
|
||||
&& defaultAlignment >= 0) {
|
||||
heap_debug_set_default_alignment(defaultAlignment);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user