]> granicus.if.org Git - python/commitdiff
bpo-37160: Thread native ID NetBSD support (GH-13835)
authorDavid Carlier <dcarlier@afilias.info>
Wed, 12 Jun 2019 15:37:56 +0000 (15:37 +0000)
committerVictor Stinner <vstinner@redhat.com>
Wed, 12 Jun 2019 15:37:56 +0000 (17:37 +0200)
Doc/library/_thread.rst
Doc/library/threading.rst
Include/pythread.h
Misc/NEWS.d/next/Core and Builtins/2019-06-05-09-24-17.bpo-37160.O3IAY3.rst [new file with mode: 0644]
Python/thread_pthread.h

index 26568dcbf8f5328c4809fbf94cb5f7401da0d442..5b4fcde669e13b9d773dfedbb6740ef5cfe1cae1 100644 (file)
@@ -106,7 +106,7 @@ This module defines the following constants and functions:
    Its value may be used to uniquely identify this particular thread system-wide
    (until the thread terminates, after which the value may be recycled by the OS).
 
-   .. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD.
+   .. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD.
 
    .. versionadded:: 3.8
 
index 7fb9ac9979e42f119d6d7d32d0d385a33436d70b..b4f4814c4ad37bcd5e22239a8211d215d9575c38 100644 (file)
@@ -82,7 +82,7 @@ This module defines the following functions:
    Its value may be used to uniquely identify this particular thread system-wide
    (until the thread terminates, after which the value may be recycled by the OS).
 
-   .. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD.
+   .. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD.
 
    .. versionadded:: 3.8
 
index 84b79c87642575aa74434ea98080257832792b03..79a9210af3a491a75b4ebda5f20a2aca6888a541 100644 (file)
@@ -26,7 +26,7 @@ PyAPI_FUNC(unsigned long) PyThread_start_new_thread(void (*)(void *), void *);
 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(_WIN32)
+#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(_WIN32)
 #define PY_HAVE_THREAD_NATIVE_ID
 PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void);
 #endif
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-06-05-09-24-17.bpo-37160.O3IAY3.rst b/Misc/NEWS.d/next/Core and Builtins/2019-06-05-09-24-17.bpo-37160.O3IAY3.rst
new file mode 100644 (file)
index 0000000..c2fc680
--- /dev/null
@@ -0,0 +1 @@
+:func:`threading.get_native_id` now also supports NetBSD.\r
index 740b521b9446218344a18a53bdf22a003067adb4..9b4b23bdc7d7bf2a6e6c2d90d2edb09028d3557d 100644 (file)
@@ -18,6 +18,8 @@
 #   include <pthread_np.h>      /* pthread_getthreadid_np() */
 #elif defined(__OpenBSD__)
 #   include <unistd.h>          /* getthrid() */
+#elif defined(__NetBSD__)       /* _lwp_self */
+#   include <lwp.h>
 #endif
 
 /* The POSIX spec requires that use of pthread_attr_setstacksize
@@ -328,6 +330,9 @@ PyThread_get_thread_native_id(void)
 #elif defined(__OpenBSD__)
     pid_t native_id;
     native_id = getthrid();
+#elif defined(__NetBSD__)
+    lwpid_t native_id;
+    native_id = _lwp_self();
 #endif
     return (unsigned long) native_id;
 }