diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-10-16 18:45:24 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-10-16 18:45:24 +0000 |
commit | 5eceb3958ee6cb42d57d4fe52dd76fb03b178edf (patch) | |
tree | fcddcedf0dc6b3aab54a8f7e85d619e574aa0e11 /newlib/libc | |
parent | 71c13b96338eeb7021c211c1819cba700e85b61c (diff) | |
download | newlib-5eceb3958ee6cb42d57d4fe52dd76fb03b178edf.zip newlib-5eceb3958ee6cb42d57d4fe52dd76fb03b178edf.tar.gz newlib-5eceb3958ee6cb42d57d4fe52dd76fb03b178edf.tar.bz2 |
* libc/include/sys/features.h (__GNUC_PREREQ): Define. Use
throughout in place of explicit GNUC version checks.
* libc/include/_ansi.h (_NOINLINE): Define.
(_NOINLINE_STATIC): Define.
* libc/stdio/vfprintf.c (__sbprintf): Define _NOINLINE_STATIC.
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/include/_ansi.h | 14 | ||||
-rw-r--r-- | newlib/libc/include/machine/_default_types.h | 3 | ||||
-rw-r--r-- | newlib/libc/include/math.h | 5 | ||||
-rw-r--r-- | newlib/libc/include/stdint.h | 6 | ||||
-rw-r--r-- | newlib/libc/include/sys/features.h | 10 | ||||
-rw-r--r-- | newlib/libc/include/tgmath.h | 3 | ||||
-rw-r--r-- | newlib/libc/posix/engine.c | 4 | ||||
-rw-r--r-- | newlib/libc/stdio/vfprintf.c | 4 | ||||
-rw-r--r-- | newlib/libc/string/strcasestr.c | 3 |
9 files changed, 33 insertions, 19 deletions
diff --git a/newlib/libc/include/_ansi.h b/newlib/libc/include/_ansi.h index 86cb82b..c5597b3 100644 --- a/newlib/libc/include/_ansi.h +++ b/newlib/libc/include/_ansi.h @@ -34,9 +34,7 @@ #define _BEGIN_STD_C extern "C" { #define _END_STD_C } #endif -#if defined(__GNUC__) && \ - ( (__GNUC__ >= 4) || \ - ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) +#if __GNUC_PREREQ (3, 3) #define _NOTHROW __attribute__ ((nothrow)) #else #define _NOTHROW throw() @@ -133,4 +131,14 @@ #define _ELIDABLE_INLINE static __inline__ #endif +#if __GNUC_PREREQ (3, 1) +#define _NOINLINE __attribute__ ((__noinline__)) +#define _NOINLINE_STATIC _NOINLINE static +#else +/* On non-GNU compilers and GCC prior to version 3.1 the compiler can't be + trusted not to inline if it is static. */ +#define _NOINLINE +#define _NOINLINE_STATIC +#endif + #endif /* _ANSIDECL_H_ */ diff --git a/newlib/libc/include/machine/_default_types.h b/newlib/libc/include/machine/_default_types.h index e79f993..362e079 100644 --- a/newlib/libc/include/machine/_default_types.h +++ b/newlib/libc/include/machine/_default_types.h @@ -12,8 +12,7 @@ extern "C" { /* * Guess on types by examining *_MIN / *_MAX defines. */ -#if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ >= 3 ) \ - && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 )) +#if __GNUC_PREREQ (3, 3) /* GCC >= 3.3.0 has __<val>__ implicitly defined. */ #define __EXP(x) __##x##__ #else diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index 9e60414..e9328c5 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -34,10 +34,7 @@ union __ldmath /* Natural log of 2 */ #define _M_LN2 0.693147180559945309417 -#if defined(__GNUC__) && \ - ( (__GNUC__ >= 4) || \ - ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) - +#if __GNUC_PREREQ (3, 3) /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ # ifndef HUGE_VAL diff --git a/newlib/libc/include/stdint.h b/newlib/libc/include/stdint.h index 94759e9..d0374ae 100644 --- a/newlib/libc/include/stdint.h +++ b/newlib/libc/include/stdint.h @@ -9,13 +9,13 @@ #ifndef _STDINT_H #define _STDINT_H +#include <_ansi.h> + #ifdef __cplusplus extern "C" { #endif -#if defined(__GNUC__) && \ - ( (__GNUC__ >= 4) || \ - ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) ) +#if __GNUC_PREREQ (3, 2) /* gcc > 3.2 implicitly defines the values we are interested */ #define __STDINT_EXP(x) __##x##__ #else diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h index e7f9c65..f150706 100644 --- a/newlib/libc/include/sys/features.h +++ b/newlib/libc/include/sys/features.h @@ -25,6 +25,16 @@ extern "C" { #endif +/* Macro to test version of GCC. Returns 0 for non-GCC or too old GCC. */ +#ifndef __GNUC_PREREQ +# if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +# else +# define __GNUC_PREREQ(maj, min) 0 +# endif +#endif /* __GNUC_PREREQ */ + /* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */ #ifdef __rtems__ diff --git a/newlib/libc/include/tgmath.h b/newlib/libc/include/tgmath.h index 52fb886..f9c8311 100644 --- a/newlib/libc/include/tgmath.h +++ b/newlib/libc/include/tgmath.h @@ -58,8 +58,7 @@ */ /* requires GCC >= 3.1 */ -#if !defined(__GNUC__) || __GNUC__ < 3 || \ - (__GNUC__ == 3 && __GNUC_MINOR__ < 1) +#if !__GNUC_PREREQ (3, 1) #error "<tgmath.h> not implemented for this compiler" #endif diff --git a/newlib/libc/posix/engine.c b/newlib/libc/posix/engine.c index 73ce45c..c80834a 100644 --- a/newlib/libc/posix/engine.c +++ b/newlib/libc/posix/engine.c @@ -34,6 +34,7 @@ */ #include <sys/cdefs.h> +#include <_ansi.h> /* * The matching engine and friends. This file is #included by regexec.c @@ -364,8 +365,7 @@ sopno stopst; char *ssp; /* start of string matched by subsubRE */ char *sep; /* end of string matched by subsubRE */ char *oldssp; /* previous ssp */ -#if defined (__GNUC__) && \ - ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#if __GNUC_PREREQ (4, 6) /* dp is only used for assertion testing which, for some reason, is not recognized as usage. */ #pragma GCC diagnostic ignored "-Wunused-but-set-variable" diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 4b165e0..6dfa9c8 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -333,8 +333,10 @@ int __sprint_r (struct _reent *, FILE *, register struct __suio *); * Helper function for `fprintf to unbuffered unix file': creates a * temporary buffer. We only work on write-only files; this avoids * worries about ungetc buffers and so forth. + * + * Make sure to avoid inlining when optimizing for size. */ -static int +_NOINLINE_STATIC int _DEFUN(__sbprintf, (rptr, fp, fmt, ap), struct _reent *rptr _AND register FILE *fp _AND diff --git a/newlib/libc/string/strcasestr.c b/newlib/libc/string/strcasestr.c index 9178316..1bde1cd 100644 --- a/newlib/libc/string/strcasestr.c +++ b/newlib/libc/string/strcasestr.c @@ -84,8 +84,7 @@ QUICKREF (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ && ((h_l) = (j) + (n_l))) # define CANON_ELEMENT(c) tolower (c) -#if defined (__GNUC__) && \ - ((__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || __GNUC__ > 4) +#if __GNUC_PREREQ (4, 2) /* strncasecmp uses signed char, CMP_FUNC is expected to use unsigned char. */ #pragma GCC diagnostic ignored "-Wpointer-sign" #endif |