forked from wolfSSL/wolfssl
Tentative: User defined mutex
This commit is contained in:
27
user-mutex.c
Normal file
27
user-mutex.c
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include <wolfssl/wolfcrypt/wc_port.h>
|
||||||
|
|
||||||
|
int wc_InitMutex(wolfSSL_Mutex* m)
|
||||||
|
{
|
||||||
|
(void)m;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wc_FreeMutex(wolfSSL_Mutex *m)
|
||||||
|
{
|
||||||
|
(void)m;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wc_LockMutex(wolfSSL_Mutex *m)
|
||||||
|
{
|
||||||
|
(void)m;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wc_UnLockMutex(wolfSSL_Mutex *m)
|
||||||
|
{
|
||||||
|
(void)m;
|
||||||
|
return 0;
|
||||||
|
}
|
2
user_settings.h
Normal file
2
user_settings.h
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
typedef int wolfSSL_Mutex;
|
@@ -647,7 +647,7 @@ int z_fs_close(XFILE file)
|
|||||||
|
|
||||||
#endif /* !NO_FILESYSTEM && !WOLFSSL_ZEPHYR */
|
#endif /* !NO_FILESYSTEM && !WOLFSSL_ZEPHYR */
|
||||||
|
|
||||||
|
#if !defined(WOLFSSL_USER_MUTEX)
|
||||||
wolfSSL_Mutex* wc_InitAndAllocMutex(void)
|
wolfSSL_Mutex* wc_InitAndAllocMutex(void)
|
||||||
{
|
{
|
||||||
wolfSSL_Mutex* m = (wolfSSL_Mutex*) XMALLOC(sizeof(wolfSSL_Mutex), NULL,
|
wolfSSL_Mutex* m = (wolfSSL_Mutex*) XMALLOC(sizeof(wolfSSL_Mutex), NULL,
|
||||||
@@ -665,6 +665,7 @@ wolfSSL_Mutex* wc_InitAndAllocMutex(void)
|
|||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WOLF_STRTOK
|
#ifdef USE_WOLF_STRTOK
|
||||||
/* String token (delim) search. If str is null use nextp. */
|
/* String token (delim) search. If str is null use nextp. */
|
||||||
@@ -1845,6 +1846,10 @@ int wolfSSL_CryptHwMutexUnLock(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(WOLFSSL_USER_MUTEX)
|
||||||
|
|
||||||
|
/* Use user own mutex */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#warning No mutex handling defined
|
#warning No mutex handling defined
|
||||||
|
|
||||||
|
@@ -156,9 +156,11 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
#ifndef SINGLE_THREADED
|
#ifndef SINGLE_THREADED
|
||||||
|
#ifndef WOLFSSL_USER_MUTEX
|
||||||
#define WOLFSSL_PTHREADS
|
#define WOLFSSL_PTHREADS
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if (defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)) && \
|
#if (defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)) && \
|
||||||
!defined(NO_FILESYSTEM)
|
!defined(NO_FILESYSTEM)
|
||||||
#include <unistd.h> /* for close of BIO */
|
#include <unistd.h> /* for close of BIO */
|
||||||
@@ -238,6 +240,8 @@
|
|||||||
typedef struct k_mutex wolfSSL_Mutex;
|
typedef struct k_mutex wolfSSL_Mutex;
|
||||||
#elif defined(WOLFSSL_TELIT_M2MB)
|
#elif defined(WOLFSSL_TELIT_M2MB)
|
||||||
typedef M2MB_OS_MTX_HANDLE wolfSSL_Mutex;
|
typedef M2MB_OS_MTX_HANDLE wolfSSL_Mutex;
|
||||||
|
#elif defined(WOLFSSL_USER_MUTEX)
|
||||||
|
/* typedef User_Mutex wolfSSL_Mutex; */
|
||||||
#else
|
#else
|
||||||
#error Need a mutex type in multithreaded mode
|
#error Need a mutex type in multithreaded mode
|
||||||
#endif /* USE_WINDOWS_API */
|
#endif /* USE_WINDOWS_API */
|
||||||
|
Reference in New Issue
Block a user