aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-17 17:23:57 +0100
committerMattias Andrée <maandree@kth.se>2022-02-17 17:23:57 +0100
commit611f60b5fbc14f0c2ca31476e8f7ebd8cb442402 (patch)
tree2f800da4309dc475e15100ac625ff252a1354d19
parentFix typo (diff)
downloadlibblake-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>
-rw-r--r--libblake_init.c3
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) {