summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Topol <zotthewizard@gmail.com>2019-06-12 18:15:47 -0400
committerAlon Zakai <azakai@google.com>2019-06-12 15:15:47 -0700
commitb2167087ac9d97a6ee024d7ecfc5e29a5bc157f3 (patch)
treeb06800b99075bf3237b8418379974175071a188c
parent284c9357d84165b51e04fa939debddeedbf2eb99 (diff)
downloadbinaryen-b2167087ac9d97a6ee024d7ecfc5e29a5bc157f3.tar.gz
binaryen-b2167087ac9d97a6ee024d7ecfc5e29a5bc157f3.tar.bz2
binaryen-b2167087ac9d97a6ee024d7ecfc5e29a5bc157f3.zip
Enable compiling on GCC < 5 (#2149)
_ISOC11_SOURCE is the preprocessor flag that specifies whether or not aligned_alloc is defined and exists. While GCC versions lower than 5 do include C++11 and C++14 constructs, they do not include std::aligned_alloc, so this check allows compiling on those versions of GCC by defaulting down to posix_memalign in those situations appropriately.
-rw-r--r--src/support/alloc.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/support/alloc.h b/src/support/alloc.h
index d85cbb0f7..fb5815588 100644
--- a/src/support/alloc.h
+++ b/src/support/alloc.h
@@ -38,7 +38,7 @@ inline void* aligned_malloc(size_t align, size_t size) {
if (errno == ENOMEM)
ret = nullptr;
return ret;
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) || !defined(_ISOC11_SOURCE)
void* ptr;
int result = posix_memalign(&ptr, align, size);
return result == 0 ? ptr : nullptr;