clang  9.0.0
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 #include <stdlib.h>
14 
15 /* We can't depend on <stdlib.h> since the prototype of posix_memalign
16  may not be visible. */
17 #ifndef __cplusplus
18 extern int posix_memalign (void **, size_t, size_t);
19 #else
20 extern "C" int posix_memalign (void **, size_t, size_t) throw ();
21 #endif
22 
23 static __inline void *
24 _mm_malloc (size_t size, size_t alignment)
25 {
26  /* PowerPC64 ELF V2 ABI requires quadword alignment. */
27  size_t vec_align = sizeof (__vector float);
28  void *ptr;
29 
30  if (alignment < vec_align)
31  alignment = vec_align;
32  if (posix_memalign (&ptr, alignment, size) == 0)
33  return ptr;
34  else
35  return NULL;
36 }
37 
38 static __inline void
39 _mm_free (void * ptr)
40 {
41  free (ptr);
42 }
43 
44 #endif /* _MM_MALLOC_H_INCLUDED */
int posix_memalign(void **__memptr, size_t __alignment, size_t __size)
#define NULL
static __inline void * _mm_malloc(size_t size, size_t alignment)
Definition: mm_malloc.h:24
static __inline void _mm_free(void *ptr)
Definition: mm_malloc.h:39