Port: No syslimits.h on GNU Hurd
[babeltrace.git] / src / logging / log.c
index 349204e8148fa24f047dc6fd0b98ff39f6017d57..613e056880fb3716ba2c6c5121421f7c8ec325a6 100644 (file)
@@ -1,7 +1,10 @@
 /*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (c) 2016 wonder-mice
+ *
  * This is zf_log.c, modified with Babeltrace prefixes.
  * See <https://github.com/wonder-mice/zf_log/>.
- * See LICENSE.
  */
 
 #include "common/macros.h"
@@ -310,8 +313,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 */
+       #elif (defined(__sun__) || defined(__CYGWIN__) || defined(__GNU__))
+               /* Solaris, Cygwin and Hurd have no sys/syslimits.h */
        #else
                #include <sys/syslimits.h>
        #endif
@@ -327,6 +330,9 @@ extern unsigned long pthread_getsequence_np(pthread_t *);
 #if defined(__MACH__)
        #include <pthread.h>
 #endif
+#if defined(__GNU__)
+       #include <mach.h>
+#endif
 
 #define INLINE _BT_LOG_INLINE
 #define VAR_UNUSED(var) (void)var
@@ -840,8 +846,12 @@ static void pid_callback(int *const pid, int *const tid)
        *tid = gettid();
        #elif defined(__linux__)
        *tid = syscall(SYS_gettid);
-       #elif defined(__MACH__)
+       #elif defined(__APPLE__) && defined(__MACH__)
        *tid = (int)pthread_mach_thread_np(pthread_self());
+       #elif defined(__GNU__)
+       mach_port_t mach_port = mach_thread_self();
+       mach_port_deallocate(mach_task_self(), mach_port);
+       *tid = (int)mach_port;
        #else
                #define Platform not supported
        #endif
@@ -1193,7 +1203,8 @@ static void put_src(bt_log_message *const msg, const src_location *const src)
 #endif
 }
 
-static void put_msg(bt_log_message *const msg,
+static _BT_LOG_PRINTFLIKE(2, 0)
+void put_msg(bt_log_message *const msg,
                                        const char *const fmt, va_list va)
 {
        int n;
@@ -1268,7 +1279,8 @@ void bt_log_set_output_v(const unsigned mask, void *const arg,
        _bt_log_global_output.callback = callback;
 }
 
-static void _bt_log_write_imp(
+static _BT_LOG_PRINTFLIKE(6, 0)
+void _bt_log_write_imp(
                const bt_log_spec *log,
                const src_location *const src, const mem_block *const mem,
                const int lvl, const char *const tag, const char *const fmt, va_list va)
This page took 0.024541 seconds and 4 git commands to generate.