From: Florian Weimer <fweimer@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: libc-alpha <libc-alpha@sourceware.org>,
Rich Felker <dalias@libc.org>,
linux-api <linux-api@vger.kernel.org>,
Boqun Feng <boqun.feng@gmail.com>,
Will Deacon <will.deacon@arm.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ben Maurer <bmaurer@fb.com>, Dave Watson <davejwatson@fb.com>,
Thomas Gleixner <tglx@linutronix.de>,
Paul <paulmck@linux.vnet.ibm.com>, Paul Turner <pjt@google.com>,
Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH glibc 1/3] glibc: Perform rseq registration at C startup and thread creation (v19)
Date: Tue, 26 May 2020 14:41:14 +0200 [thread overview]
Message-ID: <87lflerhqt.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <108939265.33525.1590428184533.JavaMail.zimbra@efficios.com> (Mathieu Desnoyers's message of "Mon, 25 May 2020 13:36:24 -0400 (EDT)")
* Mathieu Desnoyers:
> Something like this ?
>
> #ifdef __cplusplus
> # if __cplusplus >= 201103L
> # define rseq_static_assert (expr, diagnostic) static_assert (expr, diagnostic)
> # define rseq_alignof alignof
> # endif
> #elif __STDC_VERSION__ >= 201112L
> # define rseq_static_assert (expr, diagnostic) _Static_assert (expr, diagnostic)
> # define rseq_alignof _Alignof
> #endif
>
> #ifndef rseq_static_assert
> # define rseq_static_assert (expr, diagnostic) /* nothing */
> #endif
You can't have a space in #defines like that, no matter what GNU style
says. 8-)
> /* Ensure the compiler supports __attribute__ ((aligned)). */
> rseq_static_assert ((rseq_alignof (struct rseq_cs) >= 32, "alignment"));
> rseq_static_assert ((rseq_alignof (struct rseq) >= 32, "alignment"));
You need to move the ; into rseq_static_assert. And if you use explicit
arguments, you can't use double parentheses.
>> And something similar for _Alignas/attribute aligned,
>
> I don't see where _Alignas is needed here ?
>
> For attribute aligned, what would be the oldest supported C and C++
> standards ?
There are no standardized attributes for C, there is only _Alignas.
C++11 has an alignas specifier; it's not an attribute either. I think
these are syntactically similar.
>> with an error for
>> older standards and !__GNUC__ compilers (because neither the type nor
>> __thread can be represented there).
>
> By "type" you mean "struct rseq" here ? What does it contain that requires
> a __GNUC__ compiler ?
__attribute__ and __thread support.
> About __thread, I recall other compilers have other means to declare it.
> In liburcu, I end up with the following:
>
> #if defined (__cplusplus) && (__cplusplus >= 201103L)
> # define URCU_TLS_STORAGE_CLASS thread_local
> #elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
> # define URCU_TLS_STORAGE_CLASS _Thread_local
> #elif defined (_MSC_VER)
> # define URCU_TLS_STORAGE_CLASS __declspec(thread)
> #else
> # define URCU_TLS_STORAGE_CLASS __thread
> #endif
>
> Would something along those lines be OK for libc ?
Yes, it would be okay (minus the Visual C++ part). This part does not
have to go into UAPI headers first. A fallback definition of __thread
should be okay. Outside glibc, the TLS model declaration is optional, I
think. The glibc *definition* ensures that the variable is
initial-exec.
Thanks,
Florian
next prev parent reply other threads:[~2020-05-26 12:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200501021439.2456-1-mathieu.desnoyers@efficios.com>
2020-05-01 2:14 ` [PATCH glibc 1/3] glibc: Perform rseq registration at C startup and thread creation (v19) Mathieu Desnoyers
2020-05-20 11:40 ` Florian Weimer
2020-05-25 14:51 ` Mathieu Desnoyers
2020-05-25 15:20 ` Florian Weimer
2020-05-25 17:36 ` Mathieu Desnoyers
2020-05-26 12:41 ` Florian Weimer [this message]
2020-05-26 14:32 ` Mathieu Desnoyers
2020-05-26 14:38 ` Florian Weimer
2020-05-26 14:53 ` Mathieu Desnoyers
2020-05-26 14:57 ` Florian Weimer
2020-05-26 15:22 ` Mathieu Desnoyers
2020-05-01 2:14 ` [PATCH glibc 2/3] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux (v7) Mathieu Desnoyers
2020-05-20 10:14 ` Florian Weimer
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lflerhqt.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=bmaurer@fb.com \
--cc=boqun.feng@gmail.com \
--cc=dalias@libc.org \
--cc=davejwatson@fb.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=tglx@linutronix.de \
--cc=will.deacon@arm.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 NNTP newsgroup(s).