Skip to content

Commit 5faa324

Browse files
committed
gh-137884: Added threading.get_native_id on Illumos/Solaris
1 parent 7636a66 commit 5faa324

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Include/pythread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void);
4242
#if (defined(__APPLE__) || defined(__linux__) || defined(_WIN32) \
4343
|| defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
4444
|| defined(__OpenBSD__) || defined(__NetBSD__) \
45-
|| defined(__DragonFly__) || defined(_AIX))
45+
|| defined(__DragonFly__) || defined(_AIX)) \
46+
|| defined(__sun__)
4647
#define PY_HAVE_THREAD_NATIVE_ID
4748
PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void);
4849
#endif

Python/thread_pthread.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
# include <lwp.h> /* _lwp_self() */
3131
#elif defined(__DragonFly__)
3232
# include <sys/lwp.h> /* lwp_gettid() */
33+
#elif defined(__sun__)
34+
# include <thread.h>
3335
#endif
3436

3537
/* The POSIX spec requires that use of pthread_attr_setstacksize
@@ -399,6 +401,8 @@ PyThread_get_thread_native_id(void)
399401
#elif defined(__DragonFly__)
400402
lwpid_t native_id;
401403
native_id = lwp_gettid();
404+
#elif defined(__sun__)
405+
unsigned long native_id = (unsigned long)getpid() << 32 | thr_self();
402406
#endif
403407
return (unsigned long) native_id;
404408
}

0 commit comments

Comments
 (0)