From f61ad75488270a7c052714453bb27d6e043867db Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Tue, 11 Jul 2017 15:58:32 -0400 Subject: [PATCH] Port: Add Cygwin tid support to logging MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- logging/log.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/logging/log.c b/logging/log.c index adac547e..e31f867e 100644 --- a/logging/log.c +++ b/logging/log.c @@ -7,6 +7,10 @@ #include #include +#ifdef __CYGWIN__ +extern unsigned long pthread_getsequence_np(pthread_t *); +#endif + /* When defined, Android log (android/log.h) will be used by default instead of * stderr (ignored on non-Android platforms). Date, time, pid and tid (context) * will be provided by Android log. Android log features will be used to output @@ -823,6 +827,9 @@ static void pid_callback(int *const pid, int *const tid) #else #if defined(_WIN32) || defined(_WIN64) *tid = GetCurrentThreadId(); + #elif defined(__CYGWIN__) + pthread_t thr = pthread_self(); + *tid = (int)pthread_getsequence_np(&thr); #elif defined(__ANDROID__) *tid = gettid(); #elif defined(__linux__) -- 2.34.1