Skip to content

Commit 0b9956e

Browse files
David Carliervstinner
David Carlier
authored andcommitted
bpo-37087: Adding native ID support for OpenBSD (GH-13654)
1 parent 141da44 commit 0b9956e

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

Doc/library/_thread.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ This module defines the following constants and functions:
106106
Its value may be used to uniquely identify this particular thread system-wide
107107
(until the thread terminates, after which the value may be recycled by the OS).
108108

109-
.. availability:: Windows, FreeBSD, Linux, macOS.
109+
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD.
110110

111111
.. versionadded:: 3.8
112112

Doc/library/threading.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ This module defines the following functions:
8282
Its value may be used to uniquely identify this particular thread system-wide
8383
(until the thread terminates, after which the value may be recycled by the OS).
8484

85-
.. availability:: Windows, FreeBSD, Linux, macOS.
85+
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD.
8686

8787
.. versionadded:: 3.8
8888

@@ -355,7 +355,7 @@ since it is impossible to detect the termination of alien threads.
355355
system-wide) from the time the thread is created until the thread
356356
has been terminated.
357357

358-
.. availability:: Windows, FreeBSD, Linux, macOS.
358+
.. availability:: Require :func:`get_native_id` function.
359359

360360
.. versionadded:: 3.8
361361

Include/pythread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PyAPI_FUNC(unsigned long) PyThread_start_new_thread(void (*)(void *), void *);
2626
PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);
2727
PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void);
2828

29-
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(_WIN32)
29+
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(_WIN32)
3030
#define PY_HAVE_THREAD_NATIVE_ID
3131
PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void);
3232
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add native thread ID (TID) support to OpenBSD.

Python/thread_pthread.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# include <sys/syscall.h> /* syscall(SYS_gettid) */
1717
#elif defined(__FreeBSD__)
1818
# include <pthread_np.h> /* pthread_getthreadid_np() */
19+
#elif defined(__OpenBSD__)
20+
# include <unistd.h> /* getthrid() */
1921
#endif
2022

2123
/* The POSIX spec requires that use of pthread_attr_setstacksize
@@ -323,6 +325,9 @@ PyThread_get_thread_native_id(void)
323325
#elif defined(__FreeBSD__)
324326
int native_id;
325327
native_id = pthread_getthreadid_np();
328+
#elif defined(__OpenBSD__)
329+
pid_t native_id;
330+
native_id = getthrid();
326331
#endif
327332
return (unsigned long) native_id;
328333
}

0 commit comments

Comments
 (0)