diff --git a/lib/plat/freertos/private-lib-plat-freertos.h b/lib/plat/freertos/private-lib-plat-freertos.h index 052f43ad5..f8d61499c 100644 --- a/lib/plat/freertos/private-lib-plat-freertos.h +++ b/lib/plat/freertos/private-lib-plat-freertos.h @@ -72,6 +72,12 @@ gai_strerror(int); #include #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 #if defined(LWS_BUILTIN_GETIFADDRS) diff --git a/lib/plat/unix/private-lib-plat-unix.h b/lib/plat/unix/private-lib-plat-unix.h index d64f89883..feb222739 100644 --- a/lib/plat/unix/private-lib-plat-unix.h +++ b/lib/plat/unix/private-lib-plat-unix.h @@ -75,6 +75,15 @@ #endif #endif +#if defined(LWS_HAVE_PTHREAD_H) +#include +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 diff --git a/lib/plat/windows/private-lib-plat-windows.h b/lib/plat/windows/private-lib-plat-windows.h index 03cffd175..56bfc3c00 100644 --- a/lib/plat/windows/private-lib-plat-windows.h +++ b/lib/plat/windows/private-lib-plat-windows.h @@ -66,6 +66,15 @@ #if defined(LWS_WITH_UNIX_SOCK) #include +#endif + +#if defined(LWS_HAVE_PTHREAD_H) +#include +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)