Commit 8d5b6365 authored by Oleg Kolosov's avatar Oleg Kolosov

Use __BIONIC__ feature test macro instead of _ISOC11_SOURCE and __ANDROID__

Have not found a universal way to detect C11 and after some deliberation
__BIONIC__ seems to be a better choice for these cases.
parent f015a9c0
......@@ -72,8 +72,8 @@ namespace {
#undef SEEK_HOLE
#endif
#if __ANDROID__
// no DTTOIF function
#if __BIONIC__
// No no DTTOIF function
#undef DT_UNKNOWN
#endif
......
......@@ -288,27 +288,27 @@ void BTreeImpl::growTree(uint minCapacity) {
// aligned_alloc() function. Unfortunately, many platforms don't implement it. Luckily, there
// are usually alternatives.
#if _WIN32
#if __APPLE__ || __BIONIC__
// OSX and Android lack aligned_alloc(), but have posix_memalign(). Fine.
void* allocPtr;
int error = posix_memalign(&allocPtr,
sizeof(BTreeImpl::NodeUnion), newCapacity * sizeof(BTreeImpl::NodeUnion));
if (error != 0) {
KJ_FAIL_SYSCALL("posix_memalign", error);
}
NodeUnion* newTree = reinterpret_cast<NodeUnion*>(allocPtr);
#elif _WIN32
// Windows lacks aligned_alloc() but has its own _aligned_malloc() (which requires freeing using
// _aligned_free()).
// WATCH OUT: The argument order for _aligned_malloc() is opposite of aligned_alloc()!
NodeUnion* newTree = reinterpret_cast<NodeUnion*>(
_aligned_malloc(newCapacity * sizeof(BTreeImpl::NodeUnion), sizeof(BTreeImpl::NodeUnion)));
KJ_ASSERT(newTree != nullptr, "memory allocation failed", newCapacity);
#elif _ISOC11_SOURCE // macro available since glibc 2.16
#else
// Let's use the C11 standard.
NodeUnion* newTree = reinterpret_cast<NodeUnion*>(
aligned_alloc(sizeof(BTreeImpl::NodeUnion), newCapacity * sizeof(BTreeImpl::NodeUnion)));
KJ_ASSERT(newTree != nullptr, "memory allocation failed", newCapacity);
#else
// OSX and Android lack aligned_alloc(), but have posix_memalign(). Fine.
void* allocPtr;
int error = posix_memalign(&allocPtr,
sizeof(BTreeImpl::NodeUnion), newCapacity * sizeof(BTreeImpl::NodeUnion));
if (error != 0) {
KJ_FAIL_SYSCALL("posix_memalign", error);
}
NodeUnion* newTree = reinterpret_cast<NodeUnion*>(allocPtr);
#endif
acopy(newTree, tree, treeCapacity);
......
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