Skip to content

Commit ffe3d80

Browse files
Merge pull request #9097 from douzzer/20250812-atomic-cmpxchg
20250812-atomic-cmpxchg
2 parents 5b1302e + cefeb4c commit ffe3d80

File tree

19 files changed

+656
-231
lines changed

19 files changed

+656
-231
lines changed

.github/workflows/pq-all.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
'--enable-intelasm --enable-sp-asm --enable-mlkem=yes,kyber,ml-kem CPPFLAGS="-DWOLFSSL_ML_KEM_USE_OLD_IDS"',
2222
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-kyber=yes,original --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
2323
'--enable-smallstack --enable-smallstackcache --enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-kyber=yes,original --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
24-
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-kyber=yes,original --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE" CC=c++'
24+
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-kyber=yes,original --enable-lms --enable-xmss --enable-dilithium --enable-dual-alg-certs --disable-qt CPPFLAGS="-Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE" CC=c++'
2525
]
2626
name: make check
2727
if: github.repository_owner == 'wolfssl'

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ WOLFSSL_TLSX_PQC_MLKEM_STORE_PRIV_KEY
877877
WOLFSSL_TRACK_MEMORY_FULL
878878
WOLFSSL_TRAP_MALLOC_SZ
879879
WOLFSSL_UNALIGNED_64BIT_ACCESS
880+
WOLFSSL_USER_DEFINED_ATOMICS
880881
WOLFSSL_USER_FILESYSTEM
881882
WOLFSSL_USER_LOG
882883
WOLFSSL_USER_MUTEX

tests/api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42088,10 +42088,10 @@ static int test_wolfSSL_dtls_bad_record(void)
4208842088
!defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && \
4208942089
defined(HAVE_IO_TESTS_DEPENDENCIES)
4209042090
static volatile int test_AEAD_seq_num = 0;
42091-
#ifdef WOLFSSL_ATOMIC_INITIALIZER
42092-
wolfSSL_Atomic_Int test_AEAD_done = WOLFSSL_ATOMIC_INITIALIZER(0);
42093-
#else
42091+
#ifdef WOLFSSL_NO_ATOMICS
4209442092
static volatile int test_AEAD_done = 0;
42093+
#else
42094+
wolfSSL_Atomic_Int test_AEAD_done = WOLFSSL_ATOMIC_INITIALIZER(0);
4209542095
#endif
4209642096
#ifdef WOLFSSL_MUTEX_INITIALIZER
4209742097
static wolfSSL_Mutex test_AEAD_mutex = WOLFSSL_MUTEX_INITIALIZER(test_AEAD_mutex);

wolfcrypt/src/aes.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,11 @@ block cipher mechanism that uses n-bit binary string parameter key with 128-bits
624624
*/
625625
static int checkedAESNI = 0;
626626
static int haveAESNI = 0;
627-
static word32 intel_flags = 0;
627+
static cpuid_flags_t intel_flags = WC_CPUID_INITIALIZER;
628628

629629
static WARN_UNUSED_RESULT int Check_CPU_support_AES(void)
630630
{
631-
intel_flags = cpuid_get_flags();
631+
cpuid_get_flags_ex(&intel_flags);
632632

633633
return IS_INTEL_AESNI(intel_flags) != 0;
634634
}
@@ -786,15 +786,11 @@ block cipher mechanism that uses n-bit binary string parameter key with 128-bits
786786

787787
#define NEED_AES_TABLES
788788

789-
static int checkedCpuIdFlags = 0;
790-
static word32 cpuid_flags = 0;
789+
static cpuid_flags_t cpuid_flags = WC_CPUID_INITIALIZER;
791790

792791
static void Check_CPU_support_HwCrypto(Aes* aes)
793792
{
794-
if (checkedCpuIdFlags == 0) {
795-
cpuid_flags = cpuid_get_flags();
796-
checkedCpuIdFlags = 1;
797-
}
793+
cpuid_get_flags_ex(&cpuid_flags);
798794
aes->use_aes_hw_crypto = IS_AARCH64_AES(cpuid_flags);
799795
#ifdef HAVE_AESGCM
800796
aes->use_pmull_hw_crypto = IS_AARCH64_PMULL(cpuid_flags);

wolfcrypt/src/chacha.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ Public domain.
109109
#define HAVE_INTEL_AVX2
110110
#endif
111111

112-
static int cpuidFlagsSet = 0;
113-
static word32 cpuidFlags = 0;
112+
static cpuid_flags_t cpuidFlags = WC_CPUID_INITIALIZER;
114113
#endif
115114

116115
/**
@@ -332,10 +331,7 @@ int wc_Chacha_Process(ChaCha* ctx, byte* output, const byte* input,
332331
return 0;
333332
}
334333

335-
if (!cpuidFlagsSet) {
336-
cpuidFlags = cpuid_get_flags();
337-
cpuidFlagsSet = 1;
338-
}
334+
cpuid_get_flags_ex(&cpuidFlags);
339335

340336
#ifdef HAVE_INTEL_AVX2
341337
if (IS_INTEL_AVX2(cpuidFlags)) {

0 commit comments

Comments
 (0)