X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=logging%2Flog.c;h=1a9fed4bc486c8fcec0673daf1569d020dcbd5ad;hb=ee07b1e97986cfaf1ee0753230191c44fea9f470;hp=adac547eedf0666328ae3cdb50bad97e29cef518;hpb=557d8f3969212af3726d8e9afd9dc49eb780550d;p=babeltrace.git diff --git a/logging/log.c b/logging/log.c index adac547e..1a9fed4b 100644 --- a/logging/log.c +++ b/logging/log.c @@ -6,6 +6,11 @@ #include #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) @@ -305,6 +310,8 @@ #include #if defined(__linux__) #include + #elif (defined(__sun__) || defined(__CYGWIN__)) + /* Solaris and Cygwin have no sys/syslimits.h */ #else #include #endif @@ -735,7 +742,7 @@ static char lvl_char(const int lvl) #define TCACHE_FLUID (0x40000000 | 0x80000000) static unsigned g_tcache_mode = TCACHE_STALE; static struct timeval g_tcache_tv = {0, 0}; -static struct tm g_tcache_tm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static struct tm g_tcache_tm = {0}; static INLINE int tcache_get(const struct timeval *const tv, struct tm *const tm) { @@ -823,6 +830,11 @@ 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(__sun__) + *tid = (int)pthread_self(); #elif defined(__ANDROID__) *tid = gettid(); #elif defined(__linux__) @@ -893,7 +905,7 @@ static char *put_integer_r(unsigned v, const int sign, const unsigned w, const char wc, char *const e) { static const char _signs[] = {'-', '0', '+'}; - static const char *const signs = _signs + 1; + const char *const signs = _signs + 1; char *p = e; do { *--p = '0' + v % 10; } while (0 != (v /= 10)); if (0 == sign) return put_padding_r(w, wc, p, e);