18#ifndef COAP_MUTEX_INTERNAL_H_
19#define COAP_MUTEX_INTERNAL_H_
26#if COAP_CONSTRAINED_STACK
28#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
31typedef pthread_mutex_t coap_mutex_t;
33#define coap_mutex_init(a) pthread_mutex_init(a, NULL)
34#define coap_mutex_destroy(a) pthread_mutex_destroy(a)
35#define coap_mutex_lock(a) pthread_mutex_lock(a)
36#define coap_mutex_trylock(a) pthread_mutex_trylock(a)
37#define coap_mutex_unlock(a) pthread_mutex_unlock(a)
39#elif defined(RIOT_VERSION)
43typedef mutex_t coap_mutex_t;
45#define coap_mutex_init(a) mutex_init(a)
46#define coap_mutex_destroy(a)
47#define coap_mutex_lock(a) mutex_lock(a)
48#define coap_mutex_trylock(a) mutex_trylock(a)
49#define coap_mutex_unlock(a) mutex_unlock(a)
51#elif defined(WITH_LWIP)
56typedef int coap_mutex_t;
58#define coap_mutex_init(a) *(a) = 0
59#define coap_mutex_destroy(a) *(a) = 0
60#define coap_mutex_lock(a) *(a) = 1
61#define coap_mutex_trylock(a) *(a) = 1
62#define coap_mutex_unlock(a) *(a) = 0
66typedef sys_mutex_t coap_mutex_t;
68#define coap_mutex_init(a) sys_mutex_new(a)
69#define coap_mutex_destroy(a) sys_mutex_set_invalid(a)
70#define coap_mutex_lock(a) sys_mutex_lock(a)
71#define coap_mutex_trylock(a) sys_mutex_lock(a)
72#define coap_mutex_unlock(a) sys_mutex_unlock(a)
75#elif defined(WITH_CONTIKI)
77typedef int coap_mutex_t;
79#define coap_mutex_init(a) *(a) = 0
80#define coap_mutex_destroy(a) *(a) = 0
81#define coap_mutex_lock(a) *(a) = 1
82#define coap_mutex_trylock(a) *(a) = 1
83#define coap_mutex_unlock(a) *(a) = 0
85#elif defined(__ZEPHYR__)
86#include <zephyr/sys/mutex.h>
88typedef struct sys_mutex coap_mutex_t;
90#define coap_mutex_init(a) sys_mutex_init(a)
91#define coap_mutex_destroy(a)
92#define coap_mutex_lock(a) sys_mutex_lock(a, K_FOREVER)
93#define coap_mutex_trylock(a) sys_mutex_lock(a, K_NO_WAIT)
94#define coap_mutex_unlock(a) sys_mutex_unlock(a)
98#warning "stub mutex functions"
99typedef int coap_mutex_t;
101#define coap_mutex_init(a) *(a) = 0
102#define coap_mutex_destroy(a) *(a) = 0
103#define coap_mutex_lock(a) *(a) = 1
104#define coap_mutex_trylock(a) *(a) = 1
105#define coap_mutex_unlock(a) *(a) = 0
109extern coap_mutex_t m_show_pdu;
110extern coap_mutex_t m_log_impl;
111extern coap_mutex_t m_dtls_recv;
112extern coap_mutex_t m_read_session;
113extern coap_mutex_t m_read_endpoint;
114extern coap_mutex_t m_persist_add;