This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 4/6] i386: Remove bogus THREAD_ATOMIC_* macros
- From: Florian Weimer <fweimer at redhat dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 25 Jan 2019 16:16:15 +0100
- Subject: Re: [PATCH v2 4/6] i386: Remove bogus THREAD_ATOMIC_* macros
- References: <20181228010255.21406-1-adhemerval.zanella@linaro.org> <20181228010255.21406-5-adhemerval.zanella@linaro.org>
* Adhemerval Zanella:
> The x86 defines optimized THREAD_ATOMIC_* macros where reference always
> the current thread instead of the one indicated by input 'descr' argument.
> It work as long the input is the self thread pointer, however it generates
> wrong code is the semantic is to set a bit atomicialy from another thread.
The entire set of THREAD_* macros is poorly documented, but this is part
of the interface: On some targets, it is expensive to obtain the thread
pointer, so it makes sense to cache it. On other targets, including
x86-64 or i386, access to the thread pointer is implicit (or can be
cached by the compiler), so an explicit cached descriptor is
unnecessary.
I think we can improve this a lot: We could use a new type for the
cache, to make clear it is a cache, and make the macros type-safe. Or
we could try to have the compiler cache the value for us, like we do
with __errno_location.
Thanks,
Florian