Added new thread yield macro and added new header with CAAM_ADDRESS def and a couple loose fixes

This commit is contained in:
Aidan Keefe
2026-08-05 15:42:07 -06:00
parent 10f6294d5d
commit 7323dea41b
25 changed files with 170 additions and 68 deletions
+2 -2
View File
@@ -366,11 +366,11 @@ int wc_Sha256_Grow(wc_Sha256* sha256, const byte* in, int inSz);
\return negative on error
\param src Source SHA256 structure
\param dst Destination SHA256 structure
\param dst Destination SHA256 structure; must be zeroed/initialized
_Example_
\code
wc_Sha256 src, dst;
wc_Sha256 src, dst = {0};
int ret = wc_Sha256Copy(&src, &dst);
\endcode
+5 -2
View File
@@ -3262,6 +3262,8 @@ int test_wc_AesGcmEncryptDecrypt_Sizes(void)
int sz;
int i;
WC_DECLARE_VAR(plain, byte, GCM_LEN, NULL);
/* enlarged size is to accommodate devcrypto build which assumes
* space in buffer to append auth tag */
WC_DECLARE_VAR(cipher, byte, GCM_LEN+WC_AES_BLOCK_SIZE, NULL);
#ifdef HAVE_AES_DECRYPT
WC_DECLARE_VAR(decrypted, byte, GCM_LEN, NULL);
@@ -3288,7 +3290,7 @@ int test_wc_AesGcmEncryptDecrypt_Sizes(void)
ExpectIntEQ(wc_AesGcmSetKey(&aes, key32, sizeof(key32)/sizeof(byte)), 0);
for (sz = 0; sz < WC_AES_BLOCK_SIZE; sz++) {
XMEMSET(cipher, 0, GCM_LEN);
XMEMSET(cipher, 0, GCM_LEN + WC_AES_BLOCK_SIZE);
ExpectIntEQ(wc_AesGcmEncrypt(&aes, cipher, plain, sz, iv, ivLen, tag,
sizeof(tag), NULL, 0), 0);
ExpectBufEQ(cipher, expected, sz);
@@ -3304,7 +3306,7 @@ int test_wc_AesGcmEncryptDecrypt_Sizes(void)
i = 0;
for (sz = WC_AES_BLOCK_SIZE; sz <= GCM_LEN; sz *= 2) {
XMEMSET(cipher, 0, GCM_LEN);
XMEMSET(cipher, 0, GCM_LEN + WC_AES_BLOCK_SIZE);
ExpectIntEQ(wc_AesGcmEncrypt(&aes, cipher, plain, sz, iv, ivLen, tag,
sizeof(tag), NULL, 0), 0);
ExpectBufEQ(tag, expTagLong[i], WC_AES_BLOCK_SIZE);
@@ -3996,6 +3998,7 @@ int test_wc_AesGcmNonStdNonce(void)
!defined(HAVE_FIPS) && \
!defined(WOLFSSL_AFALG) && !defined(WOLFSSL_KCAPI) && \
!defined(WOLFSSL_DEVCRYPTO_AES)
/* DEVCRYPTO does not support Non std Nonce */
/* ------------------------------------------------------------------
* Section 1: 1-byte IV, AES-128
+2
View File
@@ -5972,6 +5972,7 @@ static void AesSetKey_C(Aes* aes, const byte* key, word32 keySz, int dir)
#if defined(WOLFSSL_DEVCRYPTO) && \
(defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC))
aes->ctx.inited = 0;
aes->ctx.cfd = -1;
#endif
#ifdef WOLFSSL_IMX6_CAAM_BLOB
#ifdef WOLFSSL_CHECK_MEM_ZERO
@@ -15787,6 +15788,7 @@ int wc_AesInit(Aes* aes, void* heap, int devId)
#if defined(WOLFSSL_DEVCRYPTO) && \
(defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC))
aes->ctx.inited = 0;
aes->ctx.cfd = -1;
#endif
#if defined(WOLFSSL_IMXRT_DCP)
DCPAesInit(aes);
+2 -2
View File
@@ -1570,13 +1570,13 @@
pc1m[(l = j + totrot[i]) < (j < 28 ? 28 : 56) ? l : l-28];
/* rotate left and right halves independently */
for (j = 0; j < 48; j++) { /* select bits individually */
for (j = 0; j < 48; j++) { /* select bits individually */
byte bit;
byte mask;
bit =
(byte)(pcr[pc2[j] - 1]); /* all pcr values are either 0 or 1 */
mask = (byte)(0 - bit); /* mask is either 0xFF or 0x00 */
/* only set to bytebit value if bit == 1*/
/* only set to bytebit value if bit == 1 */
ks[j/6] |=
(byte)((bytebit[j % 6] >> 2) & mask);
}
+1 -1
View File
@@ -1151,7 +1151,7 @@ int wc_DsaVerify_ex(const byte* digest, word32 digestSz, const byte* sig,
if (digest == NULL || sig == NULL || key == NULL || answer == NULL)
return BAD_FUNC_ARG;
/* assign default value so we return 0 on error */
/* assign default value so verification is always failed on error */
*answer = 0;
/* Note the min allowed digestSz here is WC_SHA_DIGEST_SIZE, not
+4
View File
@@ -270,6 +270,10 @@ ECC Curve Sizes:
#include <wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h>
#endif
#if defined(WOLFSSL_CAAM)
#include <wolfssl/wolfcrypt/port/caam/wolfcaam.h>
#endif
#if defined(WOLFSSL_KCAPI_ECC)
#include <wolfssl/wolfcrypt/port/kcapi/kcapi_ecc.h>
#endif
+1
View File
@@ -1537,6 +1537,7 @@ int wc_HmacInit(Hmac* hmac, void* heap, int devId)
#endif
#if defined(WOLFSSL_DEVCRYPTO_HMAC)
hmac->ctx.inited = 0;
hmac->ctx.cfd = -1;
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
@@ -983,7 +983,7 @@ static CB_INLINE int wolfssl_ssl_conf_verify_cb_no_signer(int preverify,
/* Clean up and exit */
if ((_crt_found == 0) && (bundle_cert != NULL)) {
ESP_LOGW(TAG, "Cert not found, free bundle_cert");
/* this_subject and this_issuer are apart of bundle_cert and will be
/* this_subject and this_issuer are a part of bundle_cert and will be
* freed here*/
wolfSSL_X509_free(bundle_cert);
bundle_cert = NULL;
@@ -418,7 +418,7 @@ static int FSPSM_HashFinal(wolfssl_FSPSM_Hash* hash, byte* out, word32 outSz)
#endif
wc_fspsm_hw_lock();
if ((ret = Init(&handle)) == FSP_SUCCESS) {
if (Init(&handle) == FSP_SUCCESS) {
ret = Update(&handle, (uint8_t*)hash->msg, hash->used);
if (ret == FSP_SUCCESS) {
ret = Final(&handle, out, (uint32_t*)&sz);
@@ -433,6 +433,10 @@ static int FSPSM_HashFinal(wolfssl_FSPSM_Hash* hash, byte* out, word32 outSz)
}
}
}
if (ret != FSP_SUCCESS)
ret = WC_HW_E;
wc_fspsm_hw_unlock();
#elif defined(WOLFSSL_RENESAS_RSIP)
+1 -1
View File
@@ -339,7 +339,7 @@ int wc_CAAM_EccSign(const byte* in, int inlen, byte* out, word32* outlen,
/* private key */
if (key->blackKey == CAAM_BLACK_KEY_SM) {
buf[idx].TheAddress = (CAAM_ADDRESS)key->blackKey;
buf[idx].TheAddress = key->blackKey;
args[0] = CAAM_BLACK_KEY_SM; /* is a black key in sm */
buf[idx].Length = keySz;
}
+1 -1
View File
@@ -54,7 +54,7 @@ int wc_CAAM_Hmac(Hmac* hmac, int macType, const byte* msg, int msgSz,
{
int ret = 0;
if (hmac->ctx.cfd == -1 && hmac->keyLen > 0) {
if (hmac->ctx.inited == 0 && hmac->keyLen > 0) {
ret = wc_DevCrypto_HmacSetKey(hmac, macType, hmac->keyRaw,
hmac->keyLen);
if (ret != 0) {
+10 -15
View File
@@ -193,12 +193,11 @@ int wc_Sha256GetHash(wc_Sha256* sha, byte* hash)
#ifdef WOLFSSL_DEVCRYPTO_HASH_KEEP
{
int ret;
wc_Sha256 cpy;
XMEMSET(&cpy, 0, sizeof(cpy)); /* ZII */
wc_Sha256 cpy = {0};
ret = wc_Sha256Copy(sha, &cpy);
if (ret == 0 &&
(ret = HashUpdate(&cpy, CRYPTO_SHA2_256, cpy.msg, cpy.used)) == 0) {
if (ret == 0 && (ret = HashUpdate(&cpy,
CRYPTO_SHA2_256, cpy.msg, cpy.used)) == 0) {
/* help static analysis tools out */
XMEMSET(hash, 0, WC_SHA256_DIGEST_SIZE);
ret = GetDigest(&cpy, CRYPTO_SHA2_256, hash);
@@ -226,25 +225,21 @@ int wc_Sha256Copy(wc_Sha256* src, wc_Sha256* dst)
#ifdef WOLFSSL_DEVCRYPTO_HASH_KEEP
wc_Sha256Free(dst);
if ((ret = wc_InitSha256_ex(dst, src->heap, 0)) != 0) {
/* make sure that any attempts to free dst
* dont accidentally close an unopened fd */
dst->ctx.inited = 0;
dst->ctx.cfd = -1;
return ret;
}
dst->len = src->len;
dst->used = src->used;
dst->msg = (byte*)XMALLOC(src->len, dst->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
wc_Sha256Free(dst);
return MEMORY_E;
if (src->len > 0) {
dst->msg = (byte*)XMALLOC(src->len, dst->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
wc_Sha256Free(dst);
return MEMORY_E;
}
XMEMCPY(dst->msg, src->msg, src->len);
}
XMEMCPY(dst->msg, src->msg, src->len);
return ret;
#else
(void)src;
(void)dst;
(void)ret;
WOLFSSL_MSG("Compile with WOLFSSL_DEVCRYPTO_HASH_KEEP for this feature");
+43 -22
View File
@@ -386,10 +386,10 @@ static int sha512DrbgDisabled = 0;
#endif /* WOLFSSL_DRBG_SHA512 */
enum {
wc_DrbgState_Mutex_Uninited,
wc_DrbgState_Mutex_InitProgress,
wc_DrbgState_Mutex_FreeProgress,
wc_DrbgState_Mutex_Inited
WC_DRBG_MUTEX_UNINITED,
WC_DRBG_MUTEX_INITPROGRESS,
WC_DRBG_MUTEX_FREEPROGRESS,
WC_DRBG_MUTEX_INITED
};
#ifndef SINGLE_THREADED
@@ -398,9 +398,9 @@ static wolfSSL_Mutex drbgStateMutex
#ifndef WOLFSSL_MUTEX_INITIALIZER
#ifdef WOLFSSL_ATOMIC_OPS
static wolfSSL_Atomic_Int drbgStateMutex_inited =
WOLFSSL_ATOMIC_INITIALIZER(wc_DrbgState_Mutex_Uninited);
WOLFSSL_ATOMIC_INITIALIZER(WC_DRBG_MUTEX_UNINITED);
#else
static int drbgStateMutex_inited = 0;
static volatile int drbgStateMutex_inited = 0;
#endif
#endif
#endif /* !SINGLE_THREADED */
@@ -410,34 +410,45 @@ int wc_DrbgState_MutexInit(void)
{
#ifndef SINGLE_THREADED
#ifndef WOLFSSL_MUTEX_INITIALIZER
#if defined(WOLFSSL_ATOMIC_OPS) && defined(WOLFSSL_THREAD_YIELD)
/* State machine so the mutex isn't marked ready before it is. The CAS
* winner initializes and publishes Inited; losers spin (via their own
* 'expected', which the failed CAS updates) until they see Inited. */
for (;;) {
int expected = wc_DrbgState_Mutex_Uninited;
WC_ATOMIC_INT_ARG expected = WC_DRBG_MUTEX_UNINITED;
if (wolfSSL_Atomic_Int_CompareExchange(&drbgStateMutex_inited,
&expected, wc_DrbgState_Mutex_InitProgress)) {
&expected, WC_DRBG_MUTEX_INITPROGRESS)) {
/* We own initialization (state moved Uninited -> InitProgress). */
int ret = wc_InitMutex(&drbgStateMutex);
if (ret != 0) {
/* Init failed; release ownership so another thread may retry. */
(void)wolfSSL_Atomic_Int_Exchange(&drbgStateMutex_inited,
wc_DrbgState_Mutex_Uninited);
WC_DRBG_MUTEX_UNINITED);
return ret;
}
/* Publish the fully initialized mutex. */
(void)wolfSSL_Atomic_Int_Exchange(&drbgStateMutex_inited,
wc_DrbgState_Mutex_Inited);
WC_DRBG_MUTEX_INITED);
return 0;
}
/* Spin until drbgStateMutex is inited */
if (expected == wc_DrbgState_Mutex_Inited) {
if (expected == WC_DRBG_MUTEX_INITED) {
/* Mutex is fully initialized. */
return 0;
}
continue;
WOLFSSL_THREAD_YIELD();
}
#else
if (drbgStateMutex_inited == WC_DRBG_MUTEX_UNINITED) {
int ret = wc_InitMutex(&drbgStateMutex);
if (ret != 0) {
return ret;
}
drbgStateMutex_inited = WC_DRBG_MUTEX_INITED;
}
#endif
#endif
#endif
return 0;
@@ -447,13 +458,14 @@ int wc_DrbgState_MutexFree(void)
{
#ifndef SINGLE_THREADED
#ifndef WOLFSSL_MUTEX_INITIALIZER
#if defined(WOLFSSL_ATOMIC_OPS) && defined(WOLFSSL_THREAD_YIELD)
/* CAS the ready state (Inited -> FreeProgress) so exactly one caller frees.
* Losers spin until it settles: Uninited returns success; Inited (a free
* that failed and rolled back) lets a spinning thread retry. */
for (;;) {
int expected = wc_DrbgState_Mutex_Inited;
WC_ATOMIC_INT_ARG expected = WC_DRBG_MUTEX_INITED;
if (wolfSSL_Atomic_Int_CompareExchange(&drbgStateMutex_inited,
&expected, wc_DrbgState_Mutex_FreeProgress)) {
&expected, WC_DRBG_MUTEX_FREEPROGRESS)) {
/* We own teardown (state moved Inited -> FreeProgress). */
int ret = wc_FreeMutex(&drbgStateMutex);
if (ret != 0) {
@@ -461,25 +473,31 @@ int wc_DrbgState_MutexFree(void)
* valid object, so restore the ready state rather than leaving
* the flag claiming it is uninitialized. */
(void)wolfSSL_Atomic_Int_Exchange(&drbgStateMutex_inited,
wc_DrbgState_Mutex_Inited);
WC_DRBG_MUTEX_INITED);
return ret;
}
/* Mark the mutex as no longer initialized. */
(void)wolfSSL_Atomic_Int_Exchange(&drbgStateMutex_inited,
wc_DrbgState_Mutex_Uninited);
WC_DRBG_MUTEX_UNINITED);
return 0;
}
/* CAS failed; 'expected' holds the observed state. */
if (expected == wc_DrbgState_Mutex_Uninited) {
if (expected == WC_DRBG_MUTEX_UNINITED) {
/* Already freed or never initialized; nothing to do. */
return 0;
}
/* expected == InitProgress or FreeProgress: another thread is busy;
* spin until it settles. */
continue;
}
return 0;
WOLFSSL_THREAD_YIELD();
}
#else
if (drbgStateMutex_inited == WC_DRBG_MUTEX_INITED) {
int ret = wc_FreeMutex(&drbgStateMutex);
if (ret != 0) {
return ret;
}
drbgStateMutex_inited = WC_DRBG_MUTEX_UNINITED;
}
#endif
#endif
#endif
return 0;
@@ -3905,6 +3923,7 @@ static int wc_GenerateSeed_IntelRD(OS_Seed* os, byte* output, word32 sz)
return ret;
}
writeUnalignedWord64(output, rndTmpLocal);
ForceZero(&rndTmpLocal, sizeof(rndTmpLocal));
}
if (sz == 0)
return 0;
@@ -3992,6 +4011,7 @@ static int wc_GenerateRand_IntelRD(OS_Seed* os, byte* output, word32 sz)
return ret;
}
writeUnalignedWord64(output, rndTmpLocal);
ForceZero(&rndTmpLocal, sizeof(rndTmpLocal));
}
if (sz == 0)
return 0;
@@ -4002,6 +4022,7 @@ static int wc_GenerateRand_IntelRD(OS_Seed* os, byte* output, word32 sz)
return ret;
XMEMCPY(output, &rndTmp, sz);
ForceZero(&rndTmp, sizeof(rndTmp));
return 0;
}
+2 -2
View File
@@ -5110,7 +5110,7 @@ static int mlkem_get_noise_k4_avx512(MLKEM_PRF_T* prf, sword16* vec1,
*/
static void mlkem_get_noise_x3_eta2_aarch64(byte* rand, byte* seed, byte o)
{
word64 state[3 * 25];
word64 state[3 * 25] = {0};
state[0*25 + 4] = 0x1f00 + 0 + o;
state[1*25 + 4] = 0x1f00 + 1 + o;
@@ -5143,7 +5143,7 @@ static void mlkem_get_noise_x3_eta2_aarch64(byte* rand, byte* seed, byte o)
*/
static void mlkem_get_noise_x3_eta3_aarch64(byte* rand, byte* seed, byte o)
{
word64 state[3 * 25];
word64 state[3 * 25] = {0};
state[0*25 + 4] = 0x1f00 + 0 + o;
state[1*25 + 4] = 0x1f00 + 1 + o;
+7 -11
View File
@@ -67,6 +67,11 @@
#include <wolfssl/wolfcrypt/port/nxp/se050_port.h>
#endif
#ifdef WOLFSSL_CAAM
/* for CAAM_ADDRESS, used by struct ecc_key below */
#include <wolfssl/wolfcrypt/port/caam/caam_type.h>
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include <wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h>
#endif
@@ -76,10 +81,6 @@
#endif
#if defined(WOLFSSL_CAAM)
#include <wolfssl/wolfcrypt/port/caam/wolfcaam.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -532,13 +533,8 @@ struct ecc_key {
#endif
#ifdef WOLFSSL_CAAM
#ifdef CAAM_ADDRESS
CAAM_ADDRESS blackKey; /* address of key encrypted and in secure memory */
CAAM_ADDRESS securePubKey; /* address of public key in secure memory */
#else
word32 blackKey; /* address of key encrypted and in secure memory */
word32 securePubKey; /* address of public key in secure memory */
#endif
CAAM_ADDRESS blackKey; /* address of key encrypted and in secure memory */
CAAM_ADDRESS securePubKey; /* address of public key in secure memory */
int partNum; /* partition number*/
#endif
#ifdef WOLFSSL_SE050
+2 -1
View File
@@ -209,7 +209,8 @@ endif
endif
if BUILD_CAAM
nobase_include_HEADERS+= wolfssl/wolfcrypt/port/caam/wolfcaam.h \
nobase_include_HEADERS+= wolfssl/wolfcrypt/port/caam/caam_type.h \
wolfssl/wolfcrypt/port/caam/wolfcaam.h \
wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h \
wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h \
wolfssl/wolfcrypt/port/caam/wolfcaam_rsa.h \
+2 -1
View File
@@ -41,10 +41,11 @@
#define CAAM_LOCK_MUTEX(x) pthread_mutex_lock((x))
#define CAAM_UNLOCK_MUTEX(x) pthread_mutex_unlock((x))
#include <wolfssl/wolfcrypt/port/caam/caam_type.h>
#define Error int
#define Value int
#define Boolean int
#define CAAM_ADDRESS uintptr_t
#define Success 1
#define Failure 0
#define INTERRUPT_Panic() do {} while (0)
+48
View File
@@ -0,0 +1,48 @@
/* caam_type.h
*
* Copyright (C) 2006-2026 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/* Single definition of CAAM_ADDRESS, the type used to hold an address handed to
* or returned from the CAAM.
*
* struct ecc_key stores CAAM addresses, so its layout depends on this type.
* Keep the definition here, selected only from build configuration macros, so
* that every translation unit in a build agrees on it no matter which of the
* CAAM headers it happens to include, and in which order.
*
* This header intentionally has no wolfSSL dependencies; the standalone QNX
* driver build includes it without settings.h. Whatever includes it is expected
* to have already pulled in settings.h if it needs the configuration macros.
*/
#ifndef WOLF_CRYPT_CAAM_TYPE_H
#define WOLF_CRYPT_CAAM_TYPE_H
#include <stdint.h>
#ifndef CAAM_ADDRESS
#ifdef WOLFSSL_SECO_CAAM
#define CAAM_ADDRESS intptr_t
#else
#define CAAM_ADDRESS uintptr_t
#endif
#endif
#endif /* WOLF_CRYPT_CAAM_TYPE_H */
+1
View File
@@ -24,6 +24,7 @@
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/port/caam/caam_type.h>
/* include for porting layer */
#ifdef WOLFSSL_QNX_CAAM
@@ -50,7 +50,7 @@
#define NoActivityReady -1
#define MemoryOperationNotPerformed -1
#define CAAM_ADDRESS uintptr_t
#include <wolfssl/wolfcrypt/port/caam/caam_type.h>
#ifndef WOLFSSL_CAAM_BUFFER
#define WOLFSSL_CAAM_BUFFER
typedef struct CAAM_BUFFER {
+1 -1
View File
@@ -41,7 +41,7 @@
#define NoActivityReady -1
#define MemoryOperationNotPerformed -1
#define CAAM_ADDRESS uintptr_t
#include <wolfssl/wolfcrypt/port/caam/caam_type.h>
#ifndef WOLFSSL_CAAM_BUFFER
#define WOLFSSL_CAAM_BUFFER
typedef struct CAAM_BUFFER {
+1 -2
View File
@@ -44,8 +44,7 @@
#define NoActivityReady -1
#define MemoryOperationNotPerformed -1
#include <stdint.h>
#define CAAM_ADDRESS intptr_t
#include <wolfssl/wolfcrypt/port/caam/caam_type.h>
#ifndef WOLFSSL_CAAM_BUFFER
#define WOLFSSL_CAAM_BUFFER
typedef struct CAAM_BUFFER {
@@ -38,7 +38,7 @@
typedef struct WC_CRYPTODEV {
int cfd;
word8 inited : 1;/* is this object initialized (1) or not (0) */
unsigned int inited : 1;/* is this object initialized (1) or not (0) */
struct session_op sess;
} WC_CRYPTODEV;
+2
View File
@@ -3153,6 +3153,7 @@
#endif
#ifdef WOLFSSL_SECO_CAAM
#undef WOLFSSL_CAAM
#define WOLFSSL_CAAM
#define WOLFSSL_HASH_KEEP
@@ -3160,6 +3161,7 @@
#endif
#ifdef WOLFSSL_IMXRT1170_CAAM
#undef WOLFSSL_CAAM
#define WOLFSSL_CAAM
#endif
+24
View File
@@ -773,6 +773,30 @@
}
#endif
/* Yield the CPU to another runnable thread. Used by spin-wait loops that are
* waiting on another thread to finish a short critical section. Ports may
* override. */
#ifndef WOLFSSL_THREAD_YIELD
#if defined(SINGLE_THREADED)
#define WOLFSSL_THREAD_YIELD() WC_DO_NOTHING
#elif defined(WOLFSSL_PTHREADS)
#include <sched.h>
#define WOLFSSL_THREAD_YIELD() (void)sched_yield()
#elif defined(USE_WINDOWS_API) && !defined(WOLFSSL_NOT_WINDOWS_API)
#define WOLFSSL_THREAD_YIELD() (void)SwitchToThread()
#elif defined(FREERTOS)
#define WOLFSSL_THREAD_YIELD() taskYIELD()
#elif defined(THREADX)
#define WOLFSSL_THREAD_YIELD() tx_thread_relinquish()
#elif defined(WOLFSSL_ZEPHYR)
#define WOLFSSL_THREAD_YIELD() k_yield()
#elif defined(WOLFSSL_VXWORKS)
#include <vxWorks.h>
#include <taskLib.h>
#define WOLFSSL_THREAD_YIELD() (void)taskDelay(0)
#endif
#endif
/* Reference counting. */
typedef struct wolfSSL_RefWithMutex {
#if !defined(SINGLE_THREADED)