[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ftbmpxqi.fsf@oldenburg2.str.redhat.com>
Date: Tue, 26 May 2020 16:38:45 +0200
From: Florian Weimer <fweimer@...hat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: libc-alpha <libc-alpha@...rceware.org>,
Rich Felker <dalias@...c.org>,
linux-api <linux-api@...r.kernel.org>,
Boqun Feng <boqun.feng@...il.com>,
Will Deacon <will.deacon@....com>,
linux-kernel <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ben Maurer <bmaurer@...com>, Dave Watson <davejwatson@...com>,
Thomas Gleixner <tglx@...utronix.de>,
Paul <paulmck@...ux.vnet.ibm.com>, Paul Turner <pjt@...gle.com>,
Joseph Myers <joseph@...esourcery.com>
Subject: Re: [PATCH glibc 1/3] glibc: Perform rseq registration at C startup and thread creation (v19)
* Mathieu Desnoyers:
> AFAIU, the only gain here would be to make sure we don't emit useless
> ";" in the "/* nothing */" case. But does it matter ?
I don't think C allows empty constructs like this at the top level.
>>>> 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.
>
> There appears to be an interesting difference between attribute aligned
> and alignas. It seems like alignas cannot be used on a structure declaration,
> only on fields, e.g.:
>
> struct blah {
> int a;
> } _Alignas (16);
>
> o.c:3:1: warning: useless ‘_Alignas’ in empty declaration
> } _Alignas (16);
>
> But
>
> struct blah {
> int _Alignas (16) a;
> };
Like the attribute, it needs to come right after the struct keyword, I
think. (Trailing attributes can be ambiguous, but not in this case.)
> is OK. So if I change e.g. struct rseq_cs to align
> the first field:
>
> struct rseq_cs
> {
> /* Version of this structure. */
> uint32_t rseq_align (32) version;
> /* enum rseq_cs_flags. */
> uint32_t flags;
> uint64_t start_ip;
> /* Offset from start_ip. */
> uint64_t post_commit_offset;
> uint64_t abort_ip;
> };
>
> It should work.
Indeed.
> /* Rely on GNU extensions for older standards and tls model. */
> #ifdef __GNUC__
> # ifndef rseq_alignof
> # define rseq_alignof(x) __alignof__ (x)
> # endif
> # ifndef rseq_alignas
> # define rseq_alignas(x) __attribute__ ((aligned (x)))
> # endif
> # define rseq_tls_model_ie __attribute__ ((__tls_model__ ("initial-exec")))
> #else
> /* Specifying the TLS model on the declaration is optional. */
> # define rseq_tls_model_ie /* Nothing. */
> #endif
>
> /* Fall back to __thread for TLS storage class. */
> #ifndef rseq_tls_storage_class
> # define rseq_tls_storage_class __thread
> #endif
If they are only used in the glibc headers, they should have __rseq
prefixes, so that application code doesn't start using them (in case we
have to change/fix them, or move the into <sys/cdefs.h> later).
Rest looks fine.
Thanks,
Florian
Powered by blists - more mailing lists