Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.uk
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ LIBPYTHON3_CORE_CFLAGS-y += $(LIBPYTHON3_SUPRESS_CFLAGS-y)
LIBPYTHON3_CORE_CXXFLAGS-y += $(LIBPYTHON3_SUPRESS_CXXFLAGS-y)

# Preprocessing symbols
LIBPYTHON3_CORE_DEFINES-y += $(LIBPYTHON3_COMMON_DEFINES-y) -DPy_BUILD_CORE -DPy_BUILD_CORE_BUILTIN
LIBPYTHON3_CORE_DEFINES-y += $(LIBPYTHON3_COMMON_DEFINES-y) -DPy_BUILD_CORE -DPy_BUILD_CORE_BUILTIN -DWORKAROUND_PTHREAD_EMBEDDED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be added only if the NEWLIB and PTHREAD symbols exist right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Use LIBPYTHON3_CORE_DEFINES-$(LIBPTHREAD_EMBEDDED)

LIBPYTHON3_CORE_CFLAGS-y += $(LIBPYTHON3_CORE_DEFINES-y)
LIBPYTHON3_CORE_CXXFLAGS-y += $(LIBPYTHON3_CORE_DEFINES-y)

Expand Down
44 changes: 44 additions & 0 deletions patches/0005_workaround_pthread_embedded.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From fe7c24ccde424aa21d20a6da3546e8a447dd85d7 Mon Sep 17 00:00:00 2001
From: Salar Samani <[email protected]>
Date: Tue, 29 Jul 2025 02:14:48 +0200
Subject: [PATCH] workaround pthread_embedded pthread_t type

---
Python/thread_pthread.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index 35b9810aa37..a7976837ae4 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -325,6 +325,19 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
- The cast to unsigned long is inherently unsafe.
- It is not clear that the 'volatile' (for AIX?) are any longer necessary.
*/
+#ifdef WORKAROUND_PTHREAD_EMBEDDED
+unsigned long
+PyThread_get_thread_ident(void)
+{
+ volatile pthread_t threadid;
+ uintptr_t tid;
+ if (!initialized)
+ PyThread_init_thread();
+ threadid = pthread_self();
+ memcpy(&tid, &threadid, sizeof(tid));
+ return (unsigned long) tid;
+}
+#else
unsigned long
PyThread_get_thread_ident(void)
{
@@ -334,6 +347,7 @@ PyThread_get_thread_ident(void)
threadid = pthread_self();
return (unsigned long) threadid;
}
+#endif /*WORKAROUND_PTHREAD_EMBEDDED*/

#ifdef PY_HAVE_THREAD_NATIVE_ID
unsigned long
--
2.43.0