Skip to content

Commit 886d83e

Browse files
bpo-37077: Add native thread ID (TID) for AIX (GH-13624)
This is the followup for issue36084 https://bugs.python.org/issue37077 (cherry picked from commit d0eeb93) Co-authored-by: Michael Felt <[email protected]>
1 parent 5282b3b commit 886d83e

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
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, NetBSD.
109+
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD, AIX.
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, NetBSD.
85+
.. availability:: Windows, FreeBSD, Linux, macOS, OpenBSD, NetBSD, AIX.
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(__NetBSD__) || defined(_WIN32)
29+
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(_WIN32) || defined(_AIX)
3030
#define PY_HAVE_THREAD_NATIVE_ID
3131
PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void);
3232
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add :func:`threading.get_native_id` support for AIX.
2+
Patch by M. Felt

Python/thread_pthread.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
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>
21+
#elif defined(_AIX)
22+
# include <sys/thread.h> /* thread_self() */
23+
#elif defined(__NetBSD__)
24+
# include <lwp.h> /* _lwp_self() */
2325
#endif
2426

2527
/* The POSIX spec requires that use of pthread_attr_setstacksize
@@ -330,6 +332,9 @@ PyThread_get_thread_native_id(void)
330332
#elif defined(__OpenBSD__)
331333
pid_t native_id;
332334
native_id = getthrid();
335+
#elif defined(_AIX)
336+
tid_t native_id;
337+
native_id = thread_self();
333338
#elif defined(__NetBSD__)
334339
lwpid_t native_id;
335340
native_id = _lwp_self();

0 commit comments

Comments
 (0)