mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
lws_mutex
Add a simple platform wrapper around OS mutexes. *nix and windows == pthreads freertos = SemaphoreHandle
This commit is contained in:
parent
b324f0e43b
commit
fdf8a5f931
3 changed files with 24 additions and 0 deletions
|
@ -72,6 +72,12 @@ gai_strerror(int);
|
|||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
typedef SemaphoreHandle_t lws_mutex_t;
|
||||
#define lws_mutex_init(x) x = xSemaphoreCreateMutex()
|
||||
#define lws_mutex_destroy(x) vSemaphoreDelete(x)
|
||||
#define lws_mutex_lock(x) xSemaphoreTake(x, portMAX_DELAY)
|
||||
#define lws_mutex_unlock(x) xSemaphoreGive(x)
|
||||
|
||||
#include <lwip/sockets.h>
|
||||
|
||||
#if defined(LWS_BUILTIN_GETIFADDRS)
|
||||
|
|
|
@ -75,6 +75,15 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LWS_HAVE_PTHREAD_H)
|
||||
#include <pthread.h>
|
||||
typedef pthread_mutex_t lws_mutex_t;
|
||||
#define lws_mutex_init(x) pthread_mutex_init(&(x), NULL)
|
||||
#define lws_mutex_destroy(x) pthread_mutex_destroy(&(x))
|
||||
#define lws_mutex_lock(x) pthread_mutex_lock(&(x))
|
||||
#define lws_mutex_unlock(x) pthread_mutex_unlock(&(x))
|
||||
#endif
|
||||
|
||||
#if defined(__sun) && defined(__GNUC__)
|
||||
|
||||
#include <arpa/nameser_compat.h>
|
||||
|
|
|
@ -66,6 +66,15 @@
|
|||
|
||||
#if defined(LWS_WITH_UNIX_SOCK)
|
||||
#include <afunix.h>
|
||||
#endif
|
||||
|
||||
#if defined(LWS_HAVE_PTHREAD_H)
|
||||
#include <pthread.h>
|
||||
typedef pthread_mutex_t lws_mutex_t;
|
||||
#define lws_mutex_init(x) pthread_mutex_init(&(x), NULL)
|
||||
#define lws_mutex_destroy(x) pthread_mutex_destroy(&(x))
|
||||
#define lws_mutex_lock(x) pthread_mutex_lock(&(x))
|
||||
#define lws_mutex_unlock(x) pthread_mutex_unlock(&(x))
|
||||
#endif
|
||||
|
||||
#if !defined(LWS_HAVE_ATOLL)
|
||||
|
|
Loading…
Add table
Reference in a new issue