Skip to content

Commit 0d1d77a

Browse files
committed
rework thread local things for rhel7
1 parent 31f0daa commit 0d1d77a

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

common/gm_crypt.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131

3232
unsigned char key[KEYBYTES];
3333

34-
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
35-
#define TLS _Thread_local
36-
#elif defined(__GNUC__)
37-
#define TLS __thread
34+
#ifndef _Thread_local
35+
# define _Thread_local __thread
36+
#endif
37+
#if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
38+
#define THREAD_LOCAL _Thread_local
39+
#elif defined(__GNUC__) || defined(__clang__)
40+
#define THREAD_LOCAL __thread
3841
#else
39-
#error "No thread-local storage support"
42+
#error "No thread-local storage support"
4043
#endif
4144

4245
/* initialize encryption */
@@ -141,11 +144,11 @@ int mod_gm_aes_decrypt(EVP_CIPHER_CTX * ctx, unsigned char * plaintext, unsigned
141144

142145
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
143146
/* OpenSSL 3.0+ */
144-
static TLS EVP_MAC *mac = NULL;
145-
static TLS EVP_MAC_CTX *mac_ctx = NULL;
147+
static THREAD_LOCAL EVP_MAC *mac = NULL;
148+
static THREAD_LOCAL EVP_MAC_CTX *mac_ctx = NULL;
146149
#else
147150
/* OpenSSL 1.1.x and earlier */
148-
static TLS HMAC_CTX *hmac_ctx = NULL;
151+
static THREAD_LOCAL HMAC_CTX *hmac_ctx = NULL;
149152
#endif
150153

151154
int hmac_sha256_init(void) {

0 commit comments

Comments
 (0)