Skip to content

Commit d62ead4

Browse files
committed
Implement get_current_systemwide_thread_id for Cygwin based on Winapi.
1 parent 0df6182 commit d62ead4

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

include/boost/interprocess/detail/os_thread_functions.hpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,20 @@
6363
#elif defined(__APPLE__)
6464
#include <pthread.h>
6565
#elif defined(__NetBSD__)
66-
#include <lwp.h>
66+
#include <lwp.h>
6767
#elif defined(__OpenBSD__)
68-
#include <unistd.h>
68+
#include <unistd.h>
6969
#elif defined(__sun) && defined(__SVR4)
70-
#include <thread.h>
70+
#include <thread.h>
71+
#elif defined(__CYGWIN__)
72+
#ifndef __LP64__ // 32 bit target
73+
typedef unsigned long BOOSTIPC_CYGWIN_DWORD;
74+
#else // 64 bit Cygwin target
75+
typedef unsigned int BOOSTIPC_CYGWIN_DWORD;
76+
#endif
77+
extern "C" {
78+
__declspec(dllimport) BOOSTIPC_CYGWIN_DWORD __stdcall GetCurrentThreadId (void);
79+
} //extern "C" {
7180
#endif
7281

7382

@@ -349,7 +358,17 @@ inline OS_systemwide_thread_id_t get_current_systemwide_thread_id()
349358
inline OS_systemwide_thread_id_t get_invalid_systemwide_thread_id()
350359
{ return (thread_t)(-1); }
351360

352-
#else //fallback to fragile pthread-based solution
361+
#elif defined(__CYGWIN__)
362+
363+
typedef BOOSTIPC_CYGWIN_DWORD OS_systemwide_thread_id_t;
364+
365+
inline OS_systemwide_thread_id_t get_current_systemwide_thread_id()
366+
{ return ::GetCurrentThreadId(); }
367+
368+
inline OS_systemwide_thread_id_t get_invalid_systemwide_thread_id()
369+
{ return (OS_systemwide_thread_id_t)(-1); }
370+
371+
#else //fallback to fragile nad mostly wrong pthread-based solution
353372

354373
class OS_systemwide_thread_id_t
355374
{

0 commit comments

Comments
 (0)