Commit 7c0f3f06 authored by bjaideep's avatar bjaideep Committed by Commit bot

AIX: Work around for malloc(0) behavior

malloc(0) returning 0 is expected behavior on AIX but
compiling with -D_LINUX_SOURCE_COMPAT, malloc(0) should
return a valid pointer (which we do define for AIX). However,
including cstdlib resets the behaviour of _LINUX_SOURCE_COMPAT.
GCC bug: 79839

R=jochen@chromium.org, titzer@chromium.org
BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2732743002
Cr-Commit-Position: refs/heads/master@{#43647}
parent 58ff145e
......@@ -100,7 +100,13 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
#if USE_VM
if (RoundToPageSize(&length)) return VirtualMemoryAllocate(length);
#endif
// Work around for GCC bug on AIX
// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79839
#if V8_OS_AIX && _LINUX_SOURCE_COMPAT
return __linux_malloc(length);
#else
return malloc(length);
#endif
}
virtual void Free(void* data, size_t length) {
#if USE_VM
......
......@@ -110,7 +110,7 @@ class TestingModule : public ModuleEnv {
CHECK_EQ(0, instance->mem_size);
module_.has_memory = true;
instance->mem_start = reinterpret_cast<byte*>(malloc(size));
CHECK(instance->mem_start);
CHECK(size == 0 || instance->mem_start);
memset(instance->mem_start, 0, size);
instance->mem_size = size;
return raw_mem_start<byte>();
......
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