This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/2] Optimize generic spinlock code and use C11 like atomic macros.
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Stefan Liebler <stli at linux dot vnet dot ibm dot com>, <libc-alpha at sourceware dot org>
- Cc: <nd at arm dot com>
- Date: Mon, 19 Dec 2016 12:14:08 +0000
- Subject: Re: [PATCH 1/2] Optimize generic spinlock code and use C11 like atomic macros.
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
- Nodisclaimer: True
- References: <1481905917-15654-1-git-send-email-stli@linux.vnet.ibm.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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.)