Port: Add Cygwin tid support to logging
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 11 Jul 2017 19:58:32 +0000 (15:58 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 19 Jul 2017 19:08:41 +0000 (15:08 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
logging/log.c

index adac547eedf0666328ae3cdb50bad97e29cef518..e31f867e13872c79aca8eda145b0ac023932e4c0 100644 (file)
@@ -7,6 +7,10 @@
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/common-internal.h>
 
+#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__)
This page took 0.02507 seconds and 4 git commands to generate.