diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-03 22:48:19 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-03 22:48:19 +0200 |
| commit | 7ec3cbe54de4a620e884ab77f2996f175015c815 (patch) | |
| tree | 3c5ad555d3c33b031a4d18737937909e3d6248a6 | |
| parent | Check HWCAP_SHA1 on ARM (diff) | |
| download | libsha1-7ec3cbe54de4a620e884ab77f2996f175015c815.tar.gz libsha1-7ec3cbe54de4a620e884ab77f2996f175015c815.tar.bz2 libsha1-7ec3cbe54de4a620e884ab77f2996f175015c815.tar.xz | |
Ensure HWCAP_SHA1-check does not modify errno
Signed-off-by: Mattias Andrée <m@maandree.se>
| -rw-r--r-- | process.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include "common.h" +#include <errno.h> #include <stdatomic.h> #if defined(__SSE4_1__) && defined(__SSSE3__) && defined(__SSE2__) && defined(__SHA__) @@ -483,6 +484,7 @@ have_sha_intrinsics(void) { static volatile int ret = -1; static volatile atomic_flag spinlock = ATOMIC_FLAG_INIT; + int saved_errno; if (ret != -1) return ret; @@ -492,10 +494,12 @@ have_sha_intrinsics(void) if (ret != -1) goto out; + saved_errno = errno; if (getauxval(AT_HWCAP) & HWCAP_SHA1) ret = 1; else ret = 0; + errno = saved_errno; out: atomic_flag_clear(&spinlock); |
