This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] Optimize generic spinlock code and use C11 like atomic macros.


On 16/12/16 16:31, Stefan Liebler wrote:
> Passing a volatile pointer to the atomic macros can lead to extra stores
> and loads to stack if such a macro creates a temporary variable by using
> __typeof (*(mem)). Thus the patch passes a int pointer to the atomic macros.

the resolution of
http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_423.htm
says that the type of a cast expression is unqualified, so

  __typeof ((__typeof (*(mem)))*(mem)) tmp = *(mem);

would have the right type.. seems to work since gcc-5

https://godbolt.org/g/eS0X5b

(looks beautiful.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]