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 v2 4/6] i386: Remove bogus THREAD_ATOMIC_* macros


* 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


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