Peer review cleanups.
This commit is contained in:
parent
e33d59cd76
commit
6be0512728
@ -718,7 +718,7 @@ void ssl_InitSniffer_ex2(int threadNum)
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#ifndef WC_NO_ASYNC_THREADING
|
||||
if (wolfAsync_DevOpenThread(&devId,&threadNum) < 0)
|
||||
if (wolfAsync_DevOpenThread(&devId, &threadNum) < 0)
|
||||
#else
|
||||
if (wolfAsync_DevOpen(&devId) < 0)
|
||||
#endif
|
||||
|
@ -600,18 +600,21 @@ typedef struct {
|
||||
} wm_Sem;
|
||||
|
||||
/* Posix style semaphore */
|
||||
static int wm_SemInit(wm_Sem *s){
|
||||
static int wm_SemInit(wm_Sem *s)
|
||||
{
|
||||
s->lockCount = 0;
|
||||
pthread_mutex_init(&s->mutex, NULL);
|
||||
pthread_cond_init(&s->cond, NULL);
|
||||
return 0;
|
||||
}
|
||||
static int wm_SemFree(wm_Sem *s){
|
||||
static int wm_SemFree(wm_Sem *s)
|
||||
{
|
||||
pthread_mutex_destroy(&s->mutex);
|
||||
pthread_cond_destroy(&s->cond);
|
||||
return 0;
|
||||
}
|
||||
static int wm_SemLock(wm_Sem *s){
|
||||
static int wm_SemLock(wm_Sem *s)
|
||||
{
|
||||
pthread_mutex_lock(&s->mutex);
|
||||
while (s->lockCount > 0)
|
||||
pthread_cond_wait(&s->cond, &s->mutex);
|
||||
@ -619,7 +622,8 @@ static int wm_SemLock(wm_Sem *s){
|
||||
pthread_mutex_unlock(&s->mutex);
|
||||
return 0;
|
||||
}
|
||||
static int wm_SemUnlock(wm_Sem *s){
|
||||
static int wm_SemUnlock(wm_Sem *s)
|
||||
{
|
||||
pthread_mutex_lock(&s->mutex);
|
||||
s->lockCount--;
|
||||
pthread_cond_signal(&s->cond);
|
||||
|
@ -291,37 +291,43 @@ typedef struct wolfSSL_Ref {
|
||||
} wolfSSL_Ref;
|
||||
|
||||
#ifdef SINGLE_THREADED
|
||||
#define wolfSSL_RefInit(ref, err) do { \
|
||||
(ref)->count = 1; \
|
||||
*(err) = 0; \
|
||||
} while(0);
|
||||
#define wolfSSL_RefInit(ref, err) \
|
||||
do { \
|
||||
(ref)->count = 1; \
|
||||
*(err) = 0; \
|
||||
} while(0)
|
||||
#define wolfSSL_RefFree(ref)
|
||||
#define wolfSSL_RefInc(ref, err) do { \
|
||||
(ref)->count++; \
|
||||
*(err) = 0; \
|
||||
} while(0);
|
||||
#define wolfSSL_RefDec(ref, isZero, err) do { \
|
||||
(ref)->count--; \
|
||||
*(isZero) = ((ref)->count == 0); \
|
||||
*(err) = 0; \
|
||||
} while(0);
|
||||
#define wolfSSL_RefInc(ref, err) \
|
||||
do { \
|
||||
(ref)->count++; \
|
||||
*(err) = 0; \
|
||||
} while(0)
|
||||
#define wolfSSL_RefDec(ref, isZero, err) \
|
||||
do { \
|
||||
(ref)->count--; \
|
||||
*(isZero) = ((ref)->count == 0); \
|
||||
*(err) = 0; \
|
||||
} while(0)
|
||||
#elif defined(HAVE_C___ATOMIC)
|
||||
#define wolfSSL_RefInit(ref, err) do { \
|
||||
(ref)->count = 1; \
|
||||
*(err) = 0; \
|
||||
} while(0);
|
||||
#define wolfSSL_RefInit(ref, err) \
|
||||
do { \
|
||||
(ref)->count = 1; \
|
||||
*(err) = 0; \
|
||||
} while(0)
|
||||
#define wolfSSL_RefFree(ref)
|
||||
#define wolfSSL_RefInc(ref, err) do { \
|
||||
__atomic_fetch_add(&(ref)->count, 1, \
|
||||
__ATOMIC_RELAXED); \
|
||||
*(err) = 0; \
|
||||
} while(0);
|
||||
#define wolfSSL_RefDec(ref, isZero, err) do { \
|
||||
__atomic_fetch_sub(&(ref)->count, 1, \
|
||||
__ATOMIC_RELAXED); \
|
||||
*(isZero) = ((ref)->count == 0); \
|
||||
*(err) = 0; \
|
||||
} while(0);
|
||||
#define wolfSSL_RefInc(ref, err) \
|
||||
do { \
|
||||
__atomic_fetch_add(&(ref)->count, 1, \
|
||||
__ATOMIC_RELAXED); \
|
||||
*(err) = 0; \
|
||||
} while(0)
|
||||
#define wolfSSL_RefDec(ref, isZero, err) \
|
||||
do { \
|
||||
__atomic_fetch_sub(&(ref)->count, 1, \
|
||||
__ATOMIC_RELAXED); \
|
||||
*(isZero) = ((ref)->count == 0); \
|
||||
*(err) = 0; \
|
||||
} while(0)
|
||||
#else
|
||||
WOLFSSL_LOCAL void wolfSSL_RefInit(wolfSSL_Ref* ref, int* err);
|
||||
WOLFSSL_LOCAL void wolfSSL_RefFree(wolfSSL_Ref* ref);
|
||||
|
Loading…
x
Reference in New Issue
Block a user