From 15b71e66797fb4f2705532da0d08bd656b8c621c Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 21 Apr 2009 18:24:59 +0000 Subject: [PATCH] 2009-04-21 Mark Mitchell * libc/include/_ansi.h: Move C++ defines to top of file. (_NOTHROW): New macro. (_EXFUN_NOTHROW): Likewise. * libc/include/stdlib.h (calloc): Declare with _EXFUN_NOTHROW. (free): Likewise. (malloc): Likewise. (realloc): Likewise. (_malloc_r): Likewise. (_callor_r): Likewise. (_free_r): Likewise. (_realloc_r): Likewise. --- newlib/ChangeLog | 14 +++++++++++ newlib/libc/include/_ansi.h | 45 ++++++++++++++++++++++-------------- newlib/libc/include/stdlib.h | 16 ++++++------- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 7e80ce48e..8997c2099 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,17 @@ +2009-04-21 Mark Mitchell + + * libc/include/_ansi.h: Move C++ defines to top of file. + (_NOTHROW): New macro. + (_EXFUN_NOTHROW): Likewise. + * libc/include/stdlib.h (calloc): Declare with _EXFUN_NOTHROW. + (free): Likewise. + (malloc): Likewise. + (realloc): Likewise. + (_malloc_r): Likewise. + (_callor_r): Likewise. + (_free_r): Likewise. + (_realloc_r): Likewise. + 2009-04-20 Jeff johnston * libc/include/math.h: Change _LDBL_EQ_DBL flag usage to diff --git a/newlib/libc/include/_ansi.h b/newlib/libc/include/_ansi.h index 3ece8e184..5b2da4e4b 100644 --- a/newlib/libc/include/_ansi.h +++ b/newlib/libc/include/_ansi.h @@ -23,6 +23,31 @@ #define _HAVE_STDC #endif +/* ISO C++. */ + +#ifdef __cplusplus +#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) +#ifdef _HAVE_STD_CXX +#define _BEGIN_STD_C namespace std { extern "C" { +#define _END_STD_C } } +#else +#define _BEGIN_STD_C extern "C" { +#define _END_STD_C } +#endif +#if defined(__GNUC__) && \ + ( (__GNUC__ >= 4) || \ + ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) +#define _NOTHROW __attribute__ ((nothrow)) +#else +#define _NOTHROW throw() +#endif +#endif +#else +#define _BEGIN_STD_C +#define _END_STD_C +#define _NOTHROW +#endif + #ifdef _HAVE_STDC #define _PTR void * #define _AND , @@ -33,9 +58,11 @@ #define _DOTS , ... #define _VOID void #ifdef __CYGWIN__ +#define _EXFUN_NOTHROW(name, proto) __cdecl name proto _NOTHROW #define _EXFUN(name, proto) __cdecl name proto #define _EXPARM(name, proto) (* __cdecl name) proto #else +#define _EXFUN_NOTHROW(name, proto) name proto _NOTHROW #define _EXFUN(name, proto) name proto #define _EXPARM(name, proto) (* name) proto #endif @@ -61,6 +88,7 @@ #define _DOTS #define _VOID void #define _EXFUN(name, proto) name() +#define _EXFUN_NOTHROW(name, proto) name() #define _DEFUN(name, arglist, args) name arglist args; #define _DEFUN_VOID(name) name() #define _CAST_VOID @@ -100,21 +128,4 @@ #define _ELIDABLE_INLINE __inline__ #endif -/* ISO C++. */ - -#ifdef __cplusplus -#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) -#ifdef _HAVE_STD_CXX -#define _BEGIN_STD_C namespace std { extern "C" { -#define _END_STD_C } } -#else -#define _BEGIN_STD_C extern "C" { -#define _END_STD_C } -#endif -#endif -#else -#define _BEGIN_STD_C -#define _END_STD_C -#endif - #endif /* _ANSIDECL_H_ */ diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h index 5b44bb6e1..7dfb77983 100644 --- a/newlib/libc/include/stdlib.h +++ b/newlib/libc/include/stdlib.h @@ -75,17 +75,17 @@ _PTR _EXFUN(bsearch,(const _PTR __key, size_t __nmemb, size_t __size, int _EXPARM(_compar,(const _PTR, const _PTR)))); -_PTR _EXFUN(calloc,(size_t __nmemb, size_t __size)); +_PTR _EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size)); div_t _EXFUN(div,(int __numer, int __denom)); _VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn))); -_VOID _EXFUN(free,(_PTR)); +_VOID _EXFUN_NOTHROW(free,(_PTR)); char * _EXFUN(getenv,(const char *__string)); char * _EXFUN(_getenv_r,(struct _reent *, const char *__string)); char * _EXFUN(_findenv,(_CONST char *, int *)); char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *)); long _EXFUN(labs,(long)); ldiv_t _EXFUN(ldiv,(long __numer, long __denom)); -_PTR _EXFUN(malloc,(size_t __size)); +_PTR _EXFUN_NOTHROW(malloc,(size_t __size)); int _EXFUN(mblen,(const char *, size_t)); int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *)); int _EXFUN(mbtowc,(wchar_t *, const char *, size_t)); @@ -106,7 +106,7 @@ char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((warning ("the us #endif _VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR))); int _EXFUN(rand,(_VOID)); -_PTR _EXFUN(realloc,(_PTR __r, size_t __size)); +_PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size)); #ifndef __STRICT_ANSI__ _PTR _EXFUN(reallocf,(_PTR __r, size_t __size)); #endif @@ -189,10 +189,10 @@ int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string)); char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**)); #ifndef __CYGWIN__ -_PTR _EXFUN(_malloc_r,(struct _reent *, size_t)); -_PTR _EXFUN(_calloc_r,(struct _reent *, size_t, size_t)); -_VOID _EXFUN(_free_r,(struct _reent *, _PTR)); -_PTR _EXFUN(_realloc_r,(struct _reent *, _PTR, size_t)); +_PTR _EXFUN_NOTHROW(_malloc_r,(struct _reent *, size_t)); +_PTR _EXFUN_NOTHROW(_calloc_r,(struct _reent *, size_t, size_t)); +_VOID _EXFUN_NOTHROW(_free_r,(struct _reent *, _PTR)); +_PTR _EXFUN_NOTHROW(_realloc_r,(struct _reent *, _PTR, size_t)); _VOID _EXFUN(_mstats_r,(struct _reent *, char *)); #endif int _EXFUN(_system_r,(struct _reent *, const char *)); -- 2.43.5