mirror of
https://github.com/python/cpython
synced 2026-09-29 11:30:29 +03:00
gh-81057: Move time Globals to _PyRuntimeState (gh-100122)
https://github.com/python/cpython/issues/81057
This commit is contained in:
parent
cda9f0236f
commit
8a3f06c54b
14 changed files with 100 additions and 118 deletions
|
|
@ -1,38 +0,0 @@
|
|||
#ifndef Py_INTERNAL_OS_H
|
||||
#define Py_INTERNAL_OS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef Py_BUILD_CORE
|
||||
# error "this header requires Py_BUILD_CORE define"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MS_WINDOWS
|
||||
#define _OS_NEED_TICKS_PER_SECOND
|
||||
# define need_ticks_per_second_STATE \
|
||||
long ticks_per_second;
|
||||
# define need_ticks_per_second_INIT \
|
||||
.ticks_per_second = -1,
|
||||
#else
|
||||
# define need_ticks_per_second_STATE
|
||||
# define need_ticks_per_second_INIT
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
|
||||
struct _os_runtime_state {
|
||||
int _not_used;
|
||||
need_ticks_per_second_STATE
|
||||
};
|
||||
# define _OS_RUNTIME_INIT \
|
||||
{ \
|
||||
._not_used = 0, \
|
||||
need_ticks_per_second_INIT \
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_INTERNAL_OS_H */
|
||||
|
|
@ -44,6 +44,7 @@ extern void _PySys_Fini(PyInterpreterState *interp);
|
|||
extern int _PyBuiltins_AddExceptions(PyObject * bltinmod);
|
||||
extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
|
||||
|
||||
extern PyStatus _PyTime_Init(void);
|
||||
extern PyStatus _PyImportZip_Init(PyThreadState *tstate);
|
||||
extern PyStatus _PyGC_Init(PyInterpreterState *interp);
|
||||
extern PyStatus _PyAtExit_Init(PyInterpreterState *interp);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ extern "C" {
|
|||
#include "pycore_pymem.h" // struct _pymem_allocators
|
||||
#include "pycore_pyhash.h" // struct pyhash_runtime_state
|
||||
#include "pycore_obmalloc.h" // struct obmalloc_state
|
||||
#include "pycore_os.h" // struct _os_runtime_state
|
||||
#include "pycore_time.h" // struct _time_runtime_state
|
||||
#include "pycore_unicodeobject.h" // struct _Py_unicode_runtime_ids
|
||||
|
||||
struct _getargs_runtime_state {
|
||||
|
|
@ -104,7 +104,7 @@ typedef struct pyruntimestate {
|
|||
* KeyboardInterrupt exception, suggesting the user pressed ^C. */
|
||||
int unhandled_keyboard_interrupt;
|
||||
} signals;
|
||||
struct _os_runtime_state os;
|
||||
struct _time_runtime_state time;
|
||||
|
||||
struct pyinterpreters {
|
||||
PyThread_type_lock mutex;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ extern "C" {
|
|||
}, \
|
||||
.obmalloc = _obmalloc_state_INIT(runtime.obmalloc), \
|
||||
.pyhash_state = pyhash_state_INIT, \
|
||||
.os = _OS_RUNTIME_INIT, \
|
||||
.interpreters = { \
|
||||
/* This prevents interpreters from getting created \
|
||||
until _PyInterpreterState_Enable() is called. */ \
|
||||
|
|
|
|||
25
Include/internal/pycore_time.h
Normal file
25
Include/internal/pycore_time.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef Py_INTERNAL_TIME_H
|
||||
#define Py_INTERNAL_TIME_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef Py_BUILD_CORE
|
||||
# error "this header requires Py_BUILD_CORE define"
|
||||
#endif
|
||||
|
||||
|
||||
struct _time_runtime_state {
|
||||
#ifdef HAVE_TIMES
|
||||
int ticks_per_second_initialized;
|
||||
long ticks_per_second;
|
||||
#else
|
||||
int _not_used;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_INTERNAL_TIME_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue