From feb0a69677101f361aaf5dbfcdd8b5a7a827900f Mon Sep 17 00:00:00 2001 From: Andrew Hsieh Date: Tue, 2 Apr 2013 19:48:31 +0800 Subject: [4.8] 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) See 0457b0db02c4b229eab11c01025df948032c31a7 Change-Id: I2e83d544a4ac2f4549de3b41a85e009a0a085476 --- gcc-4.8/gcc/config/i386/pmm_malloc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc-4.8/gcc/config/i386/pmm_malloc.h b/gcc-4.8/gcc/config/i386/pmm_malloc.h index d64cb38a2..ee2d1a02a 100644 --- a/gcc-4.8/gcc/config/i386/pmm_malloc.h +++ b/gcc-4.8/gcc/config/i386/pmm_malloc.h @@ -26,6 +26,7 @@ #include +#if !defined(__ANDROID__) || defined(HAVE_POSIX_MEMALIGN) /* We can't depend on 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 -- cgit v1.2.3