diff options
Diffstat (limited to 'localedef')
-rw-r--r-- | localedef/ChangeLog.eglibc | 8 | ||||
-rw-r--r-- | localedef/include/programs/xmalloc.h | 33 | ||||
-rw-r--r-- | localedef/include/sys/cdefs.h | 19 |
3 files changed, 56 insertions, 4 deletions
diff --git a/localedef/ChangeLog.eglibc b/localedef/ChangeLog.eglibc index 558737022..a63708fa9 100644 --- a/localedef/ChangeLog.eglibc +++ b/localedef/ChangeLog.eglibc @@ -1,3 +1,11 @@ +2013-03-06 Joseph Myers <joseph@codesourcery.com> + + * include/sys/cdefs.h (__attribute_malloc__): Define if not + already defined. + (__attribute_alloc_size): Change to __attribute_alloc_size__. + Define if not already defined. + * include/programs/xmalloc.h: Copy from glibc. + 2013-01-23 Joseph Myers <joseph@codesourcery.com> * configure.ac: Use AC_USE_SYSTEM_EXTENSIONS. diff --git a/localedef/include/programs/xmalloc.h b/localedef/include/programs/xmalloc.h new file mode 100644 index 000000000..f4278852b --- /dev/null +++ b/localedef/include/programs/xmalloc.h @@ -0,0 +1,33 @@ +/* Memory related definitions for program modules. + Copyright (C) 1998-2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. */ + +#ifndef _XMALLOC_H +#define _XMALLOC_H 1 + +#include <sys/cdefs.h> +#include <stddef.h> + +/* Prototypes for a few program-wide used functions. */ +extern void *xmalloc (size_t n) + __attribute_malloc__ __attribute_alloc_size__ ((1)); +extern void *xcalloc (size_t n, size_t s) + __attribute_malloc__ __attribute_alloc_size__ ((1, 2)); +extern void *xrealloc (void *o, size_t n) + __attribute_malloc__ __attribute_alloc_size__ ((2)); +extern char *xstrdup (const char *) __attribute_malloc__; + +#endif /* xmalloc.h */ diff --git a/localedef/include/sys/cdefs.h b/localedef/include/sys/cdefs.h index aa1c34be1..e6bdff1f2 100644 --- a/localedef/include/sys/cdefs.h +++ b/localedef/include/sys/cdefs.h @@ -47,9 +47,20 @@ # endif #endif -#if defined(__GNUC__) \ +#ifndef __attribute_malloc__ +# if defined(__GNUC__) \ + && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) +# define __attribute_malloc__ __attribute__ ((__malloc__)) +# else +# define __attribute_malloc__ /* Ignore */ +# endif +#endif + +#ifndef __attribute_alloc_size__ +# if defined(__GNUC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) -# define __attribute_alloc_size(...) __attribute__ ((alloc_size (__VA_ARGS__))) -#else -# define __attribute_alloc_size(...) +# define __attribute_alloc_size__(...) __attribute__ ((alloc_size (__VA_ARGS__))) +# else +# define __attribute_alloc_size__(...) +# endif #endif |