From d62ead405de45a9d744234d3cf309b28183fb3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 3 Jan 2026 19:37:59 +0100 Subject: [PATCH] Implement get_current_systemwide_thread_id for Cygwin based on Winapi. --- .../detail/os_thread_functions.hpp | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/include/boost/interprocess/detail/os_thread_functions.hpp b/include/boost/interprocess/detail/os_thread_functions.hpp index 6d8f24b..f313929 100644 --- a/include/boost/interprocess/detail/os_thread_functions.hpp +++ b/include/boost/interprocess/detail/os_thread_functions.hpp @@ -63,11 +63,20 @@ #elif defined(__APPLE__) #include #elif defined(__NetBSD__) - #include + #include #elif defined(__OpenBSD__) - #include + #include #elif defined(__sun) && defined(__SVR4) - #include + #include +#elif defined(__CYGWIN__) + #ifndef __LP64__ // 32 bit target + typedef unsigned long BOOSTIPC_CYGWIN_DWORD; + #else // 64 bit Cygwin target + typedef unsigned int BOOSTIPC_CYGWIN_DWORD; + #endif + extern "C" { + __declspec(dllimport) BOOSTIPC_CYGWIN_DWORD __stdcall GetCurrentThreadId (void); + } //extern "C" { #endif @@ -349,7 +358,17 @@ inline OS_systemwide_thread_id_t get_current_systemwide_thread_id() inline OS_systemwide_thread_id_t get_invalid_systemwide_thread_id() { return (thread_t)(-1); } -#else //fallback to fragile pthread-based solution +#elif defined(__CYGWIN__) + +typedef BOOSTIPC_CYGWIN_DWORD OS_systemwide_thread_id_t; + +inline OS_systemwide_thread_id_t get_current_systemwide_thread_id() +{ return ::GetCurrentThreadId(); } + +inline OS_systemwide_thread_id_t get_invalid_systemwide_thread_id() +{ return (OS_systemwide_thread_id_t)(-1); } + +#else //fallback to fragile nad mostly wrong pthread-based solution class OS_systemwide_thread_id_t {