path: root/gcc-4.6
diff options
authorAndrew Hsieh <andrewhsieh@google.com>2013-02-20 16:17:40 +0800
committerAndrew Hsieh <andrewhsieh@google.com>2013-02-20 16:17:40 +0800
commit0457b0db02c4b229eab11c01025df948032c31a7 (patch)
tree392a5cfdd4ce74500bf66a9fe36f4cd96d80c324 /gcc-4.6
parent67a559de3736deb9b9912d89ca22149922a4894c (diff)
Use memalign instead of posix_memalign in GCC x86 mm_malloc.h
posix_memalign doesn't exist in NDK. Code inludes ?mmintrin.h which in turn includes mm_malloc.h may fail to link For AOSP platform build which uses the same compiler, add -DHAVE_POSIX_MEMALIGN to restore the original behavior. Other than non-zero return value which _mm_alloc already ignores, both paths are functioanlly identical (under the hood dlmalloc.c in 32-bit ensure alignment is at least 16-byte) Change-Id: I55e9bb8b80e1b55baa9744920df10fcf83218300
Diffstat (limited to 'gcc-4.6')
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc-4.6/gcc/config/i386/pmm_malloc.h b/gcc-4.6/gcc/config/i386/pmm_malloc.h
index 0a9f2e2..fcc0f80 100644
--- a/gcc-4.6/gcc/config/i386/pmm_malloc.h
+++ b/gcc-4.6/gcc/config/i386/pmm_malloc.h
@@ -26,6 +26,7 @@
#include <stdlib.h>
+#if !defined(__ANDROID__) || defined(HAVE_POSIX_MEMALIGN)
/* We can't depend on <stdlib.h> since the prototype of posix_memalign
may not be visible. */
#ifndef __cplusplus
@@ -33,6 +34,7 @@ extern int posix_memalign (void **, size_t, size_t);
extern "C" int posix_memalign (void **, size_t, size_t) throw ();
static __inline void *
_mm_malloc (size_t size, size_t alignment)
@@ -42,10 +44,14 @@ _mm_malloc (size_t size, size_t alignment)
return malloc (size);
if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4))
alignment = sizeof (void *);
+#if !defined(__ANDROID__) || defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign (&ptr, alignment, size) == 0)
return ptr;
return NULL;
+ return memalign(alignment, size);
static __inline void