From 2a868d76457840c145bb98305249b8a235b065d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sun, 26 Jul 2015 10:09:22 +0200 Subject: [PATCH] glibc: replace extern __inline with __extern_inline. * this helps to comply with C99. As a reminder, some of these headers are also used by x86_gcc2 src/libs/stdc++. --- src/system/libroot/posix/glibc/ctype/ctype.h | 4 +-- .../libroot/posix/glibc/include/allocalim.h | 2 +- .../include/arch/x86_64/bits/mathinline.h | 4 +-- .../libroot/posix/glibc/include/bits/stdio.h | 2 +- .../posix/glibc/include/misc/sys/cdefs.h | 32 +++++++++++++++++++ src/system/libroot/posix/glibc/stdlib/gmp.h | 4 ++- .../libroot/posix/glibc/stdlib/stdlib.h | 26 +++++++-------- .../libroot/posix/glibc/string/bits/string2.h | 2 +- src/system/libroot/posix/glibc/wcsmbs/wchar.h | 14 ++++---- 9 files changed, 62 insertions(+), 28 deletions(-) diff --git a/src/system/libroot/posix/glibc/ctype/ctype.h b/src/system/libroot/posix/glibc/ctype/ctype.h index f92fa2b6b5..adffe76cb0 100644 --- a/src/system/libroot/posix/glibc/ctype/ctype.h +++ b/src/system/libroot/posix/glibc/ctype/ctype.h @@ -164,13 +164,13 @@ __exctype (_tolower); # endif # ifdef __USE_EXTERN_INLINES -extern __inline int +__extern_inline int tolower (int __c) __THROW { return __c >= -128 && __c < 256 ? __ctype_tolower[__c] : __c; } -extern __inline int +__extern_inline int toupper (int __c) __THROW { return __c >= -128 && __c < 256 ? __ctype_toupper[__c] : __c; diff --git a/src/system/libroot/posix/glibc/include/allocalim.h b/src/system/libroot/posix/glibc/include/allocalim.h index f9bc036bc3..fb2a205a5e 100644 --- a/src/system/libroot/posix/glibc/include/allocalim.h +++ b/src/system/libroot/posix/glibc/include/allocalim.h @@ -1,5 +1,5 @@ #ifndef _EXTERN_INLINE -#define _EXTERN_INLINE extern inline +#define _EXTERN_INLINE __extern_inline #endif _EXTERN_INLINE int __libc_use_alloca (size_t size) { diff --git a/src/system/libroot/posix/glibc/include/arch/x86_64/bits/mathinline.h b/src/system/libroot/posix/glibc/include/arch/x86_64/bits/mathinline.h index 80f6d6453e..a5c7c405b1 100644 --- a/src/system/libroot/posix/glibc/include/arch/x86_64/bits/mathinline.h +++ b/src/system/libroot/posix/glibc/include/arch/x86_64/bits/mathinline.h @@ -22,10 +22,10 @@ #define __NTH(fct) __attribute__ ((__nothrow__)) fct -#ifdef __cplusplus +#ifndef __extern_always_inline # define __MATH_INLINE __inline #else -# define __MATH_INLINE extern __inline +# define __MATH_INLINE __extern_always_inline #endif diff --git a/src/system/libroot/posix/glibc/include/bits/stdio.h b/src/system/libroot/posix/glibc/include/bits/stdio.h index 118118adce..387da3c4b0 100644 --- a/src/system/libroot/posix/glibc/include/bits/stdio.h +++ b/src/system/libroot/posix/glibc/include/bits/stdio.h @@ -24,7 +24,7 @@ #ifdef __cplusplus # define __STDIO_INLINE inline #else -# define __STDIO_INLINE extern __inline +# define __STDIO_INLINE __extern_inline #endif diff --git a/src/system/libroot/posix/glibc/include/misc/sys/cdefs.h b/src/system/libroot/posix/glibc/include/misc/sys/cdefs.h index 18143058fa..f4aa3d76c6 100644 --- a/src/system/libroot/posix/glibc/include/misc/sys/cdefs.h +++ b/src/system/libroot/posix/glibc/include/misc/sys/cdefs.h @@ -226,6 +226,38 @@ # define __attribute_format_strfmon__(a,b) /* Ignore */ #endif + +/* Forces a function to be always inlined. */ +#if __GNUC_PREREQ (3,2) +# define __always_inline __inline __attribute__ ((__always_inline__)) +#else +# define __always_inline __inline +#endif + +/* Associate error messages with the source location of the call site rather + than with the source location inside the function. */ +#if __GNUC_PREREQ (4,3) +# define __attribute_artificial__ __attribute__ ((__artificial__)) +#else +# define __attribute_artificial__ /* Ignore */ +#endif + +/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 + inline semantics, unless -fgnu89-inline is used. */ +#if !defined __cplusplus || __GNUC_PREREQ (4,3) +# if defined __GNUC_STDC_INLINE__ || defined __cplusplus +# define __extern_inline extern __inline __attribute__ ((__gnu_inline__)) +# define __extern_always_inline \ + extern __always_inline __attribute__ ((__gnu_inline__)) +# else +# define __extern_inline extern __inline +# define __extern_always_inline extern __always_inline +# endif +#else +# define __extern_inline extern __inline +#endif + + /* It is possible to compile containing GCC extensions even if GCC is run in pedantic mode if the uses are carefully marked using the `__extension__' keyword. But this is not generally available before diff --git a/src/system/libroot/posix/glibc/stdlib/gmp.h b/src/system/libroot/posix/glibc/stdlib/gmp.h index 0ecc6d1024..c9eb744dc8 100644 --- a/src/system/libroot/posix/glibc/stdlib/gmp.h +++ b/src/system/libroot/posix/glibc/stdlib/gmp.h @@ -21,6 +21,8 @@ MA 02111-1307, USA. */ #ifndef __GMP_H__ +#include + #ifndef __GNU_MP__ #define __GNU_MP__ 2 #define __need_size_t @@ -41,7 +43,7 @@ MA 02111-1307, USA. */ #ifndef _EXTERN_INLINE #ifdef __GNUC__ -#define _EXTERN_INLINE extern __inline__ +#define _EXTERN_INLINE __extern_inline #else #define _EXTERN_INLINE static #endif diff --git a/src/system/libroot/posix/glibc/stdlib/stdlib.h b/src/system/libroot/posix/glibc/stdlib/stdlib.h index 6d175df441..a38d7010db 100644 --- a/src/system/libroot/posix/glibc/stdlib/stdlib.h +++ b/src/system/libroot/posix/glibc/stdlib/stdlib.h @@ -306,18 +306,18 @@ extern unsigned long long int __strtoull_internal (__const char * /* Define inline functions which call the internal entry points. */ __BEGIN_NAMESPACE_STD -extern __inline double +__extern_inline double strtod (__const char *__restrict __nptr, char **__restrict __endptr) __THROW { return __strtod_internal (__nptr, __endptr, 0); } -extern __inline long int +__extern_inline long int strtol (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW { return __strtol_internal (__nptr, __endptr, __base, 0); } -extern __inline unsigned long int +__extern_inline unsigned long int strtoul (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW { @@ -327,12 +327,12 @@ __END_NAMESPACE_STD # ifdef __USE_ISOC99 __BEGIN_NAMESPACE_C99 -extern __inline float +__extern_inline float strtof (__const char *__restrict __nptr, char **__restrict __endptr) __THROW { return __strtof_internal (__nptr, __endptr, 0); } -extern __inline long double +__extern_inline long double strtold (__const char *__restrict __nptr, char **__restrict __endptr) __THROW { return __strtold_internal (__nptr, __endptr, 0); @@ -341,13 +341,13 @@ __END_NAMESPACE_C99 # endif # ifdef __USE_BSD -__extension__ extern __inline long long int +__extension__ __extern_inline long long int strtoq (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW { return __strtoll_internal (__nptr, __endptr, __base, 0); } -__extension__ extern __inline unsigned long long int +__extension__ __extern_inline unsigned long long int strtouq (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW { @@ -357,13 +357,13 @@ strtouq (__const char *__restrict __nptr, char **__restrict __endptr, # if defined __USE_MISC || defined __USE_ISOC99 __BEGIN_NAMESPACE_C99 -__extension__ extern __inline long long int +__extension__ __extern_inline long long int strtoll (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW { return __strtoll_internal (__nptr, __endptr, __base, 0); } -__extension__ extern __inline unsigned long long int +__extension__ __extern_inline unsigned long long int strtoull (__const char * __restrict __nptr, char **__restrict __endptr, int __base) __THROW { @@ -373,17 +373,17 @@ __END_NAMESPACE_C99 # endif __BEGIN_NAMESPACE_STD -extern __inline double +__extern_inline double atof (__const char *__nptr) __THROW { return strtod (__nptr, (char **) NULL); } -extern __inline int +__extern_inline int atoi (__const char *__nptr) __THROW { return (int) strtol (__nptr, (char **) NULL, 10); } -extern __inline long int +__extern_inline long int atol (__const char *__nptr) __THROW { return strtol (__nptr, (char **) NULL, 10); @@ -392,7 +392,7 @@ __END_NAMESPACE_STD # if defined __USE_MISC || defined __USE_ISOC99 __BEGIN_NAMESPACE_C99 -__extension__ extern __inline long long int +__extension__ __extern_inline long long int atoll (__const char *__nptr) __THROW { return strtoll (__nptr, (char **) NULL, 10); diff --git a/src/system/libroot/posix/glibc/string/bits/string2.h b/src/system/libroot/posix/glibc/string/bits/string2.h index a02b0558f1..29c91964a7 100644 --- a/src/system/libroot/posix/glibc/string/bits/string2.h +++ b/src/system/libroot/posix/glibc/string/bits/string2.h @@ -43,7 +43,7 @@ # ifdef __cplusplus # define __STRING_INLINE inline # else -# define __STRING_INLINE extern __inline +# define __STRING_INLINE __extern_inline # endif #endif diff --git a/src/system/libroot/posix/glibc/wcsmbs/wchar.h b/src/system/libroot/posix/glibc/wcsmbs/wchar.h index de2b5ab24a..579e74c922 100644 --- a/src/system/libroot/posix/glibc/wcsmbs/wchar.h +++ b/src/system/libroot/posix/glibc/wcsmbs/wchar.h @@ -218,34 +218,34 @@ extern unsigned long long int __wcstoull_internal (__const wchar_t * #if defined __OPTIMIZE__ && __GNUC__ >= 2 /* Define inline functions which call the internal entry points. */ -extern __inline double wcstod (__const wchar_t *__restrict __nptr, +__extern_inline double wcstod (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW { return __wcstod_internal (__nptr, __endptr, 0); } -extern __inline long int wcstol (__const wchar_t *__restrict __nptr, +__extern_inline long int wcstol (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) __THROW { return __wcstol_internal (__nptr, __endptr, __base, 0); } -extern __inline unsigned long int wcstoul (__const wchar_t *__restrict __nptr, +__extern_inline unsigned long int wcstoul (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) __THROW { return __wcstoul_internal (__nptr, __endptr, __base, 0); } # ifdef __USE_GNU -extern __inline float wcstof (__const wchar_t *__restrict __nptr, +__extern_inline float wcstof (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW { return __wcstof_internal (__nptr, __endptr, 0); } -extern __inline long double wcstold (__const wchar_t *__restrict __nptr, +__extern_inline long double wcstold (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW { return __wcstold_internal (__nptr, __endptr, 0); } __extension__ -extern __inline long long int wcstoq (__const wchar_t *__restrict __nptr, +__extern_inline long long int wcstoq (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base) __THROW { return __wcstoll_internal (__nptr, __endptr, __base, 0); } __extension__ -extern __inline unsigned long long int wcstouq (__const wchar_t * +__extern_inline unsigned long long int wcstouq (__const wchar_t * __restrict __nptr, wchar_t **__restrict __endptr, int __base) __THROW