Re: [PATCH 1/3] util: gettid() is Linux-specific

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 04, 2017 at 05:23:45PM +0100, Andrea Bolognani wrote:
> 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@xxxxxxxxxx>
> ---
>  src/util/virthread.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virthread.c b/src/util/virthread.c
> index 6c495158f..05b5572f5 100644
> --- a/src/util/virthread.c
> +++ b/src/util/virthread.c
> @@ -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

Reviewed-by: Daniel P. Berrange <berrange@xxxxxxxxxx>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux