mutex: define mutex with COAP_MUTEX_DEFINE() macro

Introduce new macro, which will be used for defining static mutex
objects, for use from COAP_CONSTRAINED_STACK enabled code. This macro
will automatically initialize mutex using platform/OS specific macro if
such exists.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This commit is contained in:
Marcin Niestroj authored and Jon Shallow committed 2023-02-24 20:37:43 +00:00
1 parent 2390abf8bd
commit bad2255ab4
4 files changed
+15 -10

No files matched your search

+2 -2
View File
@@ -602,7 +602,7 @@ is_binary(int content_format) {
void
coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu) {
#if COAP_CONSTRAINED_STACK
static coap_mutex_t static_show_pdu_mutex = COAP_MUTEX_INITIALIZER;
COAP_MUTEX_DEFINE(static_show_pdu_mutex);
/* Proxy-Uri: can be 1034 bytes long */
static unsigned char buf[min(COAP_DEBUG_BUF_SIZE, 1035)];
static char outbuf[COAP_DEBUG_BUF_SIZE];
@@ -1062,7 +1062,7 @@ coap_log_impl(coap_log_t level, const char *format, ...) {
if (log_handler) {
#if COAP_CONSTRAINED_STACK
static coap_mutex_t static_log_mutex = COAP_MUTEX_INITIALIZER;
COAP_MUTEX_DEFINE(static_log_mutex);
static char message[COAP_DEBUG_BUF_SIZE];
#else /* ! COAP_CONSTRAINED_STACK */
char message[COAP_DEBUG_BUF_SIZE];
+1 -1
View File
@@ -2073,7 +2073,7 @@ int coap_dtls_receive(coap_session_t *c_session,
if (m_env->established) {
#if COAP_CONSTRAINED_STACK
static coap_mutex_t b_static_mutex = COAP_MUTEX_INITIALIZER;
COAP_MUTEX_DEFINE(b_static_mutex);
static uint8_t pdu[COAP_RXBUFFER_SIZE];
#else /* ! COAP_CONSTRAINED_STACK */
uint8_t pdu[COAP_RXBUFFER_SIZE];
+2 -2
View File
@@ -1721,7 +1721,7 @@ coap_write_session(coap_context_t *ctx, coap_session_t *session, coap_tick_t now
static void
coap_read_session(coap_context_t *ctx, coap_session_t *session, coap_tick_t now) {
#if COAP_CONSTRAINED_STACK
static coap_mutex_t s_static_mutex = COAP_MUTEX_INITIALIZER;
COAP_MUTEX_DEFINE(s_static_mutex);
static unsigned char payload[COAP_RXBUFFER_SIZE];
static coap_packet_t s_packet;
#else /* ! COAP_CONSTRAINED_STACK */
@@ -1886,7 +1886,7 @@ coap_read_endpoint(coap_context_t *ctx, coap_endpoint_t *endpoint, coap_tick_t n
ssize_t bytes_read = -1;
int result = -1; /* the value to be returned */
#if COAP_CONSTRAINED_STACK
static coap_mutex_t e_static_mutex = COAP_MUTEX_INITIALIZER;
COAP_MUTEX_DEFINE(e_static_mutex);
static unsigned char payload[COAP_RXBUFFER_SIZE];
static coap_packet_t e_packet;
#else /* ! COAP_CONSTRAINED_STACK */