mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-81057: Move Threading-Related Globals to _PyRuntimeState (#100084)
https://github.com/python/cpython/issues/81057
This commit is contained in:
parent
bc8cdf8c3d
commit
1160001b34
11 changed files with 114 additions and 54 deletions
|
@ -8,15 +8,7 @@
|
|||
#include "Python.h"
|
||||
#include "pycore_pystate.h" // _PyInterpreterState_GET()
|
||||
#include "pycore_structseq.h" // _PyStructSequence_FiniType()
|
||||
|
||||
#ifndef _POSIX_THREADS
|
||||
/* This means pthreads are not implemented in libc headers, hence the macro
|
||||
not present in unistd.h. But they still can be implemented as an external
|
||||
library (e.g. gnu pth in pthread emulation) */
|
||||
# ifdef HAVE_PTHREAD_H
|
||||
# include <pthread.h> /* _POSIX_THREADS */
|
||||
# endif
|
||||
#endif
|
||||
#include "pycore_pythread.h"
|
||||
|
||||
#ifndef DONT_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
|
@ -24,33 +16,17 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef _POSIX_THREADS
|
||||
|
||||
/* Check if we're running on HP-UX and _SC_THREADS is defined. If so, then
|
||||
enough of the Posix threads package is implemented to support python
|
||||
threads.
|
||||
|
||||
This is valid for HP-UX 11.23 running on an ia64 system. If needed, add
|
||||
a check of __ia64 to verify that we're running on an ia64 system instead
|
||||
of a pa-risc system.
|
||||
*/
|
||||
#ifdef __hpux
|
||||
#ifdef _SC_THREADS
|
||||
#define _POSIX_THREADS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#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();
|
||||
}
|
||||
|
@ -58,7 +34,7 @@ PyThread_init_thread(void)
|
|||
#if defined(HAVE_PTHREAD_STUBS)
|
||||
# define PYTHREAD_NAME "pthread-stubs"
|
||||
# include "thread_pthread_stubs.h"
|
||||
#elif defined(_POSIX_THREADS)
|
||||
#elif defined(_USE_PTHREADS) /* AKA _PTHREADS */
|
||||
# if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||
# define PYTHREAD_NAME "pthread-stubs"
|
||||
# else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue