Fix: global logging symbols defined multiple times
[babeltrace.git] / logging / log.c
index e31f867e13872c79aca8eda145b0ac023932e4c0..78a0361de7c5e89d3586028fbd6e49a9a03999cf 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/common-internal.h>
+#include <pthread.h>
 
 #ifdef __CYGWIN__
 extern unsigned long pthread_getsequence_np(pthread_t *);
@@ -309,6 +310,8 @@ extern unsigned long pthread_getsequence_np(pthread_t *);
        #include <sys/time.h>
        #if defined(__linux__)
                #include <linux/limits.h>
+       #elif (defined(__sun__) || defined(__CYGWIN__))
+               /* Solaris and Cygwin have no sys/syslimits.h */
        #else
                #include <sys/syslimits.h>
        #endif
@@ -487,7 +490,8 @@ extern unsigned long pthread_getsequence_np(pthread_t *);
        #define memccpy _memccpy
 #endif
 
-#if (defined(_MSC_VER) && !defined(__INTEL_COMPILER)) || defined(__MINGW64__)
+#if (defined(_MSC_VER) && !defined(__INTEL_COMPILER)) || \
+               (defined(__MINGW64__) && !defined(__USE_MINGW_ANSI_STDIO))
        #define vsnprintf(s, sz, fmt, va) fake_vsnprintf(s, sz, fmt, va)
        static int fake_vsnprintf(char *s, size_t sz, const char *fmt, va_list ap)
        {
@@ -681,6 +685,7 @@ static const bt_log_output out_stderr = {BT_LOG_OUT_STDERR};
        BT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL = 0;
 #endif
 
+BT_HIDDEN
 const bt_log_spec _bt_log_stderr_spec =
 {
        BT_LOG_GLOBAL_FORMAT,
@@ -739,7 +744,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)
 {
@@ -830,6 +835,8 @@ static void pid_callback(int *const pid, int *const tid)
        #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__)
@@ -900,7 +907,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);
This page took 0.025548 seconds and 4 git commands to generate.