Improve gActiveTPM detection for needing thread local.

pull/417/head
David Garske 2025-05-27 12:24:57 -07:00
parent 57706751ab
commit cbb7c2969b
1 changed files with 11 additions and 8 deletions

View File

@ -37,23 +37,26 @@
/* --- Local Variables -- */
/******************************************************************************/
#ifdef WOLFTPM_NO_ACTIVE_THREAD_LS
/* if using gHwLock and want to use a shared active TPM2_CTX between threads */
static TPM2_CTX* gActiveTPM;
#else
static THREAD_LS_T TPM2_CTX* gActiveTPM;
#endif
#ifndef WOLFTPM2_NO_WOLFCRYPT
static volatile int gWolfCryptRefCount = 0;
#endif
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(WOLFTPM_NO_LOCK) && \
!defined(SINGLE_THREADED)
/* if a mutex lock is supported, then don't use thread local on gActiveTPM */
#undef WOLFTPM_NO_ACTIVE_THREAD_LS
#define WOLFTPM_NO_ACTIVE_THREAD_LS
static wolfSSL_Mutex gHwLock WOLFSSL_MUTEX_INITIALIZER_CLAUSE(gHwLock);
#endif
#ifdef WOLFTPM_NO_ACTIVE_THREAD_LS
/* if using gHwLock and want to use a shared active TPM2_CTX between threads */
static TPM2_CTX* gActiveTPM;
#else
static THREAD_LS_T TPM2_CTX* gActiveTPM;
#endif
#ifdef WOLFTPM_LINUX_DEV
#define INTERNAL_SEND_COMMAND TPM2_LINUX_SendCommand
#define TPM2_INTERNAL_CLEANUP(ctx)