Skip to content

Commit cea0d45

Browse files
committed
gh-81925: Implement the native thread ids for the Hurd and KFreeBSD
1 parent ba8aa1f commit cea0d45

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Include/pythread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);
2121
PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void);
2222

2323
#if (defined(__APPLE__) || defined(__linux__) || defined(_WIN32) \
24-
|| defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
24+
|| defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
25+
|| defined(__OpenBSD__) || defined(__NetBSD__) \
2526
|| defined(__DragonFly__) || defined(_AIX))
2627
#define PY_HAVE_THREAD_NATIVE_ID
2728
PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement native thread ids for GNU KFreeBSD.

Python/thread_pthread.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# include <sys/syscall.h> /* syscall(SYS_gettid) */
2121
#elif defined(__FreeBSD__)
2222
# include <pthread_np.h> /* pthread_getthreadid_np() */
23+
#elif defined(__FreeBSD_kernel__)
24+
# include <sys/syscall.h> /* syscall(SYS_thr_self) */
2325
#elif defined(__OpenBSD__)
2426
# include <unistd.h> /* getthrid() */
2527
#elif defined(_AIX)
@@ -384,6 +386,9 @@ PyThread_get_thread_native_id(void)
384386
#elif defined(__FreeBSD__)
385387
int native_id;
386388
native_id = pthread_getthreadid_np();
389+
#elif defined(__FreeBSD_kernel__)
390+
long native_id;
391+
syscall(SYS_thr_self, &native_id);
387392
#elif defined(__OpenBSD__)
388393
pid_t native_id;
389394
native_id = getthrid();

0 commit comments

Comments
 (0)