Loading...
Searching...
No Matches
Go to the documentation of this file.
18#ifndef COAP_MUTEX_INTERNAL_H_
19#define COAP_MUTEX_INTERNAL_H_
27#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
32#define coap_mutex_init(a) pthread_mutex_init(a, NULL)
33#define coap_mutex_destroy(a) pthread_mutex_destroy(a)
34#define coap_mutex_lock(a) pthread_mutex_lock(a)
35#define coap_mutex_trylock(a) pthread_mutex_trylock(a)
36#define coap_mutex_unlock(a) pthread_mutex_unlock(a)
37#if defined(ESPIDF_VERSION)
38#define coap_thread_pid_t TaskHandle_t
39#define coap_thread_pid xTaskGetCurrentTaskHandle()
41#define coap_thread_pid_t pthread_t
42#define coap_thread_pid pthread_self()
45#elif defined(RIOT_VERSION)
51#define coap_mutex_init(a) mutex_init(a)
52#define coap_mutex_destroy(a)
53#define coap_mutex_lock(a) mutex_lock(a)
54#define coap_mutex_trylock(a) mutex_trylock(a)
55#define coap_mutex_unlock(a) mutex_unlock(a)
56#define coap_thread_pid_t kernel_pid_t
57#define coap_thread_pid thread_getpid()
59#elif defined(WITH_LWIP)
64#error Multi-threading not supported (no mutex support)
69#define coap_mutex_init(a) *(a) = 0
70#define coap_mutex_destroy(a) *(a) = 0
71#define coap_mutex_lock(a) *(a) = 1
72#define coap_mutex_trylock(a) *(a) = 1
73#define coap_mutex_unlock(a) *(a) = 0
74#define coap_thread_pid_t int
75#define coap_thread_pid 1
83#define coap_mutex_init(a) pthread_mutex_init(a, NULL)
84#define coap_mutex_destroy(a) pthread_mutex_destroy(a)
85#define coap_mutex_lock(a) pthread_mutex_lock(a)
86#define coap_mutex_trylock(a) pthread_mutex_trylock(a)
87#define coap_mutex_unlock(a) pthread_mutex_unlock(a)
88#define coap_thread_pid_t pthread_t
89#define coap_thread_pid pthread_self()
93#define coap_mutex_init(a) sys_mutex_new(a)
94#define coap_mutex_destroy(a) sys_mutex_set_invalid(a)
95#define coap_mutex_lock(a) sys_mutex_lock(a)
96#define coap_mutex_unlock(a) sys_mutex_unlock(a)
97#define coap_thread_pid_t sys_thread_t
98#define coap_thread_pid (coap_thread_pid_t)1
100#if COAP_THREAD_RECURSIVE_CHECK
101#error COAP_THREAD_RECURSIVE_CHECK not supported (no coap_mutex_trylock())
106#elif defined(WITH_CONTIKI)
108#error Multi-threading not supported (no mutex support)
113#define coap_mutex_init(a) *(a) = 0
114#define coap_mutex_destroy(a) *(a) = 0
115#define coap_mutex_lock(a) *(a) = 1
116#define coap_mutex_trylock(a) *(a) = 1
117#define coap_mutex_unlock(a) *(a) = 0
118#define coap_thread_pid_t int
119#define coap_thread_pid 1
121#elif defined(__ZEPHYR__)
122#include <zephyr/sys/mutex.h>
126#define coap_mutex_init(a) sys_mutex_init(a)
127#define coap_mutex_destroy(a)
128#define coap_mutex_lock(a) sys_mutex_lock(a, K_FOREVER)
129#define coap_mutex_trylock(a) sys_mutex_lock(a, K_NO_WAIT)
130#define coap_mutex_unlock(a) sys_mutex_unlock(a)
135#error Multi-threading not supported (no mutex support)
137#if COAP_CONSTRAINED_STACK
138#warning "stub mutex functions"
143#define coap_mutex_init(a) *(a) = 0
144#define coap_mutex_destroy(a) *(a) = 0
145#define coap_mutex_lock(a) *(a) = 1
146#define coap_mutex_trylock(a) *(a) = 1
147#define coap_mutex_unlock(a) *(a) = 0
148#define coap_thread_pid_t int
149#define coap_thread_pid 1