From 0eff6a4ed7294b43249cba56fdd28248ee3e6277 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Wed, 3 Dec 2025 15:49:50 +0000 Subject: [PATCH] FreeRTOS/LwIP: Support getting thread_id for locking --- include/coap3/coap_mutex_internal.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/coap3/coap_mutex_internal.h b/include/coap3/coap_mutex_internal.h index 27c32343..d70826e5 100644 --- a/include/coap3/coap_mutex_internal.h +++ b/include/coap3/coap_mutex_internal.h @@ -109,8 +109,14 @@ typedef sys_mutex_t coap_mutex_t; #define coap_mutex_destroy(a) sys_mutex_set_invalid(a) #define coap_mutex_lock(a) sys_mutex_lock(a) #define coap_mutex_unlock(a) sys_mutex_unlock(a) -#define coap_thread_pid_t sys_thread_t -#define coap_thread_pid (coap_thread_pid_t)1 +#ifdef _WIN32 +#define DWORD sys_thread_t +#define coap_thread_pid GetCurrentThreadId() +#else /* ! _WIN32 */ +/* Assume this is therefore FreeRTOS */ +#define caop_thread_pid_t TaskHandle_t +#define coap_thread_pid xTaskGetCurrentTaskHandle() +#endif /* ! _WIN32 */ #if COAP_THREAD_RECURSIVE_CHECK #error COAP_THREAD_RECURSIVE_CHECK not supported (no coap_mutex_trylock())