[flang][cuda] Do not register global constants (#118582)
[llvm-project.git] / clang / lib / Headers / ppc_wrappers / mm_malloc.h
blob7c1e625e44d511f7c82218be95a589d86bfc5d4f
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 *===-----------------------------------------------------------------------===
8 */
10 #ifndef _MM_MALLOC_H_INCLUDED
11 #define _MM_MALLOC_H_INCLUDED
13 #if defined(__powerpc64__) && \
14 (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX))
16 #include <stdlib.h>
18 /* We can't depend on <stdlib.h> since the prototype of posix_memalign
19 may not be visible. */
20 #ifndef __cplusplus
21 extern int posix_memalign(void **, size_t, size_t);
22 #else
23 extern "C" int posix_memalign(void **, size_t, size_t);
24 #endif
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);
29 void *__ptr;
31 if (__alignment < __vec_align)
32 __alignment = __vec_align;
33 if (posix_memalign(&__ptr, __alignment, __size) == 0)
34 return __ptr;
35 else
36 return NULL;
39 static __inline void _mm_free(void *__ptr) { free(__ptr); }
41 #else
42 #include_next <mm_malloc.h>
43 #endif
45 #endif /* _MM_MALLOC_H_INCLUDED */