krytarowski created this revision.
krytarowski added a project: LLDB.

Native Thread ID is retrieved with _lwp_self() on NetBSD.

The returned value is of type int32_t, but for consistency with other Operating 
Systems cast it to uint64_t.

Sponsored by <The NetBSD Foundation>


Repository:
  rL LLVM

https://reviews.llvm.org/D30374

Files:
  packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
  packages/Python/lldbsuite/test/tools/lldb-server/main.cpp


Index: packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
+++ packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
@@ -27,6 +27,8 @@
 int pthread_threadid_np(pthread_t, __uint64_t *);
 #elif defined(__linux__)
 #include <sys/syscall.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
 #endif
 
 static const char *const RETVAL_PREFIX = "retval:";
@@ -71,6 +73,9 @@
 #elif defined(__linux__)
   // This is a call to gettid() via syscall.
   printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
+#elif defined(__NetBSD__)
+  // Technically lwpid_t is 32-bit signed integer
+  printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
 #else
   printf("{no-tid-support}");
 #endif
Index: packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
+++ packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
@@ -18,6 +18,8 @@
 int pthread_threadid_np(pthread_t, __uint64_t *);
 #elif defined(__linux__)
 #include <sys/syscall.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
 #endif
 
 static const char *const RETVAL_PREFIX = "retval:";
@@ -62,6 +64,9 @@
 #elif defined(__linux__)
   // This is a call to gettid() via syscall.
   printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
+#elif defined(__NetBSD__)
+  // Technically lwpid_t is 32-bit signed integer
+  printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
 #else
   printf("{no-tid-support}");
 #endif


Index: packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
+++ packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
@@ -27,6 +27,8 @@
 int pthread_threadid_np(pthread_t, __uint64_t *);
 #elif defined(__linux__)
 #include <sys/syscall.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
 #endif
 
 static const char *const RETVAL_PREFIX = "retval:";
@@ -71,6 +73,9 @@
 #elif defined(__linux__)
   // This is a call to gettid() via syscall.
   printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
+#elif defined(__NetBSD__)
+  // Technically lwpid_t is 32-bit signed integer
+  printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
 #else
   printf("{no-tid-support}");
 #endif
Index: packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
+++ packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
@@ -18,6 +18,8 @@
 int pthread_threadid_np(pthread_t, __uint64_t *);
 #elif defined(__linux__)
 #include <sys/syscall.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
 #endif
 
 static const char *const RETVAL_PREFIX = "retval:";
@@ -62,6 +64,9 @@
 #elif defined(__linux__)
   // This is a call to gettid() via syscall.
   printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
+#elif defined(__NetBSD__)
+  // Technically lwpid_t is 32-bit signed integer
+  printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
 #else
   printf("{no-tid-support}");
 #endif
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to