]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix non-__GNUC__ definitions of __inline and __restrict (bug 17721).
authorJoseph Myers <joseph@codesourcery.com>
Tue, 6 Feb 2018 21:48:35 +0000 (21:48 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 6 Feb 2018 21:48:35 +0000 (21:48 +0000)
Bug 17721 reports that the non-__GNUC__ definitions of __inline and
__restrict are suboptimal, in that they are defined to empty when they
could be defined to inline and restrict for appropriate language
versions.  This patch makes those fixes.

Tested for x86_64 (however, I have not done any testing with an actual
non-__GNUC__ compiler and it's likely such compilers may have other
problems with glibc headers).

[BZ #17721]
* misc/sys/cdefs.h [!__GNUC__ && (__cplusplus || (__STDC_VERSION__
&& __STDC_VERSION__ >= 199901L))] (__inline): Define to inline.
[!__GNUC_PREREQ (2,92) && __STDC_VERSION__ && __STDC_VERSION__ >=
199901L] (__restrict): Define to restrict.

ChangeLog
misc/sys/cdefs.h

index e19e415c447c6952f173085ff75b9d6bc44bed96..62e2718fa351fef777fd4794e7bc0628c3a254d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-02-06  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #17721]
+       * misc/sys/cdefs.h [!__GNUC__ && (__cplusplus || (__STDC_VERSION__
+       && __STDC_VERSION__ >= 199901L))] (__inline): Define to inline.
+       [!__GNUC_PREREQ (2,92) && __STDC_VERSION__ && __STDC_VERSION__ >=
+       199901L] (__restrict): Define to restrict.
+
        [BZ #19667]
        * string/testcopy.c: Include <support/support.h>.  Do not include
        <malloc.h>.  Use <support/test-driver.c>.
index af103fdb8aaa5c53c3f8ac424cb453642f2a2ffc..e80a45ca68b42966d0af27da555992a004af4a8a 100644 (file)
 
 #else  /* Not GCC.  */
 
-# define __inline              /* No inline functions.  */
+# if (defined __cplusplus                                              \
+      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
+#  define __inline     inline
+# else
+#  define __inline             /* No inline functions.  */
+# endif
 
 # define __THROW
 # define __THROWNL
 
 /* __restrict is known in EGCS 1.2 and above. */
 #if !__GNUC_PREREQ (2,92)
-# define __restrict    /* Ignore */
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#  define __restrict   restrict
+# else
+#  define __restrict   /* Ignore */
+# endif
 #endif
 
 /* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is