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][BZ #14188] Allow pthread_cleanup_push to build with compilersother than gcc


On 6/2/2012 9:47 AM, Siddhesh Poyarekar wrote:
> On Fri,  1 Jun 2012 12:41:48 -0700 (PDT), Roland wrote:
>> This is the only use of __builtin_expect in a public header now.
>> But it seems reasonably likely that we'll have others eventually.
>> So my inclination would be to put the macro in sys/cdefs.h and give
>> it a different name.  (Or perhaps also slightly different semantics,
>> e.g. __glibc_unlikely(BOOL).)
>>
> 
> OK, updated patch attached. I guess it would be a good idea to mandate
> use of __glibc_unlikely() wherever applicable, purely because it makes
> code prettier. It might not be worth hunting down and changing
> everything in one go, but at least to ensure that future uses (and
> modifications) of __builtin_expect(cond, 0) be discouraged in favour of
> __glibc_unlikely throughout the code base.

No. Notice that this is a public header. It is only in public headers
where we care about the double-underscore name. 

We have made a conscious decision to use __glibc_* to avoid conflicts
with the other components of the implementation.

Thus the use of __glibc_* is only required in public headers.

> Tested with tinycc (http://bellard.org/tcc/) to verify that correct
> code is generated for pthread_cleanup_push and also with gcc on Fedora
> to verify that there are no regressions.
> 
> Regards,
> Siddhesh
> 
> 
> ChangeLog:
> 2012-06-02  Siddhesh Poyarekar  <siddhesh@redhat.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
> 
> 	[BZ #14188]
> 	* misc/sys/cdefs.h (__glibc_unlikely): New macro to wrap cases
> 	where __builtin_expect is unavailable.
> 
> 
> nptl/ChangeLog:
> 2012-06-02  Siddhesh Poyarekar  <siddhesh@redhat.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
> 
> 	[BZ #14188]
> 	* sysdeps/pthread/pthread.h
> 	[!(defined __GNUC__ && defined __EXCEPTIONS)]
> 	(pthread_cleanup_push, pthread_cleanup_push_defer_np): Use
> 	__libc_unlikely instead of __builtin_expect.

This looks good to me.

Cheers,
Carlos.
-- 
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos_odonell@mentor.com
carlos@codesourcery.com
+1 (613) 963 1026


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