File: hurd_kfreebsd_thread_native_id.diff

package info (click to toggle)
python3.9 3.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 102,508 kB
  • sloc: python: 606,145; ansic: 515,486; xml: 31,209; sh: 4,917; cpp: 3,781; makefile: 1,885; asm: 1,486; objc: 761; lisp: 502; pascal: 360; javascript: 177; csh: 11
file content (52 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--- a/Include/pythread.h
+++ b/Include/pythread.h
@@ -25,7 +25,7 @@ PyAPI_FUNC(unsigned long) PyThread_start
 PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);
 PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void);
 
-#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(_WIN32) || defined(_AIX)
+#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(_WIN32) || defined(_AIX) || defined(__GNU__)
 #define PY_HAVE_THREAD_NATIVE_ID
 PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void);
 #endif
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -17,12 +17,17 @@
 #   include <sys/syscall.h>     /* syscall(SYS_gettid) */
 #elif defined(__FreeBSD__)
 #   include <pthread_np.h>      /* pthread_getthreadid_np() */
+#elif defined(__FreeBSD_kernel__)
+#   include <sys/syscall.h>     /* syscall(SYS_thr_self) */
 #elif defined(__OpenBSD__)
 #   include <unistd.h>          /* getthrid() */
 #elif defined(_AIX)
 #   include <sys/thread.h>      /* thread_self() */
 #elif defined(__NetBSD__)
 #   include <lwp.h>             /* _lwp_self() */
+#elif defined(__GNU__)
+#   include <mach.h>            /* mach_thread_self(), mach_task_self(),
+                                   mach_port_deallocate() */
 #endif
 
 /* The POSIX spec requires that use of pthread_attr_setstacksize
@@ -338,6 +343,9 @@ PyThread_get_thread_native_id(void)
 #elif defined(__FreeBSD__)
     int native_id;
     native_id = pthread_getthreadid_np();
+#elif defined(__FreeBSD_kernel__)
+    long native_id;
+    syscall(SYS_thr_self, &native_id);
 #elif defined(__OpenBSD__)
     pid_t native_id;
     native_id = getthrid();
@@ -347,6 +355,10 @@ PyThread_get_thread_native_id(void)
 #elif defined(__NetBSD__)
     lwpid_t native_id;
     native_id = _lwp_self();
+#elif defined(__GNU__)
+    mach_port_t native_id;
+    native_id = mach_thread_self();
+    mach_port_deallocate(mach_task_self(), mach_thread_self());
 #endif
     return (unsigned long) native_id;
 }