diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 165bc4a70..7ececacf4 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -963,6 +963,40 @@ int wolfSSL_CryptHwMutexUnLock(void) return 0; } +#elif defined(RTTHREAD) + + int wc_InitMutex(wolfSSL_Mutex* m) + { + int iReturn; + + *m = ( wolfSSL_Mutex ) rt_mutex_create("mutex",RT_IPC_FLAG_FIFO); + if( *m != NULL ) + iReturn = 0; + else + iReturn = BAD_MUTEX_E; + + + return iReturn; + } + + int wc_FreeMutex(wolfSSL_Mutex* m) + { + rt_mutex_delete( *m ); + return 0; + } + + + int wc_LockMutex(wolfSSL_Mutex* m) + { + /* Assume an infinite block, or should there be zero block? */ + return rt_mutex_take( *m, RT_WAITING_FOREVER ); + } + + int wc_UnLockMutex(wolfSSL_Mutex* m) + { + return rt_mutex_release( *m ); + } + #elif defined(WOLFSSL_SAFERTOS) int wc_InitMutex(wolfSSL_Mutex* m) diff --git a/wolfssl/internal.h b/wolfssl/internal.h index c9613e25d..df17511d4 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -146,6 +146,8 @@ /* do nothing, just don't pick Unix */ #elif defined(FREERTOS) || defined(FREERTOS_TCP) || defined(WOLFSSL_SAFERTOS) /* do nothing */ +#elif defined(RTTHREAD) + /* do nothing */ #elif defined(EBSNET) /* do nothing */ #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index e65d6d8d3..be8caf02e 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -207,6 +207,8 @@ /* do nothing, just don't pick Unix */ #elif defined(FREERTOS) || defined(FREERTOS_TCP) || defined(WOLFSSL_SAFERTOS) /* do nothing */ +#elif defined(RTTHREAD) + /* do nothing */ #elif defined(EBSNET) /* do nothing */ #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) @@ -312,6 +314,9 @@ #include "FreeRTOS.h" #include "semphr.h" typedef SemaphoreHandle_t wolfSSL_Mutex; + #elif defined (RTTHREAD) + #include "rtthread.h" + typedef rt_mutex_t wolfSSL_Mutex; #elif defined(WOLFSSL_SAFERTOS) typedef struct wolfSSL_Mutex { signed char mutexBuffer[portQUEUE_OVERHEAD_BYTES];