diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2013-02-20 14:56:54 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2013-02-20 16:12:33 +0800 |
commit | 03732dc8db08a1ff13ac97ec7a9e47d50b35f062 (patch) | |
tree | 2f2d42307e0e035290a447929d0e5204cfa8b441 | |
parent | a7a9ac7f39ddb1999b1851af5c75852847bc365b (diff) | |
download | i686-linux-android-4.7-03732dc8db08a1ff13ac97ec7a9e47d50b35f062.tar.gz |
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: I723fdfe6afe4bdccf73e88780d65e17ce2ddafb5
-rw-r--r-- | lib/gcc/i686-linux-android/4.7/include/mm_malloc.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gcc/i686-linux-android/4.7/include/mm_malloc.h b/lib/gcc/i686-linux-android/4.7/include/mm_malloc.h index 0a9f2e2..fcc0f80 100644 --- a/lib/gcc/i686-linux-android/4.7/include/mm_malloc.h +++ b/lib/gcc/i686-linux-android/4.7/include/mm_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); #else extern "C" int posix_memalign (void **, size_t, size_t) throw (); #endif +#endif 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; else return NULL; +#else + return memalign(alignment, size); +#endif } static __inline void |