00001 /* Copyright (C) 2004 Free Software Foundation, Inc. 00002 00003 This file is part of GCC. 00004 00005 GCC is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2, or (at your option) 00008 any later version. 00009 00010 GCC is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with GCC; see the file COPYING. If not, write to 00017 the Free Software Foundation, 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. */ 00019 00020 /* As a special exception, if you include this header file into source 00021 files compiled by GCC, this header file does not by itself cause 00022 the resulting executable to be covered by the GNU General Public 00023 License. This exception does not however invalidate any other 00024 reasons why the executable file might be covered by the GNU General 00025 Public License. */ 00026 00027 #ifndef _MM_MALLOC_H_INCLUDED 00028 #define _MM_MALLOC_H_INCLUDED 00029 00030 #include <stdlib.h> 00031 00032 /* We can't depend on <stdlib.h> since the prototype of posix_memalign 00033 may not be visible. */ 00034 extern int posix_memalign (void **, size_t, size_t); 00035 00036 static __inline void * 00037 _mm_malloc (size_t size, size_t alignment) 00038 { 00039 void *ptr; 00040 if (alignment == 1) 00041 return malloc (size); 00042 if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4)) 00043 alignment = sizeof (void *); 00044 if (posix_memalign (&ptr, alignment, size) == 0) 00045 return ptr; 00046 else 00047 return NULL; 00048 } 00049 00050 static __inline void 00051 _mm_free (void * ptr) 00052 { 00053 free (ptr); 00054 } 00055 00056 #endif /* _MM_MALLOC_H_INCLUDED */
1.5.6