On 4/22/21 11:20 AM, Eric Blake wrote:

Looks like the definition of macro  __attribute_nonnull__ from cdefs.h
is no longer implicitly picked up by the system headers used in that file.

I installed the attached Gnulib patch to fix that; please give it a try.

If it works, we should sync Gnulib's cdefs.h back into glibc.
>From eb32c992c90617b529e2ce08ad6014d418dceaf9 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Thu, 22 Apr 2021 12:29:49 -0700
Subject: [PATCH] libc-config: port better to Fedora Rawhide
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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         | 16 ++++++++++++++++
 lib/cdefs.h       | 14 +++++++++-----
 lib/libc-config.h |  2 +-
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 579284336..eacc4a53f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2021-04-22  Paul Eggert  <egg...@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  <egg...@cs.ucla.edu>
 
 	realloc: port to AIX 7.1
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 90f97412a..9618152ab 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -259,10 +259,12 @@
 # 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
@@ -320,7 +322,9 @@
 #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))
@@ -487,7 +491,7 @@
 
 /* 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
diff --git a/lib/libc-config.h b/lib/libc-config.h
index f14013f7e..f2c86144b 100644
--- a/lib/libc-config.h
+++ b/lib/libc-config.h
@@ -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>.  */
-- 
2.27.0

Reply via email to