Performance improvement to strnlen().

Lee Thomas lee_thomas at aslantools.com
Mon May 27 03:54:56 UTC 2013


On 2013-05-26 08:00, Václav Zeman wrote:
> On 05/25/2013 10:27 PM, Lee Thomas wrote:
>> +	lp = (const unsigned long *)((uintptr_t)str & ~LONGPTR_MASK);
>> +	va = (*lp - mask01);
>> +	vb = ((~*lp) & mask80);
> I do not think that this correct C. This is type punning violating 
> the
> rules of the language.

Hello Václav,

The aliasing here is safe, because there are no writes through either 
of the pointers.

Regards,
Lee Thomas


More information about the freebsd-hackers mailing list