[Mesa-dev] [PATCH] util: import sha1 implementation from OpenBSD

Emil Velikov emil.l.velikov at gmail.com
Mon Jan 16 13:19:06 UTC 2017


On 14 January 2017 at 06:25, Jonathan Gray <jsg at jsg.id.au> wrote:
> On Fri, Jan 13, 2017 at 04:51:31PM +0000, Emil Velikov wrote:
>> From: Emil Velikov <emil.velikov at collabora.com>
>>
>> At the moment we support 5+ different implementations each with varying
>> amount of bugs - from thread safely problems [1], to outright broken
>> implementation(s) [2]
>>
>> In order to accommodate these we have 150+ lines of configure script and
>> extra two configure toggles. Whist an actual implementation being
>> ~200loc and our current compat wrapping ~250.
>>
>> Let's not forget that different people use different code paths, thus
>> effectively makes it harder to test and debug since the default
>> implementation is automatically detected.
>>
>> To minimise all these lovely experiences, import the "100% Public
>> Domain" OpenBSD sha1 implementation. Clearly document any changes needed
>> to get building correctly, since many/most of those can be upstreamed
>> making future syncs easier.
>
> I had feared that this would somehow collide with the symbols
> in libc but it seems to build and run xorg/glxgears at least
> on broadwell with i965.
>
Amazing, thanks for testing !

> Patches for OpenBSD go to tech@ and you should look at how portable
> openssh and libressl handle systems that lack functions like
> explicit_bzero, autoconf detects systems that lack functions or are
> known to have broken implementations and alternate versions are
> provided.  Damien Miller described how this is handled for ssh in
> https://www.openbsd.org/papers/portability.pdf
> https://www.openbsd.org/papers/auug2005-portability/
>
> The attribute could also be checked in autoconf as is already done
> for various other attributes.
>
> Other parts seem odd, posix defines size_t as being in sys/types.h
> not stddef.h for example.
>
> u_int* are bsd types which predate c99 types, I could see an
> argument being made for changing the types there but it
> would likely have to cover all the other hashes as well,
> not just sha1.
>
Thanks for the tips Jonathan. I'll follow suite as/if we get this patch merged.

To answer your question - I've opted for the C99 variants
(headers/types) since we build mesa/gallium on non-POSIX platforms.
With the former being almost universally supported these days.

Thanks
Emil


More information about the mesa-dev mailing list