提交 77117e18 编写于 作者: A Andrea Bolognani

util: gettid() is Linux-specific

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: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
上级 6dde44c8
...@@ -268,7 +268,7 @@ bool virThreadIsSelf(virThreadPtr thread) ...@@ -268,7 +268,7 @@ bool virThreadIsSelf(virThreadPtr thread)
* the pthread_self() id on Linux. */ * the pthread_self() id on Linux. */
unsigned long long virThreadSelfID(void) 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); pid_t tid = syscall(SYS_gettid);
return tid; return tid;
#else #else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册