[Zlib-devel] [4/6][RFC V2 Patch] Add an x86 version of Adler32

Jan Seiffert kaffeemonster at googlemail.com
Thu Mar 31 07:09:07 EDT 2011


2011/3/31 Török Edwin <edwintorok at gmail.com>:
> On 2011-03-30 17:24, Jan Seiffert wrote:
>> And finally an x86 version of Adler32.
>>
>> it covers:
>> * Plain
>> * MMX
>> * SSE
>> * SSE2
>> * SSSE3
>> * 32 & 64 Bit
>> * PIC and non PIC
>>
>> And features a runtime cpu detection + dispatch.
>> It heavily uses inline ASM, so it's restricted to GCC (or compatible
>> compiler, like clang).
>> This gives us help from the compiler for boilerplate code, all the
>> fiddling with calling conventions, PIC and bit-ness of the code.
>
> Could you use the 'ifunc' attribute to make the runtime selection? (that
> is what glibc uses)
> http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
>

Yes, could, but:
- Would need some configure magic
- In my own testing had some problems with -fpic

> On the plus side it'd eliminate the race condition,

If you look again, it has an constructor which runs before main() (or
right on dlopen). So the function is resolved very early.
The runtime switcher is only the defensive last resort if the
constructor is not run for some case, and on x86 the race should be
not that bad.

> on the downside it'd require a non-ancient binutils and glibc.
>

Yes


> Best regards,
> --Edwin
>

Greetings
Jan


-- 
The steady state of disks is full.
- Ken Thompson




More information about the Zlib-devel mailing list