Skip to content

Commit 5287022

Browse files
David Carliervstinner
David Carlier
authored andcommitted
bpo-37160: Thread native ID NetBSD support (GH-13835)
1 parent 32dda26 commit 5287022

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
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, OpenBSD.
109+
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD.
110110

111111
.. versionadded:: 3.8
112112

Doc/library/threading.rst

Lines changed: 1 addition & 1 deletion
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, OpenBSD.
85+
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD.
8686

8787
.. versionadded:: 3.8
8888

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(__OpenBSD__) || defined(_WIN32)
29+
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || 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+
:func:`threading.get_native_id` now also supports NetBSD.

Python/thread_pthread.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# include <pthread_np.h> /* pthread_getthreadid_np() */
1919
#elif defined(__OpenBSD__)
2020
# include <unistd.h> /* getthrid() */
21+
#elif defined(__NetBSD__) /* _lwp_self */
22+
# include <lwp.h>
2123
#endif
2224

2325
/* The POSIX spec requires that use of pthread_attr_setstacksize
@@ -328,6 +330,9 @@ PyThread_get_thread_native_id(void)
328330
#elif defined(__OpenBSD__)
329331
pid_t native_id;
330332
native_id = getthrid();
333+
#elif defined(__NetBSD__)
334+
lwpid_t native_id;
335+
native_id = _lwp_self();
331336
#endif
332337
return (unsigned long) native_id;
333338
}

0 commit comments

Comments
 (0)