1*2f055536Smrg /* Copyright (C) 2004-2020 Free Software Foundation, Inc.
2c3d31fe1Smrg 
3c3d31fe1Smrg    This file is part of GCC.
4c3d31fe1Smrg 
5c3d31fe1Smrg    GCC is free software; you can redistribute it and/or modify
6c3d31fe1Smrg    it under the terms of the GNU General Public License as published by
7c3d31fe1Smrg    the Free Software Foundation; either version 3, or (at your option)
8c3d31fe1Smrg    any later version.
9c3d31fe1Smrg 
10c3d31fe1Smrg    GCC is distributed in the hope that it will be useful,
11c3d31fe1Smrg    but WITHOUT ANY WARRANTY; without even the implied warranty of
12c3d31fe1Smrg    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13c3d31fe1Smrg    GNU General Public License for more details.
14c3d31fe1Smrg 
15c3d31fe1Smrg    Under Section 7 of GPL version 3, you are granted additional
16c3d31fe1Smrg    permissions described in the GCC Runtime Library Exception, version
17c3d31fe1Smrg    3.1, as published by the Free Software Foundation.
18c3d31fe1Smrg 
19c3d31fe1Smrg    You should have received a copy of the GNU General Public License and
20c3d31fe1Smrg    a copy of the GCC Runtime Library Exception along with this program;
21c3d31fe1Smrg    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
22c3d31fe1Smrg    <http://www.gnu.org/licenses/>.  */
23c3d31fe1Smrg 
24c3d31fe1Smrg #ifndef _MM_MALLOC_H_INCLUDED
25c3d31fe1Smrg #define _MM_MALLOC_H_INCLUDED
26c3d31fe1Smrg 
27c3d31fe1Smrg #include <stdlib.h>
28c3d31fe1Smrg 
29c3d31fe1Smrg /* We can't depend on <stdlib.h> since the prototype of posix_memalign
30c3d31fe1Smrg    may not be visible.  */
31c3d31fe1Smrg #ifndef __cplusplus
32c3d31fe1Smrg extern int posix_memalign (void **, size_t, size_t);
33c3d31fe1Smrg #else
34ed5fbaebSmartin extern "C" int posix_memalign (void **, size_t, size_t);
35c3d31fe1Smrg #endif
36c3d31fe1Smrg 
37c3d31fe1Smrg static __inline void *
_mm_malloc(size_t __size,size_t __alignment)38d8e5147aSmrg _mm_malloc (size_t __size, size_t __alignment)
39c3d31fe1Smrg {
40d8e5147aSmrg   void *__ptr;
41d8e5147aSmrg   if (__alignment == 1)
42d8e5147aSmrg     return malloc (__size);
43d8e5147aSmrg   if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
44d8e5147aSmrg     __alignment = sizeof (void *);
45d8e5147aSmrg   if (posix_memalign (&__ptr, __alignment, __size) == 0)
46d8e5147aSmrg     return __ptr;
47c3d31fe1Smrg   else
48c3d31fe1Smrg     return NULL;
49c3d31fe1Smrg }
50c3d31fe1Smrg 
51c3d31fe1Smrg static __inline void
_mm_free(void * __ptr)52d8e5147aSmrg _mm_free (void *__ptr)
53c3d31fe1Smrg {
54d8e5147aSmrg   free (__ptr);
55c3d31fe1Smrg }
56c3d31fe1Smrg 
57c3d31fe1Smrg #endif /* _MM_MALLOC_H_INCLUDED */
58