1 /*===---- mm_malloc.h - Implementation of _mm_malloc and _mm_free ----------===
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 *===-----------------------------------------------------------------------===
10 #ifndef _MM_MALLOC_H_INCLUDED
11 #define _MM_MALLOC_H_INCLUDED
13 #if defined(__powerpc64__) && \
14 (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX))
18 /* We can't depend on <stdlib.h> since the prototype of posix_memalign
19 may not be visible. */
21 extern int posix_memalign(void **, size_t, size_t);
23 extern "C" int posix_memalign(void **, size_t, size_t);
26 static __inline
void *_mm_malloc(size_t __size
, size_t __alignment
) {
27 /* PowerPC64 ELF V2 ABI requires quadword alignment. */
28 size_t __vec_align
= sizeof(__vector
float);
31 if (__alignment
< __vec_align
)
32 __alignment
= __vec_align
;
33 if (posix_memalign(&__ptr
, __alignment
, __size
) == 0)
39 static __inline
void _mm_free(void *__ptr
) { free(__ptr
); }
42 #include_next <mm_malloc.h>
45 #endif /* _MM_MALLOC_H_INCLUDED */