mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Simplify mac cond type
This commit is contained in:
@ -3746,7 +3746,7 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
|
||||
}
|
||||
return BAD_MUTEX_E;
|
||||
}
|
||||
#else
|
||||
#else /* __MACH__ */
|
||||
/* Apple style dispatch semaphore */
|
||||
int wolfSSL_CondInit(COND_TYPE* cond)
|
||||
{
|
||||
@ -3758,8 +3758,8 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
|
||||
* dispatch_semaphore_create(). work around this by initing
|
||||
* with 0, then incrementing it afterwards.
|
||||
*/
|
||||
cond->sem = dispatch_semaphore_create(0);
|
||||
if (cond->sem == NULL)
|
||||
*cond = dispatch_semaphore_create(0);
|
||||
if (*cond == NULL)
|
||||
return MEMORY_E;
|
||||
return 0;
|
||||
}
|
||||
@ -3769,8 +3769,8 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
|
||||
if (cond == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
dispatch_release(cond->sem);
|
||||
cond->sem = NULL;
|
||||
dispatch_release(*cond);
|
||||
*cond = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3779,7 +3779,7 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
|
||||
if (cond == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
dispatch_semaphore_signal(cond->sem);
|
||||
dispatch_semaphore_signal(*cond);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3788,7 +3788,7 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
|
||||
if (cond == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
dispatch_semaphore_wait(cond->sem, DISPATCH_TIME_FOREVER);
|
||||
dispatch_semaphore_wait(*cond, DISPATCH_TIME_FOREVER);
|
||||
return 0;
|
||||
}
|
||||
#endif /* __MACH__ */
|
||||
|
@ -1380,17 +1380,15 @@ typedef struct w64wrapper {
|
||||
#define WOLFSSL_THREAD
|
||||
#elif (defined(_POSIX_THREADS) || defined(HAVE_PTHREAD)) && \
|
||||
!defined(__MINGW32__)
|
||||
#ifdef __MACH__
|
||||
#include <dispatch/dispatch.h>
|
||||
typedef struct COND_TYPE {
|
||||
dispatch_semaphore_t sem;
|
||||
} COND_TYPE;
|
||||
#else
|
||||
#ifndef __MACH__
|
||||
#include <pthread.h>
|
||||
typedef struct COND_TYPE {
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
} COND_TYPE;
|
||||
#else
|
||||
#include <dispatch/dispatch.h>
|
||||
typedef dispatch_semaphore_t COND_TYPE;
|
||||
#endif
|
||||
typedef void* THREAD_RETURN;
|
||||
typedef pthread_t THREAD_TYPE;
|
||||
|
Reference in New Issue
Block a user