]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
libc-config: port better to Fedora Rawhide
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 22 Apr 2021 19:29:49 +0000 (12:29 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 22 Apr 2021 19:30:14 +0000 (12:30 -0700)
Problem reported by Eric Blake in:
https://lists.gnu.org/r/bug-gnulib/2021-04/msg00181.html
* lib/cdefs.h: Make this closer to glibc, so that we can
merge Gnulib into glibc here.
(__attribute_maybe_unused__): Make identical to glibc’s
definition, though with an additional comment.
(__attribute_nonnull__): Add clarifying comment.
Make inclusion of bits/wordsize.h, bits/long-double.h
dependent on __GLIBC__, not on !__WORDSIZE.
* lib/libc-config.h: Use __attribute_nonnull__,
not __attribute_maybe_unused__, to detect whether
to include sys/cdefs.h.

ChangeLog
lib/cdefs.h
lib/libc-config.h

index 579284336809679b8b476b472ce1e8153ecd80e1..eacc4a53fe63b90afd9e3692aef67b882067647c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2021-04-22  Paul Eggert  <eggert@cs.ucla.edu>
+
+       libc-config: port better to Fedora Rawhide
+       Problem reported by Eric Blake in:
+       https://lists.gnu.org/r/bug-gnulib/2021-04/msg00181.html
+       * lib/cdefs.h: Make this closer to glibc, so that we can
+       merge Gnulib into glibc here.
+       (__attribute_maybe_unused__): Make identical to glibc’s
+       definition, though with an additional comment.
+       (__attribute_nonnull__): Add clarifying comment.
+       Make inclusion of bits/wordsize.h, bits/long-double.h
+       dependent on __GLIBC__, not on !__WORDSIZE.
+       * lib/libc-config.h: Use __attribute_nonnull__,
+       not __attribute_maybe_unused__, to detect whether
+       to include sys/cdefs.h.
+
 2021-04-21  Paul Eggert  <eggert@cs.ucla.edu>
 
        realloc: port to AIX 7.1
index 90f97412a9960823744949a9498f9accc229a0cf..9618152ab8cd2a0fca5e0fd041e1fd44de6d52b0 100644 (file)
 # define __attribute_const__ /* Ignore */
 #endif
 
-#if defined __STDC_VERSION__ && 201710L < __STDC_VERSION__
-# define __attribute_maybe_unused__ [[__maybe_unused__]]
-#elif __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
+#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
 # define __attribute_maybe_unused__ __attribute__ ((__unused__))
+/* Once the next version of the C standard comes out, we can
+   do something like the following here:
+   #elif defined __STDC_VERSION__ && 202???L <= __STDC_VERSION__
+   # define __attribute_maybe_unused__ [[__maybe_unused__]]   */
 #else
 # define __attribute_maybe_unused__ /* Ignore */
 #endif
 #endif
 
 /* The nonnull function attribute marks pointer parameters that
-   must not be NULL.  */
+   must not be NULL.  This has the name __nonnull in glibc,
+   and __attribute_nonnull__ in files shared with Gnulib to avoid
+   collision with a different __nonnull in DragonFlyBSD 5.9.  */
 #ifndef __attribute_nonnull__
 # if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
 #  define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
 
 /* The #ifndef lets Gnulib avoid including these on non-glibc
    platforms, where the includes typically do not exist.  */
-#ifndef __WORDSIZE
+#ifdef __GLIBC__
 # include <bits/wordsize.h>
 # include <bits/long-double.h>
 #endif
index f14013f7e807d164a9700e4b22a892869dc4a2b3..f2c86144b8e5a76ae49407d318e4c73075e61787 100644 (file)
@@ -71,7 +71,7 @@
 # endif
 #endif
 
-#ifndef __attribute_maybe_unused__
+#ifndef __attribute_nonnull__
 /* <sys/cdefs.h> either does not exist, or is too old for Gnulib.
    Prepare to include <cdefs.h>, which is Gnulib's version of a
    more-recent glibc <sys/cdefs.h>.  */