brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 7c1e625 Raw
46 lines · c
1/*===---- mm_malloc.h - Implementation of _mm_malloc and _mm_free ----------===2 *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-exception6 *7 *===-----------------------------------------------------------------------===8 */9 10#ifndef _MM_MALLOC_H_INCLUDED11#define _MM_MALLOC_H_INCLUDED12 13#if defined(__powerpc64__) &&                                                  \14    (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX))15 16#include <stdlib.h>17 18/* We can't depend on <stdlib.h> since the prototype of posix_memalign19   may not be visible.  */20#ifndef __cplusplus21extern int posix_memalign(void **, size_t, size_t);22#else23extern "C" int posix_memalign(void **, size_t, size_t);24#endif25 26static __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;30 31  if (__alignment < __vec_align)32    __alignment = __vec_align;33  if (posix_memalign(&__ptr, __alignment, __size) == 0)34    return __ptr;35  else36    return NULL;37}38 39static __inline void _mm_free(void *__ptr) { free(__ptr); }40 41#else42#include_next <mm_malloc.h>43#endif44 45#endif /* _MM_MALLOC_H_INCLUDED */46