forked from wolfSSL/wolfssl
Merge branch 'master' of github.com:cyassl/cyassl
This commit is contained in:
@@ -106,7 +106,11 @@
|
||||
#define XGMTIME(c) gmtime((c))
|
||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
||||
#elif defined(CYASSL_MDK_ARM)
|
||||
#include <rtl.h>
|
||||
#if defined(CYASSL_MDK5)
|
||||
#include "cmsis_os.h"
|
||||
#else
|
||||
#include <rtl.h>
|
||||
#endif
|
||||
#undef RNG
|
||||
#include "cyassl_MDK_ARM.h"
|
||||
#undef RNG
|
||||
|
||||
@@ -75,7 +75,7 @@ void* CyaSSL_Malloc(size_t size)
|
||||
|
||||
#ifdef CYASSL_MALLOC_CHECK
|
||||
if (res == NULL)
|
||||
printf("CyaSSL_malloc failed\n");
|
||||
puts("CyaSSL_malloc failed");
|
||||
#endif
|
||||
|
||||
return res;
|
||||
|
||||
@@ -353,6 +353,60 @@ int UnLockMutex(CyaSSL_Mutex *m)
|
||||
}
|
||||
|
||||
#elif defined(CYASSL_MDK_ARM)
|
||||
|
||||
#if defined(CYASSL_CMSIS_RTOS)
|
||||
#include "cmsis_os.h"
|
||||
#define CMSIS_NMUTEX 10
|
||||
osMutexDef(CyaSSL_mt0) ; osMutexDef(CyaSSL_mt1) ; osMutexDef(CyaSSL_mt2) ;
|
||||
osMutexDef(CyaSSL_mt3) ; osMutexDef(CyaSSL_mt4) ; osMutexDef(CyaSSL_mt5) ;
|
||||
osMutexDef(CyaSSL_mt6) ; osMutexDef(CyaSSL_mt7) ; osMutexDef(CyaSSL_mt8) ;
|
||||
osMutexDef(CyaSSL_mt9) ;
|
||||
|
||||
static const osMutexDef_t *CMSIS_mutex[] = { osMutex(CyaSSL_mt0),
|
||||
osMutex(CyaSSL_mt1), osMutex(CyaSSL_mt2), osMutex(CyaSSL_mt3),
|
||||
osMutex(CyaSSL_mt4), osMutex(CyaSSL_mt5), osMutex(CyaSSL_mt6),
|
||||
osMutex(CyaSSL_mt7), osMutex(CyaSSL_mt8), osMutex(CyaSSL_mt9) } ;
|
||||
|
||||
static osMutexId CMSIS_mutexID[CMSIS_NMUTEX] = {0} ;
|
||||
|
||||
int InitMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
int i ;
|
||||
for (i=0; i<CMSIS_NMUTEX; i++) {
|
||||
if(CMSIS_mutexID[i] == 0) {
|
||||
CMSIS_mutexID[i] = osMutexCreate(CMSIS_mutex[i]) ;
|
||||
(*m) = CMSIS_mutexID[i] ;
|
||||
return 0 ;
|
||||
}
|
||||
}
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
int FreeMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
int i ;
|
||||
osMutexDelete (*m) ;
|
||||
for (i=0; i<CMSIS_NMUTEX; i++) {
|
||||
if(CMSIS_mutexID[i] == (*m)) {
|
||||
CMSIS_mutexID[i] = 0 ;
|
||||
return(0) ;
|
||||
}
|
||||
}
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
int LockMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
osMutexWait(*m, osWaitForever) ;
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
int UnLockMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
osMutexRelease (*m);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
||||
int InitMutex(CyaSSL_Mutex* m)
|
||||
{
|
||||
@@ -376,6 +430,7 @@ int UnLockMutex(CyaSSL_Mutex *m)
|
||||
os_mut_release (m);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* USE_WINDOWS_API */
|
||||
#endif /* SINGLE_THREADED */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user