$NetBSD: patch-src_zm_logger_cpp,v 1.5 2018/07/14 15:03:57 gdt Exp $

If the system has syscall() but not SYS_gettid [E.g. NetBSD], don't attempt
to use SYS_gettid.

--- src/zm_logger.cpp.orig	2015-02-05 02:52:37.000000000 +0000
+++ src/zm_logger.cpp
@@ -31,6 +31,7 @@
 #include <signal.h>
 #include <stdarg.h>
 #include <errno.h>
+#include <unistd.h>
 
 bool Logger::smInitialised = false;
 Logger *Logger::smInstance = 0;
@@ -527,7 +528,7 @@ void Logger::logPrint( bool hex, const c
     #endif
 
         pid_t tid;
-#ifdef HAVE_SYSCALL
+#if defined(HAVE_SYSCALL) && defined(SYS_gettid)
         if ( (tid = syscall(SYS_gettid)) < 0 ) // Thread/Process id
 #endif // HAVE_SYSCALL
         tid = getpid(); // Process id
@@ -581,7 +582,7 @@ void Logger::logPrint( bool hex, const c
             char escapedString[(strlen(syslogStart)*2)+1];
 
             mysql_real_escape_string( &mDbConnection, escapedString, syslogStart, strlen(syslogStart) );
-            snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, '%s', '%s', '%s', %d )", timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), tid, level, classString, escapedString, file, line );
+            snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) values ( %jd.%06ld, '%s', %d, %d, '%s', '%s', '%s', %d )", (intmax_t) timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), tid, level, classString, escapedString, file, line );
             if ( mysql_query( &mDbConnection, sql ) )
             {
                 databaseLevel( NOLOG );
