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:
@@ -27,8 +27,8 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static unsigned int simd_support = ~0;
|
||||
static unsigned int simd_huffman = 1;
|
||||
static THREAD_LOCAL unsigned int simd_support = ~0;
|
||||
static THREAD_LOCAL unsigned int simd_huffman = 1;
|
||||
|
||||
#if !defined(__ARM_NEON__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
|
||||
|
||||
@@ -96,8 +96,6 @@ parse_proc_cpuinfo(int bufsize)
|
||||
|
||||
/*
|
||||
* Check what SIMD accelerations are supported.
|
||||
*
|
||||
* FIXME: This code is racy under a multi-threaded environment.
|
||||
*/
|
||||
LOCAL(void)
|
||||
init_simd(void)
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
#define JSIMD_FASTST3 2
|
||||
#define JSIMD_FASTTBL 4
|
||||
|
||||
static unsigned int simd_support = ~0;
|
||||
static unsigned int simd_huffman = 1;
|
||||
static unsigned int simd_features = JSIMD_FASTLD3 | JSIMD_FASTST3 |
|
||||
JSIMD_FASTTBL;
|
||||
static THREAD_LOCAL unsigned int simd_support = ~0;
|
||||
static THREAD_LOCAL unsigned int simd_huffman = 1;
|
||||
static THREAD_LOCAL unsigned int simd_features = JSIMD_FASTLD3 |
|
||||
JSIMD_FASTST3 | JSIMD_FASTTBL;
|
||||
|
||||
#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
|
||||
|
||||
@@ -109,8 +109,6 @@ parse_proc_cpuinfo(int bufsize)
|
||||
|
||||
/*
|
||||
* Check what SIMD accelerations are supported.
|
||||
*
|
||||
* FIXME: This code is racy under a multi-threaded environment.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -32,13 +32,11 @@
|
||||
#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
|
||||
#define IS_ALIGNED_AVX(ptr) (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
|
||||
|
||||
static unsigned int simd_support = (unsigned int)(~0);
|
||||
static unsigned int simd_huffman = 1;
|
||||
static THREAD_LOCAL unsigned int simd_support = (unsigned int)(~0);
|
||||
static THREAD_LOCAL unsigned int simd_huffman = 1;
|
||||
|
||||
/*
|
||||
* Check what SIMD accelerations are supported.
|
||||
*
|
||||
* FIXME: This code is racy under a multi-threaded environment.
|
||||
*/
|
||||
LOCAL(void)
|
||||
init_simd(void)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* jsimd_mips64.c
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009-2011, 2014, 2016, 2018, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2014, 2016, 2018, 2022, D. R. Commander.
|
||||
* Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
|
||||
* Copyright (C) 2015, 2018, Matthieu Darbois.
|
||||
* Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static unsigned int simd_support = ~0;
|
||||
static THREAD_LOCAL unsigned int simd_support = ~0;
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
@@ -94,8 +94,6 @@ parse_proc_cpuinfo(int bufsize)
|
||||
|
||||
/*
|
||||
* Check what SIMD accelerations are supported.
|
||||
*
|
||||
* FIXME: This code is racy under a multi-threaded environment.
|
||||
*/
|
||||
LOCAL(void)
|
||||
init_simd(void)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* jsimd_powerpc.c
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009-2011, 2014-2016, 2018, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2014-2016, 2018, 2022, D. R. Commander.
|
||||
* Copyright (C) 2015-2016, 2018, Matthieu Darbois.
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
|
||||
static unsigned int simd_support = ~0;
|
||||
static THREAD_LOCAL unsigned int simd_support = ~0;
|
||||
|
||||
#if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
|
||||
|
||||
@@ -109,8 +109,6 @@ parse_proc_cpuinfo(int bufsize)
|
||||
|
||||
/*
|
||||
* Check what SIMD accelerations are supported.
|
||||
*
|
||||
* FIXME: This code is racy under a multi-threaded environment.
|
||||
*/
|
||||
LOCAL(void)
|
||||
init_simd(void)
|
||||
|
||||
@@ -32,13 +32,11 @@
|
||||
#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
|
||||
#define IS_ALIGNED_AVX(ptr) (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
|
||||
|
||||
static unsigned int simd_support = (unsigned int)(~0);
|
||||
static unsigned int simd_huffman = 1;
|
||||
static THREAD_LOCAL unsigned int simd_support = (unsigned int)(~0);
|
||||
static THREAD_LOCAL unsigned int simd_huffman = 1;
|
||||
|
||||
/*
|
||||
* Check what SIMD accelerations are supported.
|
||||
*
|
||||
* FIXME: This code is racy under a multi-threaded environment.
|
||||
*/
|
||||
LOCAL(void)
|
||||
init_simd(void)
|
||||
|
||||
Reference in New Issue
Block a user