mirror of
https://github.com/python/cpython.git
synced 2025-11-03 19:34:08 +00:00
gh-81057: Move Globals in Core Code to _PyRuntimeState (gh-99496)
This is the first of several changes to consolidate non-object globals in core code. https://github.com/python/cpython/issues/81057
This commit is contained in:
parent
73943cbc4c
commit
3c57971a2d
17 changed files with 235 additions and 167 deletions
|
|
@ -1,3 +1,5 @@
|
|||
#ifndef Py_INTERNAL_DTOA_H
|
||||
#define Py_INTERNAL_DTOA_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -11,6 +13,46 @@ extern "C" {
|
|||
|
||||
#if _PY_SHORT_FLOAT_REPR == 1
|
||||
|
||||
typedef uint32_t ULong;
|
||||
|
||||
struct
|
||||
Bigint {
|
||||
struct Bigint *next;
|
||||
int k, maxwds, sign, wds;
|
||||
ULong x[1];
|
||||
};
|
||||
|
||||
#ifdef Py_USING_MEMORY_DEBUGGER
|
||||
|
||||
struct _dtoa_runtime_state {
|
||||
int _not_used;
|
||||
};
|
||||
#define _dtoa_runtime_state_INIT {0}
|
||||
|
||||
#else // !Py_USING_MEMORY_DEBUGGER
|
||||
|
||||
/* The size of the Bigint freelist */
|
||||
#define Bigint_Kmax 7
|
||||
|
||||
#ifndef PRIVATE_MEM
|
||||
#define PRIVATE_MEM 2304
|
||||
#endif
|
||||
#define Bigint_PREALLOC_SIZE \
|
||||
((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
|
||||
|
||||
struct _dtoa_runtime_state {
|
||||
struct Bigint *freelist[Bigint_Kmax+1];
|
||||
double preallocated[Bigint_PREALLOC_SIZE];
|
||||
double *preallocated_next;
|
||||
};
|
||||
#define _dtoa_runtime_state_INIT(runtime) \
|
||||
{ \
|
||||
.preallocated_next = runtime.dtoa.preallocated, \
|
||||
}
|
||||
|
||||
#endif // !Py_USING_MEMORY_DEBUGGER
|
||||
|
||||
|
||||
/* These functions are used by modules compiled as C extension like math:
|
||||
they must be exported. */
|
||||
|
||||
|
|
@ -26,3 +68,4 @@ PyAPI_FUNC(double) _Py_dg_infinity(int sign);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_INTERNAL_DTOA_H */
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ extern "C" {
|
|||
#include "pycore_unicodeobject.h" // struct _Py_unicode_state
|
||||
#include "pycore_warnings.h" // struct _warnings_runtime_state
|
||||
|
||||
|
||||
struct _pending_calls {
|
||||
PyThread_type_lock lock;
|
||||
/* Request for running pending calls. */
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc);
|
|||
|
||||
/* Various one-time initializers */
|
||||
|
||||
extern void _Py_InitVersion(void);
|
||||
extern PyStatus _PyImport_Init(void);
|
||||
extern PyStatus _PyFaulthandler_Init(int enable);
|
||||
extern int _PyTraceMalloc_Init(int enable);
|
||||
|
|
|
|||
|
|
@ -113,8 +113,6 @@ struct _PyTraceMalloc_Config {
|
|||
.tracing = 0, \
|
||||
.max_nframe = 1}
|
||||
|
||||
PyAPI_DATA(struct _PyTraceMalloc_Config) _Py_tracemalloc_config;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "pycore_atomic.h" /* _Py_atomic_address */
|
||||
#include "pycore_dtoa.h" // struct _dtoa_runtime_state
|
||||
#include "pycore_gil.h" // struct _gil_runtime_state
|
||||
#include "pycore_global_objects.h" // struct _Py_global_objects
|
||||
#include "pycore_import.h" // struct _import_runtime_state
|
||||
|
|
@ -18,7 +19,8 @@ extern "C" {
|
|||
#include "pycore_unicodeobject.h" // struct _Py_unicode_runtime_ids
|
||||
|
||||
struct _getargs_runtime_state {
|
||||
PyThread_type_lock mutex;
|
||||
PyThread_type_lock mutex;
|
||||
struct _PyArg_Parser *static_parsers;
|
||||
};
|
||||
|
||||
/* ceval state */
|
||||
|
|
@ -125,6 +127,10 @@ typedef struct pyruntimestate {
|
|||
struct _ceval_runtime_state ceval;
|
||||
struct _gilstate_runtime_state gilstate;
|
||||
struct _getargs_runtime_state getargs;
|
||||
struct {
|
||||
struct _PyTraceMalloc_Config config;
|
||||
} tracemalloc;
|
||||
struct _dtoa_runtime_state dtoa;
|
||||
|
||||
PyPreConfig preconfig;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ extern "C" {
|
|||
until _PyInterpreterState_Enable() is called. */ \
|
||||
.next_id = -1, \
|
||||
}, \
|
||||
.tracemalloc = { \
|
||||
.config = _PyTraceMalloc_Config_INIT, \
|
||||
}, \
|
||||
.dtoa = _dtoa_runtime_state_INIT(runtime), \
|
||||
.types = { \
|
||||
.next_version_tag = 1, \
|
||||
}, \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue