svn commit: r504283 - in head/devel: . folly folly/files
Jan Beich
jbeich at FreeBSD.org
Sun Jun 16 12:05:39 UTC 2019
Yuri Victorovich <yuri at 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
More information about the svn-ports-all
mailing list