unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Martin Sebor <msebor@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] add attribute none to pthread_setspecific (BZ #27714)
Date: Fri, 23 Apr 2021 13:19:38 -0700	[thread overview]
Message-ID: <a5ddf2cc-6df0-38fb-473c-0fd1de74220b@cs.ucla.edu> (raw)
In-Reply-To: <a72cdbc6-7ed9-4448-259a-d8df2944d46e@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 714 bytes --]

On 4/23/21 8:24 AM, Martin Sebor wrote:
> 
> I think we considered variadic macros
> when we first introduced the attribute but rejected it for some
> reason that I'm not sure I remember.  Maybe because they're a C99
> feature and Glibc supports older compilers?

That shouldn't be an issue here, since the suggested change uses 
variadic macros for GCC 10 only.

Unless people were worried about running something like 'gcc -ansi' or 
'gcc -std=c89? To head that off at the pass, we can do the GCC 10 stuff 
only if !__STRICT_ANSI__. Also, while we're at it we should be 
C99-compatible in the variadic part (i.e., at least one named argument). 
Something like the attached (untested) patch, say.

[-- Attachment #2: cdefs-2.diff --]
[-- Type: text/x-patch, Size: 1368 bytes --]

diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 8e244a77cf..b3b5456efd 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -586,15 +586,23 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __HAVE_GENERIC_SELECTION 0
 #endif
 
-#if __GNUC_PREREQ (10, 0)
 /* Designates a 1-based positional argument ref-index of pointer type
    that can be used to access size-index elements of the pointed-to
    array according to access mode, or at least one element when
    size-index is not provided:
      access (access-mode, <ref-index> [, <size-index>])  */
-#define __attr_access(x) __attribute__ ((__access__ x))
+#if __GNUC_PREREQ (11, 0)
+# define __attr_access(x) __attribute__ ((__access__ x))
+#elif __GNUC_PREREQ (10, 0) && !defined __STRICT_ANSI__
+# define __attr_access(x) __attr_access1 x
+# define __attr_access1(mode, ...) __attr_access##mode (mode, __VA_ARGS__)
+# define __attr_access__none__(mode, ...)
+# define __attr_access__read_only__(mode, ...) \
+    __attribute__ ((__access__ (mode, __VA_ARGS__)))
+# define __attr_access__read_write__ __attr_access__read_only__
+# define __attr_access__write_only__ __attr_access__read_only__
 #else
-#  define __attr_access(x)
+# define __attr_access(x)
 #endif
 
 /* Specify that a function such as setjmp or vfork may return

  reply	other threads:[~2021-04-23 20:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 21:30 [PATCH] add attribute none to pthread_setspecific (BZ #27714) Martin Sebor via Libc-alpha
2021-04-22 22:26 ` Martin Sebor via Libc-alpha
2021-04-23  0:11 ` Paul Eggert
2021-04-23 15:24   ` Martin Sebor via Libc-alpha
2021-04-23 20:19     ` Paul Eggert [this message]
2021-04-23 21:29       ` Martin Sebor via Libc-alpha
2021-04-24  0:27         ` Paul Eggert
2021-04-26 19:38           ` Martin Sebor via Libc-alpha
2021-04-27  4:41 ` Florian Weimer via Libc-alpha
2021-04-27 19:07   ` Martin Sebor via Libc-alpha
2021-04-27 21:07     ` Joseph Myers
2021-04-27 21:46       ` Martin Sebor via Libc-alpha
2021-04-27 21:58         ` Joseph Myers
2021-04-27 22:57           ` Martin Sebor via Libc-alpha
2021-04-28  1:09             ` Martin Sebor via Libc-alpha
2021-04-28  7:32               ` Florian Weimer via Libc-alpha
2021-04-28 14:49                 ` Martin Sebor via Libc-alpha
2021-04-29  7:45                   ` Florian Weimer via Libc-alpha
2021-04-29 14:55                     ` Martin Sebor via Libc-alpha
2021-04-29 16:16                       ` Florian Weimer via Libc-alpha
2021-04-28  1:30             ` H.J. Lu via Libc-alpha

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://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5ddf2cc-6df0-38fb-473c-0fd1de74220b@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=msebor@gmail.com \
    /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).