Skip to content

Commit 1fa51f8

Browse files
committed
test3
1 parent 612a0a4 commit 1fa51f8

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Modules/_threadmodule.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static PF_SET_THREAD_DESCRIPTION pSetThreadDescription = NULL;
7979
#endif
8080

8181
#if defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP)
82-
static int _set_thread_name(const char *name);
82+
int _set_thread_name(const char *name);
8383
#endif
8484

8585

@@ -2582,7 +2582,7 @@ Set the name of the current thread.
25822582

25832583
#ifndef MS_WINDOWS
25842584
// Helper to set the thread name using platform-specific APIs (POSIX only)
2585-
static int
2585+
int
25862586
_set_thread_name(const char *name)
25872587
{
25882588
int rc;
@@ -2709,6 +2709,25 @@ _set_thread_name(const char *name)
27092709
}
27102710
#endif
27112711

2712+
/* Weak global fallback when the platform-specific helper isn't compiled.
2713+
* On toolchains that support weak symbols (GCC/Clang), mark it weak so a
2714+
* real strong implementation will override it. */
2715+
#if !defined(HAVE_PTHREAD_SETNAME_NP) && !defined(HAVE_PTHREAD_SET_NAME_NP) && !defined(MS_WINDOWS)
2716+
2717+
#if defined(__GNUC__) || defined(__clang__)
2718+
int __attribute__((weak))
2719+
_set_thread_name(const char *name)
2720+
#else
2721+
int
2722+
_set_thread_name(const char *name)
2723+
#endif
2724+
{
2725+
(void)name;
2726+
return 0;
2727+
}
2728+
#endif
2729+
2730+
27122731
static PyMethodDef thread_methods[] = {
27132732
{"start_new_thread", thread_PyThread_start_new_thread,
27142733
METH_VARARGS, start_new_thread_doc},

0 commit comments

Comments
 (0)