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 #14370: Check mismatched TLS/non-TLS symbols


On Sep  4, 2012, "H.J. Lu" <hongjiu.lu@intel.com> wrote:

> +      && (__builtin_expect (ELFW(ST_TYPE) (current_value.s->st_info) == STT_TLS, 0)
> +	  || __builtin_expect (ELFW(ST_TYPE) ((*ref)->st_info) == STT_TLS, 0))
> +      && __builtin_expect (ELFW(ST_TYPE) (current_value.s->st_info) !=
> +			   ELFW(ST_TYPE) ((*ref)->st_info), 1))

How about spelling this out as

> && __builtin_expect ((ELFW(ST_TYPE) (current_value.s->st_info) == STT_TLS)
> 			!= (ELFW(ST_TYPE) ((*ref)->st_info) == STT_TLS), 0)

?

We pretty much already have to perform both compares anyway, for most
symbols won't pass the first test, and with != instead of || we avoid
serializing the compares *and* the duplicate third comparison.

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer


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