]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: gettid() is Linux-specific
authorAndrea Bolognani <abologna@redhat.com>
Mon, 4 Dec 2017 15:22:02 +0000 (16:22 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 5 Dec 2017 10:28:19 +0000 (11:28 +0100)
The manual page clearly states that

  gettid() is Linux-specific and should not be used in programs
  that are intended to be portable.

Unfortunately, it looks like macOS implemented the functionality
and defined SYS_gettid accordingly, only to deprecate syscall()
altogether with 10.12 (Sierra), released last late year.

To avoid compilation errors, call gettid() on Linux only.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
src/util/virthread.c

index 6c495158f5665804585715abba3c414a87dc329f..05b5572f5f46431d43961c0811b017292d377853 100644 (file)
@@ -268,7 +268,7 @@ bool virThreadIsSelf(virThreadPtr thread)
  * the pthread_self() id on Linux.  */
 unsigned long long virThreadSelfID(void)
 {
-#if defined(HAVE_SYS_SYSCALL_H) && defined(SYS_gettid)
+#if defined(HAVE_SYS_SYSCALL_H) && defined(SYS_gettid) && defined(__linux__)
     pid_t tid = syscall(SYS_gettid);
     return tid;
 #else