diff options
author | Mattias Andrée <maandree@kth.se> | 2022-02-17 17:23:57 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-02-17 17:23:57 +0100 |
commit | 611f60b5fbc14f0c2ca31476e8f7ebd8cb442402 (patch) | |
tree | 2f800da4309dc475e15100ac625ff252a1354d19 /libblake_init.c | |
parent | Fix typo (diff) | |
download | libblake-611f60b5fbc14f0c2ca31476e8f7ebd8cb442402.tar.gz libblake-611f60b5fbc14f0c2ca31476e8f7ebd8cb442402.tar.bz2 libblake-611f60b5fbc14f0c2ca31476e8f7ebd8cb442402.tar.xz |
libblake_init: return before locking if already initialised (check-lock-check)
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libblake_init.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libblake_init.c b/libblake_init.c index 84dd87e..0276cd2 100644 --- a/libblake_init.c +++ b/libblake_init.c @@ -15,6 +15,9 @@ libblake_init(void) static volatile int initialised = 0; static volatile atomic_flag spinlock = ATOMIC_FLAG_INIT; + if (initialised) + return; + while (atomic_flag_test_and_set(&spinlock)); if (!initialised) { |