Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move thread.c:initialized to _PyRuntimeState.
  • Loading branch information
ericsnowcurrently committed Dec 9, 2022
commit 09fc5578f81417bb0b7d6d88c811bd8f1d7429ca
2 changes: 1 addition & 1 deletion Include/internal/pycore_pythread.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {


struct _pythread_runtime_state {
int _not_used;
int initialized;
};


Expand Down
7 changes: 4 additions & 3 deletions Python/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@

#endif /* _POSIX_THREADS */

static int initialized;

static void PyThread__init_thread(void); /* Forward */

#define initialized _PyRuntime.threads.initialized

void
PyThread_init_thread(void)
{
if (initialized)
if (initialized) {
return;
}
initialized = 1;
PyThread__init_thread();
}
Expand Down
3 changes: 2 additions & 1 deletion Python/thread_nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ unsigned long PyThread_get_thread_native_id(void);
#endif

/*
* Initialization of the C package, should not be needed.
* Initialization for the current runtime.
*/
static void
PyThread__init_thread(void)
{
// Initialization of the C package should not be needed.
}

/*
Expand Down
2 changes: 1 addition & 1 deletion Python/thread_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ typedef struct {
"%s: %s\n", name, strerror(status)); error = 1; }

/*
* Initialization.
* Initialization for the current runtime.
*/
static void
PyThread__init_thread(void)
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Python/fileutils.c set_inheritable ioctl_works -
Modules/posixmodule.c os_dup2_impl dup3_works -

## guards around resource init
Python/thread.c - initialized -
Python/thread_pthread.h PyThread__init_thread lib_initialized -
Python/thread_pthread.h - condattr_monotonic -
# static buffer used during one-time initialization
Expand Down