From fa6ec5f26bad5aadedf72bfe62fd6e28bd22b9e4 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Fri, 31 Jul 2015 14:58:49 -0700 Subject: [PATCH] Fix Android build break Android doesn't have `posix_memalign`, detect this case with preprocessor macros and compile accordingly. --- src/autowiring/CreationRulesUnix.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/autowiring/CreationRulesUnix.cpp b/src/autowiring/CreationRulesUnix.cpp index 6eedeb744..210a62e02 100644 --- a/src/autowiring/CreationRulesUnix.cpp +++ b/src/autowiring/CreationRulesUnix.cpp @@ -4,10 +4,14 @@ #include void* autowiring::aligned_malloc(size_t ncb, size_t align) { +#if _POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600 && !defined(__APPLE__) + return memalign(align, ncb); +#else void* pRetVal; - if(posix_memalign(&pRetVal, align, ncb)) + if (posix_memalign(&pRetVal, align, ncb)) return nullptr; return pRetVal; +#endif } void autowiring::aligned_free(void* ptr) {