Make SIMD capability variables thread-local ...

... on platforms that support TLS, which should include all
currently-supported platforms
(https://libjpeg-turbo.org/Documentation/OfficialBinaries)

Addresses a concern raised in #87

Although it is still my opinion that the data race in init_simd() was
innocuous, we can now fix it for free thanks to
ae87a95861, so why not?
This commit is contained in:
DRC
2022-10-03 19:46:09 -05:00
parent 2cad2169ae
commit f579cc11b3
7 changed files with 16 additions and 30 deletions

View File

@@ -2,7 +2,7 @@
* jsimd_mips.c
*
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2009-2011, 2014, 2016, 2018, 2020, D. R. Commander.
* Copyright (C) 2009-2011, 2014, 2016, 2018, 2020, 2022, D. R. Commander.
* Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
* Copyright (C) 2015-2016, 2018, Matthieu Darbois.
*
@@ -25,7 +25,7 @@
#include <ctype.h>
static unsigned int simd_support = ~0;
static THREAD_LOCAL unsigned int simd_support = ~0;
#if !(defined(__mips_dsp) && (__mips_dsp_rev >= 2)) && defined(__linux__)
@@ -55,8 +55,6 @@ parse_proc_cpuinfo(const char *search_string)
/*
* Check what SIMD accelerations are supported.
*
* FIXME: This code is racy under a multi-threaded environment.
*/
LOCAL(void)
init_simd(void)