ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mm_malloc.h
Go to the documentation of this file.
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-exception
6 *
7 *===-----------------------------------------------------------------------===
8 */
9
10#ifndef _MM_MALLOC_H_INCLUDED
11#define _MM_MALLOC_H_INCLUDED
12
13#if defined(__linux__) && defined(__ppc64__)
14
15#include <stdlib.h>
16
17/* We can't depend on <stdlib.h> since the prototype of posix_memalign
18 may not be visible. */
19#ifndef __cplusplus
20extern int posix_memalign (void **, size_t, size_t);
21#else
22extern "C" int posix_memalign (void **, size_t, size_t) throw ();
23#endif
24
25static __inline void *
26_mm_malloc (size_t size, size_t alignment)
27{
28 /* PowerPC64 ELF V2 ABI requires quadword alignment. */
29 size_t vec_align = sizeof (__vector float);
30 void *ptr;
31
32 if (alignment < vec_align)
33 alignment = vec_align;
34 if (posix_memalign (&ptr, alignment, size) == 0)
35 return ptr;
36 else
37 return NULL;
38}
39
40static __inline void
41_mm_free (void * ptr)
42{
43 free (ptr);
44}
45
46#else
47#include_next <mm_malloc.h>
48#endif
49
50#endif /* _MM_MALLOC_H_INCLUDED */
__device__ float
int posix_memalign(void **__memptr, size_t __alignment, size_t __size)
#define NULL