This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] S390: Test if lock is free before using atomic instruction in spin-lock.
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Stefan Liebler <stli at linux dot vnet dot ibm dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 16 Dec 2016 21:12:04 +0100
- Subject: Re: [PATCH 2/2] S390: Test if lock is free before using atomic instruction in spin-lock.
- Authentication-results: sourceware.org; auth=none
- References: <1479913753-20506-1-git-send-email-stli@linux.vnet.ibm.com> <1479913753-20506-2-git-send-email-stli@linux.vnet.ibm.com> <1479992650.7146.1535.camel@localhost.localdomain> <b493ee72-62f6-e630-1dfa-5a2f678cf481@linux.vnet.ibm.com>
* Stefan Liebler:
> The type pthread_spinlock_t is a volatile int!
> If lock is casted to (int *) before passing it to the atomic macros,
> the assembler output looks okay.
That's undefined:
“If an attempt is made to refer to an object defined with a
volatile-qualified type through use of an lvalue with
non-volatile-qualified type, the behavior is undefined.”
But we cannot drop the volatile qualifier from the definition of
pthread_spinlock_t because it would change the C++ mangling of
pthread_spinlock_t * and similar types.
Maybe we can receive a GCC extension to support this?