Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Jun 2019 14:05:34 +0200
From:      Jan Beich <jbeich@FreeBSD.org>
To:        Yuri Victorovich <yuri@FreeBSD.org>
Cc:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   Re: svn commit: r504283 - in head/devel: . folly folly/files
Message-ID:  <4l4p-3fch-wny@FreeBSD.org>
In-Reply-To: <201906160843.x5G8hNVq023775@repo.freebsd.org> (Yuri Victorovich's message of "Sun, 16 Jun 2019 08:43:23 %2B0000 (UTC)")
References:  <201906160843.x5G8hNVq023775@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Yuri Victorovich <yuri@FreeBSD.org> writes:

> +--- folly/portability/SysSyscall.h.orig	2019-06-16 07:32:11 UTC
> ++++ folly/portability/SysSyscall.h
> +@@ -21,6 +21,8 @@
> + 
> + #if defined(__APPLE__)
> + #define FOLLY_SYS_gettid SYS_thread_selfid
> ++#elif defined(__FreeBSD__)
> ++#define FOLLY_SYS_gettid SYS_thr_self
> + #elif defined(SYS_gettid)
> + #define FOLLY_SYS_gettid SYS_gettid
> + #else

Looks bogus. SYS_thr_self requires 1 argument compared to SYS_gettid.
While getOSThreadID() within folly can be fixed I'm not sure about
consumers in the wild.

  $ cat a.c
  #include <sys/syscall.h>
  #include <stdio.h>
  #include <unistd.h>
  #include <pthread_np.h>

  int main()
  {
          printf("%d\n", pthread_getthreadid_np());
          printf("%d\n", syscall(SYS_thr_self));
          return 0;
  }

  $ cc a.c -pthread
  $ ./a.out
  101666
  0

--- folly/system/ThreadId.h.orig	2019-06-09 22:23:35 UTC
+++ folly/system/ThreadId.h
@@ -23,6 +23,12 @@
 #include <folly/portability/Unistd.h>
 #include <folly/portability/Windows.h>
 
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+#include <pthread_np.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
+#endif
+
 namespace folly {
 
 /**
@@ -82,6 +88,12 @@ inline uint64_t getOSThreadID() {
   uint64_t tid;
   pthread_threadid_np(nullptr, &tid);
   return tid;
+#elif __DragonFly__
+  return lwp_gettid();
+#elif __FreeBSD__
+  return pthread_getthreadid_np();
+#elif __NetBSD__
+  return _lwp_self();
 #elif _WIN32
   return uint64_t(GetCurrentThreadId());
 #else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4l4p-3fch-wny>