mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-26 17:52:23 +01:00
Merge pull request #9382 from douzzer/20251104-WC_MUTEX_OPS_INLINE
20251104-WC_MUTEX_OPS_INLINE
This commit is contained in:
@@ -616,6 +616,7 @@ WC_RSA_DIRECT
|
||||
WC_RSA_NONBLOCK
|
||||
WC_RSA_NONBLOCK_TIME
|
||||
WC_RSA_NO_FERMAT_CHECK
|
||||
WC_RWLOCK_OPS_INLINE
|
||||
WC_SHA384
|
||||
WC_SHA384_DIGEST_SIZE
|
||||
WC_SHA512
|
||||
|
||||
@@ -1368,6 +1368,8 @@
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
#ifdef WOLFSSL_LINUXKM_USE_MUTEXES
|
||||
#define WC_MUTEX_OPS_INLINE
|
||||
|
||||
#ifdef LINUXKM_LKCAPI_REGISTER
|
||||
/* must use spin locks when registering implementations with the
|
||||
* kernel, because mutexes are forbidden when calling with nonzero
|
||||
@@ -1412,6 +1414,8 @@
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#define WC_MUTEX_OPS_INLINE
|
||||
|
||||
/* if BUILDING_WOLFSSL, spinlock.h will have already been included
|
||||
* recursively above, with the bevy of warnings suppressed, and the
|
||||
* below include will be a redundant no-op.
|
||||
|
||||
@@ -1880,7 +1880,12 @@ int wolfSSL_HwPkMutexUnLock(void)
|
||||
return compat_mutex_cb;
|
||||
}
|
||||
#endif /* defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) */
|
||||
#ifdef SINGLE_THREADED
|
||||
|
||||
#if defined(WC_MUTEX_OPS_INLINE)
|
||||
|
||||
/* defined in headers */
|
||||
|
||||
#elif defined(SINGLE_THREADED)
|
||||
|
||||
int wc_InitMutex(wolfSSL_Mutex* m)
|
||||
{
|
||||
@@ -2423,10 +2428,6 @@ int wolfSSL_HwPkMutexUnLock(void)
|
||||
else
|
||||
return BAD_MUTEX_E;
|
||||
}
|
||||
#elif defined(WOLFSSL_LINUXKM)
|
||||
|
||||
/* defined as inlines in linuxkm/linuxkm_wc_port.h */
|
||||
|
||||
#elif defined(WOLFSSL_VXWORKS)
|
||||
|
||||
int wc_InitMutex(wolfSSL_Mutex* m)
|
||||
@@ -3472,7 +3473,8 @@ int wolfSSL_HwPkMutexUnLock(void)
|
||||
#warning No mutex handling defined
|
||||
|
||||
#endif
|
||||
#if !defined(WOLFSSL_USE_RWLOCK) || defined(SINGLE_THREADED)
|
||||
#if !defined(WOLFSSL_USE_RWLOCK) || defined(SINGLE_THREADED) || \
|
||||
(defined(WC_MUTEX_OPS_INLINE) && !defined(WC_RWLOCK_OPS_INLINE))
|
||||
int wc_InitRwLock(wolfSSL_RwLock* m)
|
||||
{
|
||||
return wc_InitMutex(m);
|
||||
|
||||
@@ -472,7 +472,8 @@
|
||||
#define WOLFSSL_MUTEX_INITIALIZER_CLAUSE(lockname) /* null expansion */
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USE_RWLOCK) || defined(SINGLE_THREADED)
|
||||
#if !defined(WOLFSSL_USE_RWLOCK) || defined(SINGLE_THREADED) || \
|
||||
(defined(WC_MUTEX_OPS_INLINE) && !defined(WC_RWLOCK_OPS_INLINE))
|
||||
typedef wolfSSL_Mutex wolfSSL_RwLock;
|
||||
#endif
|
||||
|
||||
@@ -829,17 +830,21 @@ WOLFSSL_LOCAL void wolfSSL_RefWithMutexDec(wolfSSL_RefWithMutex* ref,
|
||||
#endif /* !defined(NO_PK_MUTEX) && defined(WOLFSSL_ALGO_HW_MUTEX) */
|
||||
|
||||
/* Mutex functions */
|
||||
WOLFSSL_API int wc_InitMutex(wolfSSL_Mutex* m);
|
||||
#ifndef WC_MUTEX_OPS_INLINE
|
||||
WOLFSSL_API int wc_InitMutex(wolfSSL_Mutex* m);
|
||||
WOLFSSL_API int wc_FreeMutex(wolfSSL_Mutex* m);
|
||||
WOLFSSL_API int wc_LockMutex(wolfSSL_Mutex* m);
|
||||
WOLFSSL_API int wc_UnLockMutex(wolfSSL_Mutex* m);
|
||||
#endif
|
||||
WOLFSSL_API wolfSSL_Mutex* wc_InitAndAllocMutex(void);
|
||||
WOLFSSL_API int wc_FreeMutex(wolfSSL_Mutex* m);
|
||||
WOLFSSL_API int wc_LockMutex(wolfSSL_Mutex* m);
|
||||
WOLFSSL_API int wc_UnLockMutex(wolfSSL_Mutex* m);
|
||||
/* RwLock functions. Fallback to Mutex when not implemented explicitly. */
|
||||
WOLFSSL_API int wc_InitRwLock(wolfSSL_RwLock* m);
|
||||
WOLFSSL_API int wc_FreeRwLock(wolfSSL_RwLock* m);
|
||||
WOLFSSL_API int wc_LockRwLock_Wr(wolfSSL_RwLock* m);
|
||||
WOLFSSL_API int wc_LockRwLock_Rd(wolfSSL_RwLock* m);
|
||||
WOLFSSL_API int wc_UnLockRwLock(wolfSSL_RwLock* m);
|
||||
#ifndef WC_RWLOCK_OPS_INLINE
|
||||
/* RwLock functions. Fallback to Mutex when not implemented explicitly. */
|
||||
WOLFSSL_API int wc_InitRwLock(wolfSSL_RwLock* m);
|
||||
WOLFSSL_API int wc_FreeRwLock(wolfSSL_RwLock* m);
|
||||
WOLFSSL_API int wc_LockRwLock_Wr(wolfSSL_RwLock* m);
|
||||
WOLFSSL_API int wc_LockRwLock_Rd(wolfSSL_RwLock* m);
|
||||
WOLFSSL_API int wc_UnLockRwLock(wolfSSL_RwLock* m);
|
||||
#endif
|
||||
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
|
||||
/* dynamically set which mutex to use. unlock / lock is controlled by flag */
|
||||
typedef void (mutex_cb)(int flag, int type, const char* file, int line);
|
||||
|
||||
Reference in New Issue
Block a user