From 6d60ac35394c9581b49be86e6aeeac77dc3a9f53 Mon Sep 17 00:00:00 2001 From: Salar Samani Date: Tue, 29 Jul 2025 05:11:20 +0200 Subject: [PATCH 1/2] Fix pthreat_t type conflict --- Makefile.uk | 2 + .../0005_workaround_pthread_embedded.patch | 44 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 patches/0005_workaround_pthread_embedded.patch diff --git a/Makefile.uk b/Makefile.uk index 7622bb0..12bd01b 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -109,6 +109,8 @@ LIBPYTHON3_COMMON_DEFINES-y += -DNDEBUG LIBPYTHON3_COMMON_CFLAGS-y += $(LIBPYTHON3_COMMON_DEFINES-y) LIBPYTHON3_COMMON_CXXFLAGS-y += $(LIBPYTHON3_COMMON_DEFINES-y) +LIBPYTHON#_COMMON_CFLAGS-y += -DWORKAROUND_PTHREAD_EMBEDDED + ################################################################################ # Glue code ################################################################################ diff --git a/patches/0005_workaround_pthread_embedded.patch b/patches/0005_workaround_pthread_embedded.patch new file mode 100644 index 0000000..ea983f3 --- /dev/null +++ b/patches/0005_workaround_pthread_embedded.patch @@ -0,0 +1,44 @@ +From fe7c24ccde424aa21d20a6da3546e8a447dd85d7 Mon Sep 17 00:00:00 2001 +From: Salar Samani +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 + From 6fe4db4c56b14b13de9f8ce0ccafc06ffcfe6b04 Mon Sep 17 00:00:00 2001 From: Salar Samani Date: Tue, 29 Jul 2025 05:24:46 +0200 Subject: [PATCH 2/2] Fix an error in Makefile.uk --- Makefile.uk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.uk b/Makefile.uk index 12bd01b..ab77b7c 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -109,8 +109,6 @@ LIBPYTHON3_COMMON_DEFINES-y += -DNDEBUG LIBPYTHON3_COMMON_CFLAGS-y += $(LIBPYTHON3_COMMON_DEFINES-y) LIBPYTHON3_COMMON_CXXFLAGS-y += $(LIBPYTHON3_COMMON_DEFINES-y) -LIBPYTHON#_COMMON_CFLAGS-y += -DWORKAROUND_PTHREAD_EMBEDDED - ################################################################################ # Glue code ################################################################################ @@ -136,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 LIBPYTHON3_CORE_CFLAGS-y += $(LIBPYTHON3_CORE_DEFINES-y) LIBPYTHON3_CORE_CXXFLAGS-y += $(LIBPYTHON3_CORE_DEFINES-y)