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