From: Paul Eggert <eggert@cs.ucla.edu>
To: Bruno Haible <bruno@clisp.org>
Cc: bug-gnulib@gnu.org,
"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
Vaseeharan Vinayagamoorthy <Vaseeharan.Vinayagamoorthy@arm.com>,
Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH 1/5] posix: Sync regex code with gnulib
Date: Tue, 19 Jan 2021 18:55:51 -0800 [thread overview]
Message-ID: <05f5e913-f1d1-b2f9-beb7-f226588733c0@cs.ucla.edu> (raw)
In-Reply-To: <2108975.lN1YhbmyTB@omega>
[-- Attachment #1: Type: text/plain, Size: 1459 bytes --]
On 1/19/21 7:43 AM, Bruno Haible wrote:
> Adhemerval Zanella wrote:
>> -# if (__GNUC__ >= 7) || (__clang_major__ >= 10)
>> +# if (__GNUC__ >= 7) || (defined __clang_major__ &&__clang_major__ >= 10)
> I would write it as:
>
> +# if (__GNUC__ >= 7) || (defined __clang__ && __clang_major__ >= 10)
This line should be used only if _LIBC is defined, so we can simplify it
to just "#if __GNUC__ >= 7" and thus not worry about Clang.
I see that Gnulib wasn't consistent about this, so I installed the
attached patch to Gnulib to fix the issue here and elsewhere. The idea
is that the Gnulib regex_internal.h can be copied back to glibc, and
that the other uses in Gnulib should be similar.
On 1/19/21 6:43 AM, Adhemerval Zanella wrote:
> Paul, this seemed to a common pattern scatter on multiple file in gnulib.
> Wouldn't be better to consolidate it on cdefs.h?
We could append something like the following to cdefs.h, and switch to
__attribute_fallthrough__ for modules shared between the two systems. Is
that something you'd like to pursue? (We should also sync Gnulib cdefs.h
back to glibc of course.)
#if defined __STDC_VERSION__ && 201710L < __STDC_VERSION__
# define __attribute_fallthrough__ [[__fallthrough__]]
#elif __GNUC_PREREQ (7, 0) || __glibc_has_attribute (__fallthrough__)
# define __attribute_fallthrough__ __attribute__ ((__fallthrough__))
#else
# define __attribute_fallthrough__ ((void) 0)
#endif
[-- Attachment #2: 0001-fnmatch-regex-fts-FALLTHROUGH-consistency.patch --]
[-- Type: text/x-patch, Size: 3792 bytes --]
From 5c52f00c69f39fe86ec087654893087a83290ee7 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 19 Jan 2021 18:35:30 -0800
Subject: [PATCH] fnmatch, regex, fts: FALLTHROUGH consistency
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Be more consistent about how FALLTHROUGH is defined.
For Gnulib, use attribute.h. For glibc, use __GNUC__ >= 7.
Problem for glibc reported by Vaseeharan Vinayagamoorthy in:
https://sourceware.org/pipermail/libc-alpha/2021-January/121778.html
* lib/fnmatch.c (FALLTHROUGH) [_LIBC]:
* lib/regex_internal.h (FALLTHROUGH) [_LIBC]:
Don’t worry about Clang, as it’s not needed and provokes GCC.
* lib/fts.c (FALLTHROUGH) [!_LIBC]:
* lib/regex_internal.h (FALLTHROUGH) [!_LIBC]:
Rely on attribute.h for FALLTHROUGH
* modules/regex: Depend on attribute module.
---
ChangeLog | 15 +++++++++++++++
lib/fnmatch.c | 2 +-
lib/fts.c | 4 ++--
lib/regex_internal.h | 6 ++++--
modules/regex | 1 +
5 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 269577caa..290fa1b4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2021-01-19 Paul Eggert <eggert@cs.ucla.edu>
+
+ fnmatch, regex, fts: FALLTHROUGH consistency
+ Be more consistent about how FALLTHROUGH is defined.
+ For Gnulib, use attribute.h. For glibc, use __GNUC__ >= 7.
+ Problem for glibc reported by Vaseeharan Vinayagamoorthy in:
+ https://sourceware.org/pipermail/libc-alpha/2021-January/121778.html
+ * lib/fnmatch.c (FALLTHROUGH) [_LIBC]:
+ * lib/regex_internal.h (FALLTHROUGH) [_LIBC]:
+ Don’t worry about Clang, as it’s not needed and provokes GCC.
+ * lib/fts.c (FALLTHROUGH) [!_LIBC]:
+ * lib/regex_internal.h (FALLTHROUGH) [!_LIBC]:
+ Rely on attribute.h for FALLTHROUGH
+ * modules/regex: Depend on attribute module.
+
2021-01-19 KO Myung-Hun <komh78@gmail.com>
spawn-pipe: Fix SIGSEGV on OS/2 kLIBC.
diff --git a/lib/fnmatch.c b/lib/fnmatch.c
index 5896812c9..b8a71f164 100644
--- a/lib/fnmatch.c
+++ b/lib/fnmatch.c
@@ -64,7 +64,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
#endif
#ifdef _LIBC
-# if (__GNUC__ >= 7) || (__clang_major__ >= 10)
+# if __GNUC__ >= 7
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# else
# define FALLTHROUGH ((void) 0)
diff --git a/lib/fts.c b/lib/fts.c
index 8a9b5ed96..e6603f40e 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -200,8 +200,8 @@ enum Fts_stat
while (false)
#endif
-#ifndef FALLTHROUGH
-# if (__GNUC__ >= 7) || (__clang_major__ >= 10)
+#ifdef _LIBC
+# if __GNUC__ >= 7
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# else
# define FALLTHROUGH ((void) 0)
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index b4f91d9ec..3fa2bf1aa 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -830,12 +830,14 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
}
#endif /* RE_ENABLE_I18N */
-#ifndef FALLTHROUGH
-# if (__GNUC__ >= 7) || (__clang_major__ >= 10)
+#ifdef _LIBC
+# if __GNUC__ >= 7
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# else
# define FALLTHROUGH ((void) 0)
# endif
+#else
+# include "attribute.h"
#endif
#endif /* _REGEX_INTERNAL_H */
diff --git a/modules/regex b/modules/regex
index 20cbe375a..a32c46e18 100644
--- a/modules/regex
+++ b/modules/regex
@@ -16,6 +16,7 @@ Depends-on:
c99
extensions
ssize_t
+attribute [test $ac_use_included_regex = yes]
btowc [test $ac_use_included_regex = yes]
builtin-expect [test $ac_use_included_regex = yes]
dynarray [test $ac_use_included_regex = yes]
--
2.27.0
next prev parent reply other threads:[~2021-01-20 2:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-30 20:15 [PATCH 1/5] posix: Sync regex code with gnulib Adhemerval Zanella
2020-12-30 20:15 ` [PATCH 2/5] posix: Sync glob " Adhemerval Zanella
2020-12-31 21:47 ` Paul Eggert
2020-12-30 20:15 ` [PATCH 3/5] Sync intprops.h " Adhemerval Zanella
2020-12-31 21:47 ` Paul Eggert
2020-12-30 20:15 ` [PATCH 4/5] Sync flexmember.h " Adhemerval Zanella
2020-12-31 21:48 ` Paul Eggert
2020-12-30 20:15 ` [PATCH 5/5] posix: Sync fnmatch " Adhemerval Zanella
2020-12-31 21:54 ` Paul Eggert
2020-12-31 21:37 ` [PATCH 1/5] posix: Sync regex code " Paul Eggert
2021-01-19 14:16 ` Vaseeharan Vinayagamoorthy
2021-01-19 14:43 ` Adhemerval Zanella
2021-01-19 15:43 ` Bruno Haible
2021-01-20 2:55 ` Paul Eggert [this message]
2021-01-20 11:27 ` Adhemerval Zanella
2021-01-20 15:32 ` Vaseeharan Vinayagamoorthy
2021-01-20 16:05 ` Adhemerval Zanella
2021-01-20 17:46 ` Paul Eggert
2021-01-19 16:52 ` Florian Weimer
2021-01-19 17:11 ` Adhemerval Zanella
2021-01-19 17:16 ` Florian Weimer
2021-01-19 17:18 ` Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05f5e913-f1d1-b2f9-beb7-f226588733c0@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=Vaseeharan.Vinayagamoorthy@arm.com \
--cc=adhemerval.zanella@linaro.org \
--cc=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).