From 621cebe81b1e6c8de10425955bf532d31ee4df42 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 12 Nov 2018 16:53:38 +0100 Subject: bpo-35081: Rename internal headers (GH-10275) Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h --- Include/internal/pycore_hash.h | 10 -- Include/internal/pycore_lifecycle.h | 50 -------- Include/internal/pycore_mem.h | 163 -------------------------- Include/internal/pycore_pyhash.h | 10 ++ Include/internal/pycore_pylifecycle.h | 50 ++++++++ Include/internal/pycore_pymem.h | 163 ++++++++++++++++++++++++++ Include/internal/pycore_pystate.h | 214 ++++++++++++++++++++++++++++++++++ Include/internal/pycore_state.h | 214 ---------------------------------- Include/pystate.h | 2 +- Makefile.pre.in | 9 +- Modules/_functoolsmodule.c | 4 +- Modules/_io/bufferedio.c | 2 +- Modules/_threadmodule.c | 2 +- Modules/_xxsubinterpretersmodule.c | 2 +- Modules/gcmodule.c | 4 +- Modules/getpath.c | 2 +- Modules/main.c | 6 +- Modules/posixmodule.c | 2 +- Objects/abstract.c | 2 +- Objects/bytearrayobject.c | 4 +- Objects/bytesobject.c | 4 +- Objects/call.c | 2 +- Objects/cellobject.c | 4 +- Objects/classobject.c | 4 +- Objects/codeobject.c | 2 +- Objects/descrobject.c | 2 +- Objects/dictobject.c | 2 +- Objects/exceptions.c | 4 +- Objects/frameobject.c | 2 +- Objects/funcobject.c | 4 +- Objects/genobject.c | 2 +- Objects/iterobject.c | 4 +- Objects/listobject.c | 2 +- Objects/memoryobject.c | 4 +- Objects/methodobject.c | 4 +- Objects/moduleobject.c | 2 +- Objects/object.c | 2 +- Objects/obmalloc.c | 2 +- Objects/odictobject.c | 2 +- Objects/setobject.c | 2 +- Objects/sliceobject.c | 4 +- Objects/tupleobject.c | 2 +- Objects/typeobject.c | 2 +- Objects/unicodeobject.c | 2 +- PC/getpathp.c | 2 +- PCbuild/pythoncore.vcxproj | 7 +- PCbuild/pythoncore.vcxproj.filters | 11 +- Parser/myreadline.c | 2 +- Parser/pgenmain.c | 4 +- Programs/python.c | 2 +- Python/_warnings.c | 2 +- Python/bltinmodule.c | 2 +- Python/ceval.c | 2 +- Python/codecs.c | 2 +- Python/context.c | 2 +- Python/coreconfig.c | 6 +- Python/dynload_shlib.c | 2 +- Python/errors.c | 2 +- Python/frozenmain.c | 2 +- Python/hamt.c | 2 +- Python/import.c | 8 +- Python/pathconfig.c | 4 +- Python/pylifecycle.c | 6 +- Python/pystate.c | 4 +- Python/pythonrun.c | 2 +- Python/symtable.c | 2 +- Python/sysmodule.c | 6 +- Python/thread.c | 2 +- Python/traceback.c | 2 +- 69 files changed, 538 insertions(+), 531 deletions(-) delete mode 100644 Include/internal/pycore_hash.h delete mode 100644 Include/internal/pycore_lifecycle.h delete mode 100644 Include/internal/pycore_mem.h create mode 100644 Include/internal/pycore_pyhash.h create mode 100644 Include/internal/pycore_pylifecycle.h create mode 100644 Include/internal/pycore_pymem.h create mode 100644 Include/internal/pycore_pystate.h delete mode 100644 Include/internal/pycore_state.h diff --git a/Include/internal/pycore_hash.h b/Include/internal/pycore_hash.h deleted file mode 100644 index babbc95..0000000 --- a/Include/internal/pycore_hash.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef Py_INTERNAL_HASH_H -#define Py_INTERNAL_HASH_H - -#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) -# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define" -#endif - -uint64_t _Py_KeyedHash(uint64_t, const char *, Py_ssize_t); - -#endif diff --git a/Include/internal/pycore_lifecycle.h b/Include/internal/pycore_lifecycle.h deleted file mode 100644 index e104316..0000000 --- a/Include/internal/pycore_lifecycle.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef Py_INTERNAL_LIFECYCLE_H -#define Py_INTERNAL_LIFECYCLE_H -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) -# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define" -#endif - -PyAPI_FUNC(int) _Py_UnixMain(int argc, char **argv); - -PyAPI_FUNC(int) _Py_SetFileSystemEncoding( - const char *encoding, - const char *errors); -PyAPI_FUNC(void) _Py_ClearFileSystemEncoding(void); - -PyAPI_FUNC(void) _Py_ClearStandardStreamEncoding(void); - -PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc); - -extern int _PyUnicode_Init(void); -extern int _PyStructSequence_Init(void); -extern int _PyLong_Init(void); -extern _PyInitError _PyFaulthandler_Init(int enable); -extern int _PyTraceMalloc_Init(int enable); - -extern void _Py_ReadyTypes(void); - -PyAPI_FUNC(void) _PyExc_Fini(void); -PyAPI_FUNC(void) _PyImport_Fini(void); -PyAPI_FUNC(void) _PyImport_Fini2(void); -PyAPI_FUNC(void) _PyGC_Fini(void); -PyAPI_FUNC(void) _PyType_Fini(void); -PyAPI_FUNC(void) _Py_HashRandomization_Fini(void); -extern void _PyUnicode_Fini(void); -extern void PyLong_Fini(void); -extern void _PyFaulthandler_Fini(void); -extern void _PyHash_Fini(void); -extern int _PyTraceMalloc_Fini(void); - -extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *); -extern void _PyGILState_Fini(void); - -PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_INTERNAL_LIFECYCLE_H */ diff --git a/Include/internal/pycore_mem.h b/Include/internal/pycore_mem.h deleted file mode 100644 index 247426a..0000000 --- a/Include/internal/pycore_mem.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef Py_INTERNAL_MEM_H -#define Py_INTERNAL_MEM_H -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) -# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined" -#endif - -#include "objimpl.h" -#include "pymem.h" - - -/* GC runtime state */ - -/* If we change this, we need to change the default value in the - signature of gc.collect. */ -#define NUM_GENERATIONS 3 - -/* - NOTE: about the counting of long-lived objects. - - To limit the cost of garbage collection, there are two strategies; - - make each collection faster, e.g. by scanning fewer objects - - do less collections - This heuristic is about the latter strategy. - - In addition to the various configurable thresholds, we only trigger a - full collection if the ratio - long_lived_pending / long_lived_total - is above a given value (hardwired to 25%). - - The reason is that, while "non-full" collections (i.e., collections of - the young and middle generations) will always examine roughly the same - number of objects -- determined by the aforementioned thresholds --, - the cost of a full collection is proportional to the total number of - long-lived objects, which is virtually unbounded. - - Indeed, it has been remarked that doing a full collection every - of object creations entails a dramatic performance - degradation in workloads which consist in creating and storing lots of - long-lived objects (e.g. building a large list of GC-tracked objects would - show quadratic performance, instead of linear as expected: see issue #4074). - - Using the above ratio, instead, yields amortized linear performance in - the total number of objects (the effect of which can be summarized - thusly: "each full garbage collection is more and more costly as the - number of objects grows, but we do fewer and fewer of them"). - - This heuristic was suggested by Martin von Löwis on python-dev in - June 2008. His original analysis and proposal can be found at: - http://mail.python.org/pipermail/python-dev/2008-June/080579.html -*/ - -/* - NOTE: about untracking of mutable objects. - - Certain types of container cannot participate in a reference cycle, and - so do not need to be tracked by the garbage collector. Untracking these - objects reduces the cost of garbage collections. However, determining - which objects may be untracked is not free, and the costs must be - weighed against the benefits for garbage collection. - - There are two possible strategies for when to untrack a container: - - i) When the container is created. - ii) When the container is examined by the garbage collector. - - Tuples containing only immutable objects (integers, strings etc, and - recursively, tuples of immutable objects) do not need to be tracked. - The interpreter creates a large number of tuples, many of which will - not survive until garbage collection. It is therefore not worthwhile - to untrack eligible tuples at creation time. - - Instead, all tuples except the empty tuple are tracked when created. - During garbage collection it is determined whether any surviving tuples - can be untracked. A tuple can be untracked if all of its contents are - already not tracked. Tuples are examined for untracking in all garbage - collection cycles. It may take more than one cycle to untrack a tuple. - - Dictionaries containing only immutable objects also do not need to be - tracked. Dictionaries are untracked when created. If a tracked item is - inserted into a dictionary (either as a key or value), the dictionary - becomes tracked. During a full garbage collection (all generations), - the collector will untrack any dictionaries whose contents are not - tracked. - - The module provides the python function is_tracked(obj), which returns - the CURRENT tracking status of the object. Subsequent garbage - collections may change the tracking status of the object. - - Untracking of certain containers was introduced in issue #4688, and - the algorithm was refined in response to issue #14775. -*/ - -struct gc_generation { - PyGC_Head head; - int threshold; /* collection threshold */ - int count; /* count of allocations or collections of younger - generations */ -}; - -/* Running stats per generation */ -struct gc_generation_stats { - /* total number of collections */ - Py_ssize_t collections; - /* total number of collected objects */ - Py_ssize_t collected; - /* total number of uncollectable objects (put into gc.garbage) */ - Py_ssize_t uncollectable; -}; - -struct _gc_runtime_state { - /* List of objects that still need to be cleaned up, singly linked - * via their gc headers' gc_prev pointers. */ - PyObject *trash_delete_later; - /* Current call-stack depth of tp_dealloc calls. */ - int trash_delete_nesting; - - int enabled; - int debug; - /* linked lists of container objects */ - struct gc_generation generations[NUM_GENERATIONS]; - PyGC_Head *generation0; - /* a permanent generation which won't be collected */ - struct gc_generation permanent_generation; - struct gc_generation_stats generation_stats[NUM_GENERATIONS]; - /* true if we are currently running the collector */ - int collecting; - /* list of uncollectable objects */ - PyObject *garbage; - /* a list of callbacks to be invoked when collection is performed */ - PyObject *callbacks; - /* This is the number of objects that survived the last full - collection. It approximates the number of long lived objects - tracked by the GC. - - (by "full collection", we mean a collection of the oldest - generation). */ - Py_ssize_t long_lived_total; - /* This is the number of objects that survived all "non-full" - collections, and are awaiting to undergo a full collection for - the first time. */ - Py_ssize_t long_lived_pending; -}; - -PyAPI_FUNC(void) _PyGC_Initialize(struct _gc_runtime_state *); - -#define _PyGC_generation0 _PyRuntime.gc.generation0 - - -/* Set the memory allocator of the specified domain to the default. - Save the old allocator into *old_alloc if it's non-NULL. - Return on success, or return -1 if the domain is unknown. */ -PyAPI_FUNC(int) _PyMem_SetDefaultAllocator( - PyMemAllocatorDomain domain, - PyMemAllocatorEx *old_alloc); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_INTERNAL_MEM_H */ diff --git a/Include/internal/pycore_pyhash.h b/Include/internal/pycore_pyhash.h new file mode 100644 index 0000000..babbc95 --- /dev/null +++ b/Include/internal/pycore_pyhash.h @@ -0,0 +1,10 @@ +#ifndef Py_INTERNAL_HASH_H +#define Py_INTERNAL_HASH_H + +#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) +# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define" +#endif + +uint64_t _Py_KeyedHash(uint64_t, const char *, Py_ssize_t); + +#endif diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h new file mode 100644 index 0000000..e104316 --- /dev/null +++ b/Include/internal/pycore_pylifecycle.h @@ -0,0 +1,50 @@ +#ifndef Py_INTERNAL_LIFECYCLE_H +#define Py_INTERNAL_LIFECYCLE_H +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) +# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define" +#endif + +PyAPI_FUNC(int) _Py_UnixMain(int argc, char **argv); + +PyAPI_FUNC(int) _Py_SetFileSystemEncoding( + const char *encoding, + const char *errors); +PyAPI_FUNC(void) _Py_ClearFileSystemEncoding(void); + +PyAPI_FUNC(void) _Py_ClearStandardStreamEncoding(void); + +PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc); + +extern int _PyUnicode_Init(void); +extern int _PyStructSequence_Init(void); +extern int _PyLong_Init(void); +extern _PyInitError _PyFaulthandler_Init(int enable); +extern int _PyTraceMalloc_Init(int enable); + +extern void _Py_ReadyTypes(void); + +PyAPI_FUNC(void) _PyExc_Fini(void); +PyAPI_FUNC(void) _PyImport_Fini(void); +PyAPI_FUNC(void) _PyImport_Fini2(void); +PyAPI_FUNC(void) _PyGC_Fini(void); +PyAPI_FUNC(void) _PyType_Fini(void); +PyAPI_FUNC(void) _Py_HashRandomization_Fini(void); +extern void _PyUnicode_Fini(void); +extern void PyLong_Fini(void); +extern void _PyFaulthandler_Fini(void); +extern void _PyHash_Fini(void); +extern int _PyTraceMalloc_Fini(void); + +extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *); +extern void _PyGILState_Fini(void); + +PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_LIFECYCLE_H */ diff --git a/Include/internal/pycore_pymem.h b/Include/internal/pycore_pymem.h new file mode 100644 index 0000000..247426a --- /dev/null +++ b/Include/internal/pycore_pymem.h @@ -0,0 +1,163 @@ +#ifndef Py_INTERNAL_MEM_H +#define Py_INTERNAL_MEM_H +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) +# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined" +#endif + +#include "objimpl.h" +#include "pymem.h" + + +/* GC runtime state */ + +/* If we change this, we need to change the default value in the + signature of gc.collect. */ +#define NUM_GENERATIONS 3 + +/* + NOTE: about the counting of long-lived objects. + + To limit the cost of garbage collection, there are two strategies; + - make each collection faster, e.g. by scanning fewer objects + - do less collections + This heuristic is about the latter strategy. + + In addition to the various configurable thresholds, we only trigger a + full collection if the ratio + long_lived_pending / long_lived_total + is above a given value (hardwired to 25%). + + The reason is that, while "non-full" collections (i.e., collections of + the young and middle generations) will always examine roughly the same + number of objects -- determined by the aforementioned thresholds --, + the cost of a full collection is proportional to the total number of + long-lived objects, which is virtually unbounded. + + Indeed, it has been remarked that doing a full collection every + of object creations entails a dramatic performance + degradation in workloads which consist in creating and storing lots of + long-lived objects (e.g. building a large list of GC-tracked objects would + show quadratic performance, instead of linear as expected: see issue #4074). + + Using the above ratio, instead, yields amortized linear performance in + the total number of objects (the effect of which can be summarized + thusly: "each full garbage collection is more and more costly as the + number of objects grows, but we do fewer and fewer of them"). + + This heuristic was suggested by Martin von Löwis on python-dev in + June 2008. His original analysis and proposal can be found at: + http://mail.python.org/pipermail/python-dev/2008-June/080579.html +*/ + +/* + NOTE: about untracking of mutable objects. + + Certain types of container cannot participate in a reference cycle, and + so do not need to be tracked by the garbage collector. Untracking these + objects reduces the cost of garbage collections. However, determining + which objects may be untracked is not free, and the costs must be + weighed against the benefits for garbage collection. + + There are two possible strategies for when to untrack a container: + + i) When the container is created. + ii) When the container is examined by the garbage collector. + + Tuples containing only immutable objects (integers, strings etc, and + recursively, tuples of immutable objects) do not need to be tracked. + The interpreter creates a large number of tuples, many of which will + not survive until garbage collection. It is therefore not worthwhile + to untrack eligible tuples at creation time. + + Instead, all tuples except the empty tuple are tracked when created. + During garbage collection it is determined whether any surviving tuples + can be untracked. A tuple can be untracked if all of its contents are + already not tracked. Tuples are examined for untracking in all garbage + collection cycles. It may take more than one cycle to untrack a tuple. + + Dictionaries containing only immutable objects also do not need to be + tracked. Dictionaries are untracked when created. If a tracked item is + inserted into a dictionary (either as a key or value), the dictionary + becomes tracked. During a full garbage collection (all generations), + the collector will untrack any dictionaries whose contents are not + tracked. + + The module provides the python function is_tracked(obj), which returns + the CURRENT tracking status of the object. Subsequent garbage + collections may change the tracking status of the object. + + Untracking of certain containers was introduced in issue #4688, and + the algorithm was refined in response to issue #14775. +*/ + +struct gc_generation { + PyGC_Head head; + int threshold; /* collection threshold */ + int count; /* count of allocations or collections of younger + generations */ +}; + +/* Running stats per generation */ +struct gc_generation_stats { + /* total number of collections */ + Py_ssize_t collections; + /* total number of collected objects */ + Py_ssize_t collected; + /* total number of uncollectable objects (put into gc.garbage) */ + Py_ssize_t uncollectable; +}; + +struct _gc_runtime_state { + /* List of objects that still need to be cleaned up, singly linked + * via their gc headers' gc_prev pointers. */ + PyObject *trash_delete_later; + /* Current call-stack depth of tp_dealloc calls. */ + int trash_delete_nesting; + + int enabled; + int debug; + /* linked lists of container objects */ + struct gc_generation generations[NUM_GENERATIONS]; + PyGC_Head *generation0; + /* a permanent generation which won't be collected */ + struct gc_generation permanent_generation; + struct gc_generation_stats generation_stats[NUM_GENERATIONS]; + /* true if we are currently running the collector */ + int collecting; + /* list of uncollectable objects */ + PyObject *garbage; + /* a list of callbacks to be invoked when collection is performed */ + PyObject *callbacks; + /* This is the number of objects that survived the last full + collection. It approximates the number of long lived objects + tracked by the GC. + + (by "full collection", we mean a collection of the oldest + generation). */ + Py_ssize_t long_lived_total; + /* This is the number of objects that survived all "non-full" + collections, and are awaiting to undergo a full collection for + the first time. */ + Py_ssize_t long_lived_pending; +}; + +PyAPI_FUNC(void) _PyGC_Initialize(struct _gc_runtime_state *); + +#define _PyGC_generation0 _PyRuntime.gc.generation0 + + +/* Set the memory allocator of the specified domain to the default. + Save the old allocator into *old_alloc if it's non-NULL. + Return on success, or return -1 if the domain is unknown. */ +PyAPI_FUNC(int) _PyMem_SetDefaultAllocator( + PyMemAllocatorDomain domain, + PyMemAllocatorEx *old_alloc); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_MEM_H */ diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h new file mode 100644 index 0000000..4f5545a --- /dev/null +++ b/Include/internal/pycore_pystate.h @@ -0,0 +1,214 @@ +#ifndef Py_INTERNAL_PYSTATE_H +#define Py_INTERNAL_PYSTATE_H +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) +# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define" +#endif + +#include "pystate.h" +#include "pythread.h" + +#include "pycore_ceval.h" +#include "pycore_pathconfig.h" +#include "pycore_pymem.h" +#include "pycore_warnings.h" + + +/* GIL state */ + +struct _gilstate_runtime_state { + int check_enabled; + /* Assuming the current thread holds the GIL, this is the + PyThreadState for the current thread. */ + _Py_atomic_address tstate_current; + PyThreadFrameGetter getframe; + /* The single PyInterpreterState used by this process' + GILState implementation + */ + /* TODO: Given interp_main, it may be possible to kill this ref */ + PyInterpreterState *autoInterpreterState; + Py_tss_t autoTSSkey; +}; + +/* hook for PyEval_GetFrame(), requested for Psyco */ +#define _PyThreadState_GetFrame _PyRuntime.gilstate.getframe + +/* Issue #26558: Flag to disable PyGILState_Check(). + If set to non-zero, PyGILState_Check() always return 1. */ +#define _PyGILState_check_enabled _PyRuntime.gilstate.check_enabled + + +/* interpreter state */ + +PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpID(PY_INT64_T); + +PyAPI_FUNC(int) _PyInterpreterState_IDInitref(PyInterpreterState *); +PyAPI_FUNC(void) _PyInterpreterState_IDIncref(PyInterpreterState *); +PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *); + + +/* cross-interpreter data */ + +struct _xid; + +// _PyCrossInterpreterData is similar to Py_buffer as an effectively +// opaque struct that holds data outside the object machinery. This +// is necessary to pass safely between interpreters in the same process. +typedef struct _xid { + // data is the cross-interpreter-safe derivation of a Python object + // (see _PyObject_GetCrossInterpreterData). It will be NULL if the + // new_object func (below) encodes the data. + void *data; + // obj is the Python object from which the data was derived. This + // is non-NULL only if the data remains bound to the object in some + // way, such that the object must be "released" (via a decref) when + // the data is released. In that case the code that sets the field, + // likely a registered "crossinterpdatafunc", is responsible for + // ensuring it owns the reference (i.e. incref). + PyObject *obj; + // interp is the ID of the owning interpreter of the original + // object. It corresponds to the active interpreter when + // _PyObject_GetCrossInterpreterData() was called. This should only + // be set by the cross-interpreter machinery. + // + // We use the ID rather than the PyInterpreterState to avoid issues + // with deleted interpreters. + int64_t interp; + // new_object is a function that returns a new object in the current + // interpreter given the data. The resulting object (a new + // reference) will be equivalent to the original object. This field + // is required. + PyObject *(*new_object)(struct _xid *); + // free is called when the data is released. If it is NULL then + // nothing will be done to free the data. For some types this is + // okay (e.g. bytes) and for those types this field should be set + // to NULL. However, for most the data was allocated just for + // cross-interpreter use, so it must be freed when + // _PyCrossInterpreterData_Release is called or the memory will + // leak. In that case, at the very least this field should be set + // to PyMem_RawFree (the default if not explicitly set to NULL). + // The call will happen with the original interpreter activated. + void (*free)(void *); +} _PyCrossInterpreterData; + +typedef int (*crossinterpdatafunc)(PyObject *, _PyCrossInterpreterData *); +PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *); + +PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *); +PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *); +PyAPI_FUNC(void) _PyCrossInterpreterData_Release(_PyCrossInterpreterData *); + +/* cross-interpreter data registry */ + +/* For now we use a global registry of shareable classes. An + alternative would be to add a tp_* slot for a class's + crossinterpdatafunc. It would be simpler and more efficient. */ + +PyAPI_FUNC(int) _PyCrossInterpreterData_Register_Class(PyTypeObject *, crossinterpdatafunc); +PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *); + +struct _xidregitem; + +struct _xidregitem { + PyTypeObject *cls; + crossinterpdatafunc getdata; + struct _xidregitem *next; +}; + + +/* Full Python runtime state */ + +typedef struct pyruntimestate { + int initialized; + int core_initialized; + PyThreadState *finalizing; + + struct pyinterpreters { + PyThread_type_lock mutex; + PyInterpreterState *head; + PyInterpreterState *main; + /* _next_interp_id is an auto-numbered sequence of small + integers. It gets initialized in _PyInterpreterState_Init(), + which is called in Py_Initialize(), and used in + PyInterpreterState_New(). A negative interpreter ID + indicates an error occurred. The main interpreter will + always have an ID of 0. Overflow results in a RuntimeError. + If that becomes a problem later then we can adjust, e.g. by + using a Python int. */ + int64_t next_id; + } interpreters; + // XXX Remove this field once we have a tp_* slot. + struct _xidregistry { + PyThread_type_lock mutex; + struct _xidregitem *head; + } xidregistry; + +#define NEXITFUNCS 32 + void (*exitfuncs[NEXITFUNCS])(void); + int nexitfuncs; + + struct _gc_runtime_state gc; + struct _warnings_runtime_state warnings; + struct _ceval_runtime_state ceval; + struct _gilstate_runtime_state gilstate; + + // XXX Consolidate globals found via the check-c-globals script. +} _PyRuntimeState; + +#define _PyRuntimeState_INIT {.initialized = 0, .core_initialized = 0} +/* Note: _PyRuntimeState_INIT sets other fields to 0/NULL */ + +PyAPI_DATA(_PyRuntimeState) _PyRuntime; +PyAPI_FUNC(_PyInitError) _PyRuntimeState_Init(_PyRuntimeState *); +PyAPI_FUNC(void) _PyRuntimeState_Fini(_PyRuntimeState *); + +/* Initialize _PyRuntimeState. + Return NULL on success, or return an error message on failure. */ +PyAPI_FUNC(_PyInitError) _PyRuntime_Initialize(void); + +#define _Py_CURRENTLY_FINALIZING(tstate) \ + (_PyRuntime.finalizing == tstate) + + +/* Variable and macro for in-line access to current thread + and interpreter state */ + +/* Get the current Python thread state. + + Efficient macro reading directly the 'gilstate.tstate_current' atomic + variable. The macro is unsafe: it does not check for error and it can + return NULL. + + The caller must hold the GIL. + + See also PyThreadState_Get() and PyThreadState_GET(). */ +#define _PyThreadState_GET() \ + ((PyThreadState*)_Py_atomic_load_relaxed(&_PyRuntime.gilstate.tstate_current)) + +/* Redefine PyThreadState_GET() as an alias to _PyThreadState_GET() */ +#undef PyThreadState_GET +#define PyThreadState_GET() _PyThreadState_GET() + +/* Get the current interpreter state. + + The macro is unsafe: it does not check for error and it can return NULL. + + The caller must hold the GIL. + + See also _PyInterpreterState_Get() + and _PyGILState_GetInterpreterStateUnsafe(). */ +#define _PyInterpreterState_GET_UNSAFE() (_PyThreadState_GET()->interp) + + +/* Other */ + +PyAPI_FUNC(_PyInitError) _PyInterpreterState_Enable(_PyRuntimeState *); +PyAPI_FUNC(void) _PyInterpreterState_DeleteExceptMain(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_PYSTATE_H */ diff --git a/Include/internal/pycore_state.h b/Include/internal/pycore_state.h deleted file mode 100644 index 01f2140..0000000 --- a/Include/internal/pycore_state.h +++ /dev/null @@ -1,214 +0,0 @@ -#ifndef Py_INTERNAL_PYSTATE_H -#define Py_INTERNAL_PYSTATE_H -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) -# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define" -#endif - -#include "pystate.h" -#include "pythread.h" - -#include "pycore_ceval.h" -#include "pycore_mem.h" -#include "pycore_pathconfig.h" -#include "pycore_warnings.h" - - -/* GIL state */ - -struct _gilstate_runtime_state { - int check_enabled; - /* Assuming the current thread holds the GIL, this is the - PyThreadState for the current thread. */ - _Py_atomic_address tstate_current; - PyThreadFrameGetter getframe; - /* The single PyInterpreterState used by this process' - GILState implementation - */ - /* TODO: Given interp_main, it may be possible to kill this ref */ - PyInterpreterState *autoInterpreterState; - Py_tss_t autoTSSkey; -}; - -/* hook for PyEval_GetFrame(), requested for Psyco */ -#define _PyThreadState_GetFrame _PyRuntime.gilstate.getframe - -/* Issue #26558: Flag to disable PyGILState_Check(). - If set to non-zero, PyGILState_Check() always return 1. */ -#define _PyGILState_check_enabled _PyRuntime.gilstate.check_enabled - - -/* interpreter state */ - -PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpID(PY_INT64_T); - -PyAPI_FUNC(int) _PyInterpreterState_IDInitref(PyInterpreterState *); -PyAPI_FUNC(void) _PyInterpreterState_IDIncref(PyInterpreterState *); -PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *); - - -/* cross-interpreter data */ - -struct _xid; - -// _PyCrossInterpreterData is similar to Py_buffer as an effectively -// opaque struct that holds data outside the object machinery. This -// is necessary to pass safely between interpreters in the same process. -typedef struct _xid { - // data is the cross-interpreter-safe derivation of a Python object - // (see _PyObject_GetCrossInterpreterData). It will be NULL if the - // new_object func (below) encodes the data. - void *data; - // obj is the Python object from which the data was derived. This - // is non-NULL only if the data remains bound to the object in some - // way, such that the object must be "released" (via a decref) when - // the data is released. In that case the code that sets the field, - // likely a registered "crossinterpdatafunc", is responsible for - // ensuring it owns the reference (i.e. incref). - PyObject *obj; - // interp is the ID of the owning interpreter of the original - // object. It corresponds to the active interpreter when - // _PyObject_GetCrossInterpreterData() was called. This should only - // be set by the cross-interpreter machinery. - // - // We use the ID rather than the PyInterpreterState to avoid issues - // with deleted interpreters. - int64_t interp; - // new_object is a function that returns a new object in the current - // interpreter given the data. The resulting object (a new - // reference) will be equivalent to the original object. This field - // is required. - PyObject *(*new_object)(struct _xid *); - // free is called when the data is released. If it is NULL then - // nothing will be done to free the data. For some types this is - // okay (e.g. bytes) and for those types this field should be set - // to NULL. However, for most the data was allocated just for - // cross-interpreter use, so it must be freed when - // _PyCrossInterpreterData_Release is called or the memory will - // leak. In that case, at the very least this field should be set - // to PyMem_RawFree (the default if not explicitly set to NULL). - // The call will happen with the original interpreter activated. - void (*free)(void *); -} _PyCrossInterpreterData; - -typedef int (*crossinterpdatafunc)(PyObject *, _PyCrossInterpreterData *); -PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *); - -PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *); -PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *); -PyAPI_FUNC(void) _PyCrossInterpreterData_Release(_PyCrossInterpreterData *); - -/* cross-interpreter data registry */ - -/* For now we use a global registry of shareable classes. An - alternative would be to add a tp_* slot for a class's - crossinterpdatafunc. It would be simpler and more efficient. */ - -PyAPI_FUNC(int) _PyCrossInterpreterData_Register_Class(PyTypeObject *, crossinterpdatafunc); -PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *); - -struct _xidregitem; - -struct _xidregitem { - PyTypeObject *cls; - crossinterpdatafunc getdata; - struct _xidregitem *next; -}; - - -/* Full Python runtime state */ - -typedef struct pyruntimestate { - int initialized; - int core_initialized; - PyThreadState *finalizing; - - struct pyinterpreters { - PyThread_type_lock mutex; - PyInterpreterState *head; - PyInterpreterState *main; - /* _next_interp_id is an auto-numbered sequence of small - integers. It gets initialized in _PyInterpreterState_Init(), - which is called in Py_Initialize(), and used in - PyInterpreterState_New(). A negative interpreter ID - indicates an error occurred. The main interpreter will - always have an ID of 0. Overflow results in a RuntimeError. - If that becomes a problem later then we can adjust, e.g. by - using a Python int. */ - int64_t next_id; - } interpreters; - // XXX Remove this field once we have a tp_* slot. - struct _xidregistry { - PyThread_type_lock mutex; - struct _xidregitem *head; - } xidregistry; - -#define NEXITFUNCS 32 - void (*exitfuncs[NEXITFUNCS])(void); - int nexitfuncs; - - struct _gc_runtime_state gc; - struct _warnings_runtime_state warnings; - struct _ceval_runtime_state ceval; - struct _gilstate_runtime_state gilstate; - - // XXX Consolidate globals found via the check-c-globals script. -} _PyRuntimeState; - -#define _PyRuntimeState_INIT {.initialized = 0, .core_initialized = 0} -/* Note: _PyRuntimeState_INIT sets other fields to 0/NULL */ - -PyAPI_DATA(_PyRuntimeState) _PyRuntime; -PyAPI_FUNC(_PyInitError) _PyRuntimeState_Init(_PyRuntimeState *); -PyAPI_FUNC(void) _PyRuntimeState_Fini(_PyRuntimeState *); - -/* Initialize _PyRuntimeState. - Return NULL on success, or return an error message on failure. */ -PyAPI_FUNC(_PyInitError) _PyRuntime_Initialize(void); - -#define _Py_CURRENTLY_FINALIZING(tstate) \ - (_PyRuntime.finalizing == tstate) - - -/* Variable and macro for in-line access to current thread - and interpreter state */ - -/* Get the current Python thread state. - - Efficient macro reading directly the 'gilstate.tstate_current' atomic - variable. The macro is unsafe: it does not check for error and it can - return NULL. - - The caller must hold the GIL. - - See also PyThreadState_Get() and PyThreadState_GET(). */ -#define _PyThreadState_GET() \ - ((PyThreadState*)_Py_atomic_load_relaxed(&_PyRuntime.gilstate.tstate_current)) - -/* Redefine PyThreadState_GET() as an alias to _PyThreadState_GET() */ -#undef PyThreadState_GET -#define PyThreadState_GET() _PyThreadState_GET() - -/* Get the current interpreter state. - - The macro is unsafe: it does not check for error and it can return NULL. - - The caller must hold the GIL. - - See also _PyInterpreterState_Get() - and _PyGILState_GetInterpreterStateUnsafe(). */ -#define _PyInterpreterState_GET_UNSAFE() (_PyThreadState_GET()->interp) - - -/* Other */ - -PyAPI_FUNC(_PyInitError) _PyInterpreterState_Enable(_PyRuntimeState *); -PyAPI_FUNC(void) _PyInterpreterState_DeleteExceptMain(void); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_INTERNAL_PYSTATE_H */ diff --git a/Include/pystate.h b/Include/pystate.h index b30c318..58499ea 100644 --- a/Include/pystate.h +++ b/Include/pystate.h @@ -301,7 +301,7 @@ PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); /* Get the current Python thread state. Macro using PyThreadState_Get() or _PyThreadState_GET() depending if - pycore_state.h is included or not (this header redefines the macro). + pycore_pystate.h is included or not (this header redefines the macro). If PyThreadState_Get() is used, issue a fatal error if the current thread state is NULL. diff --git a/Makefile.pre.in b/Makefile.pre.in index 15f3687..87a84eb 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1027,13 +1027,16 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_accu.h \ $(srcdir)/Include/internal/pycore_atomic.h \ $(srcdir)/Include/internal/pycore_ceval.h \ + $(srcdir)/Include/internal/pycore_condvar.h \ $(srcdir)/Include/internal/pycore_context.h \ $(srcdir)/Include/internal/pycore_getopt.h \ $(srcdir)/Include/internal/pycore_gil.h \ - $(srcdir)/Include/internal/pycore_lifecycle.h \ - $(srcdir)/Include/internal/pycore_mem.h \ + $(srcdir)/Include/internal/pycore_hamt.h \ $(srcdir)/Include/internal/pycore_pathconfig.h \ - $(srcdir)/Include/internal/pycore_state.h \ + $(srcdir)/Include/internal/pycore_pyhash.h \ + $(srcdir)/Include/internal/pycore_pylifecycle.h \ + $(srcdir)/Include/internal/pycore_pymem.h \ + $(srcdir)/Include/internal/pycore_pystate.h \ $(srcdir)/Include/internal/pycore_warnings.h \ $(DTRACE_HEADERS) diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 692c3b3..773102b 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1,7 +1,7 @@ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "structmember.h" /* _functools module written and maintained diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 24ae963..e1e45dc 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -9,7 +9,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "structmember.h" #include "pythread.h" #include "_iomodule.h" diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index ad65188..72d044c 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -3,7 +3,7 @@ /* Interface to Sjoerd's portable C thread library */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "structmember.h" /* offsetof */ #include "pythread.h" diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c index fb0b83a..33509ef 100644 --- a/Modules/_xxsubinterpretersmodule.c +++ b/Modules/_xxsubinterpretersmodule.c @@ -4,7 +4,7 @@ #include "Python.h" #include "frameobject.h" -#include "pycore_state.h" +#include "pycore_pystate.h" static char * diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index a54be07..48b4700 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -25,8 +25,8 @@ #include "Python.h" #include "pycore_context.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "frameobject.h" /* for PyFrame_ClearFreeList */ #include "pydtrace.h" #include "pytime.h" /* for _PyTime_GetMonotonicClock() */ diff --git a/Modules/getpath.c b/Modules/getpath.c index 6b443f6..18df795 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -4,7 +4,7 @@ #include "osdefs.h" #include "pycore_fileutils.h" #include "pycore_pathconfig.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include #include diff --git a/Modules/main.c b/Modules/main.c index c847d1a..281707a 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -3,10 +3,10 @@ #include "Python.h" #include "osdefs.h" #include "pycore_getopt.h" -#include "pycore_lifecycle.h" -#include "pycore_mem.h" #include "pycore_pathconfig.h" -#include "pycore_state.h" +#include "pycore_pylifecycle.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index bf886e3..bf3e03e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -32,7 +32,7 @@ #else #include "winreparse.h" #endif -#include "pycore_state.h" +#include "pycore_pystate.h" /* On android API level 21, 'AT_EACCESS' is not declared although * HAVE_FACCESSAT is defined. */ diff --git a/Objects/abstract.c b/Objects/abstract.c index be4758d..567da2d 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1,7 +1,7 @@ /* Abstract Object Interface (many thanks to Jim Fulton) */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include #include "structmember.h" /* we need the offsetof() macro from there */ #include "longintrepr.h" diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 7a0c340..561b06c 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2,8 +2,8 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "structmember.h" #include "bytes_methods.h" #include "bytesobject.h" diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index c912fc0..fac12f5 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3,8 +3,8 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "bytes_methods.h" #include "pystrhex.h" diff --git a/Objects/call.c b/Objects/call.c index 707b49a..7c452b9 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -1,5 +1,5 @@ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "frameobject.h" diff --git a/Objects/cellobject.c b/Objects/cellobject.c index 0b390c7..7605bcf 100644 --- a/Objects/cellobject.c +++ b/Objects/cellobject.c @@ -1,8 +1,8 @@ /* Cell object implementation */ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" PyObject * PyCell_New(PyObject *obj) diff --git a/Objects/classobject.c b/Objects/classobject.c index 93d1c67..79b0562 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -1,8 +1,8 @@ /* Class object implementation (dead now except for methods) */ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "structmember.h" #define TP_DESCR_GET(t) ((t)->tp_descr_get) diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 2450213..a2efa7e 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -3,7 +3,7 @@ #include "Python.h" #include "code.h" #include "structmember.h" -#include "pycore_state.h" +#include "pycore_pystate.h" /* Holder for co_extra information */ typedef struct { diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 17d0f5a..ca814bf 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1,7 +1,7 @@ /* Descriptors -- a new, flexible way to describe attributes */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "structmember.h" /* Why is this not included in Python.h? */ /*[clinic input] diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 08ec9e2..ca383a1 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -111,7 +111,7 @@ converting the dict to the combined table. #define PyDict_MINSIZE 8 #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "dict-common.h" #include "stringlib/eq.h" /* to get unicode_eq() */ diff --git a/Objects/exceptions.c b/Objects/exceptions.c index da79260..5ab1271 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -6,8 +6,8 @@ #define PY_SSIZE_T_CLEAN #include -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "structmember.h" #include "osdefs.h" diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 7704022..70cf580 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1,7 +1,7 @@ /* Frame object implementation */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "code.h" #include "frameobject.h" diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 8648821..a8e11a9 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -2,8 +2,8 @@ /* Function object implementation */ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "code.h" #include "structmember.h" diff --git a/Objects/genobject.c b/Objects/genobject.c index 7c2948b..98c9394 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -1,7 +1,7 @@ /* Generator object implementation */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "frameobject.h" #include "structmember.h" #include "opcode.h" diff --git a/Objects/iterobject.c b/Objects/iterobject.c index 23f0639..64bf923 100644 --- a/Objects/iterobject.c +++ b/Objects/iterobject.c @@ -1,8 +1,8 @@ /* Iterator objects */ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" typedef struct { PyObject_HEAD diff --git a/Objects/listobject.c b/Objects/listobject.c index ffd91a6..44160ab 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -1,7 +1,7 @@ /* List object implementation */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "pycore_accu.h" #ifdef STDC_HEADERS diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index f234bb4..060ae4d 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1,8 +1,8 @@ /* Memoryview object implementation */ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "pystrhex.h" #include diff --git a/Objects/methodobject.c b/Objects/methodobject.c index b0bbfa2..cfea8cf 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -2,8 +2,8 @@ /* Method object implementation */ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "structmember.h" /* Free list for method objects to safe malloc/free overhead diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 7fb711a..fca8521 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -2,7 +2,7 @@ /* Module object implementation */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "structmember.h" static Py_ssize_t max_module_number; diff --git a/Objects/object.c b/Objects/object.c index 72e2684..801b205 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2,7 +2,7 @@ /* Generic object operations; and implementation of None */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "pycore_context.h" #include "frameobject.h" diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 2cf024c..1c2a320 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -1,5 +1,5 @@ #include "Python.h" -#include "pycore_mem.h" +#include "pycore_pymem.h" #include diff --git a/Objects/odictobject.c b/Objects/odictobject.c index 52ac7e5..13bc972 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -465,7 +465,7 @@ later: */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "structmember.h" #include "dict-common.h" #include diff --git a/Objects/setobject.c b/Objects/setobject.c index 035b1db..b11cb3a 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -32,7 +32,7 @@ */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "structmember.h" /* Object used as dummy key to fill deleted entries */ diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index 9f1cf78..1f79faa 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -14,8 +14,8 @@ this type and there is exactly one in existence. */ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "structmember.h" static PyObject * diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index c997bc6..e7ba09d 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -2,7 +2,7 @@ /* Tuple object implementation */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "pycore_accu.h" /*[clinic input] diff --git a/Objects/typeobject.c b/Objects/typeobject.c index dedc4f7..682d446 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1,7 +1,7 @@ /* Type object implementation */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "frameobject.h" #include "structmember.h" diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5338781..e5d026f 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -41,7 +41,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define PY_SSIZE_T_CLEAN #include "Python.h" #include "pycore_fileutils.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "ucnhash.h" #include "bytes_methods.h" #include "stringlib/eq.h" diff --git a/PC/getpathp.c b/PC/getpathp.c index 3a62738..ee9d3d2 100644 --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -80,7 +80,7 @@ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "osdefs.h" #include diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 460500c..0ae24fa 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -119,10 +119,11 @@ - - - + + + + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 64fb77b..ef5ef72 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -156,16 +156,19 @@ Include - + Include - + Include - + + Include + + Include - + Include diff --git a/Parser/myreadline.c b/Parser/myreadline.c index f511319..acb4d01 100644 --- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -10,7 +10,7 @@ */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #ifdef MS_WINDOWS #define WIN32_LEAN_AND_MEAN #include "windows.h" diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c index 9e2159b..fa6c882 100644 --- a/Parser/pgenmain.c +++ b/Parser/pgenmain.c @@ -16,8 +16,8 @@ #define PGEN #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "pgenheaders.h" #include "grammar.h" #include "node.h" diff --git a/Programs/python.c b/Programs/python.c index 079bf9a..4c12d38c 100644 --- a/Programs/python.c +++ b/Programs/python.c @@ -1,7 +1,7 @@ /* Minimal main program -- everything is loaded from the library */ #include "Python.h" -#include "pycore_lifecycle.h" +#include "pycore_pylifecycle.h" #ifdef MS_WINDOWS int diff --git a/Python/_warnings.c b/Python/_warnings.c index 9b50289..4065005 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -1,5 +1,5 @@ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "frameobject.h" #include "clinic/_warnings.c.h" diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 6781589..14550fd 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -3,7 +3,7 @@ #include "Python.h" #include #include "ast.h" -#include "pycore_state.h" +#include "pycore_pystate.h" _Py_IDENTIFIER(__builtins__); _Py_IDENTIFIER(__dict__); diff --git a/Python/ceval.c b/Python/ceval.c index 11be8ef..9c0ab06 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -10,7 +10,7 @@ #define PY_LOCAL_AGGRESSIVE #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "code.h" #include "dictobject.h" diff --git a/Python/codecs.c b/Python/codecs.c index 62bbee6..002fad30 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -9,7 +9,7 @@ Copyright (c) Corporation for National Research Initiatives. ------------------------------------------------------------------------ */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "ucnhash.h" #include diff --git a/Python/context.c b/Python/context.c index 1fb2a5d..b548ffe 100644 --- a/Python/context.c +++ b/Python/context.c @@ -1,7 +1,7 @@ #include "Python.h" #include "structmember.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "pycore_context.h" #include "pycore_hamt.h" diff --git a/Python/coreconfig.c b/Python/coreconfig.c index c81cd8b..7aa64e1 100644 --- a/Python/coreconfig.c +++ b/Python/coreconfig.c @@ -1,9 +1,9 @@ #include "Python.h" #include "pycore_fileutils.h" -#include "pycore_lifecycle.h" -#include "pycore_mem.h" +#include "pycore_pylifecycle.h" +#include "pycore_pymem.h" #include "pycore_pathconfig.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include #ifdef HAVE_LANGINFO_H # include diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 9896560..feebd89 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -2,7 +2,7 @@ /* Support for dynamic loading of extension modules */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "importdl.h" #include diff --git a/Python/errors.c b/Python/errors.c index 4c6c34c..febe971 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -2,7 +2,7 @@ /* Error handling */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #ifndef __STDC__ #ifndef MS_WINDOWS diff --git a/Python/frozenmain.c b/Python/frozenmain.c index 9e90666..6160909 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -2,7 +2,7 @@ /* Python interpreter main program for frozen scripts */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include #ifdef MS_WINDOWS diff --git a/Python/hamt.c b/Python/hamt.c index be3813b..3fe70b40 100644 --- a/Python/hamt.c +++ b/Python/hamt.c @@ -1,7 +1,7 @@ #include "Python.h" #include "structmember.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "pycore_hamt.h" /* diff --git a/Python/import.c b/Python/import.c index fcd8851..f7c37aa 100644 --- a/Python/import.c +++ b/Python/import.c @@ -3,10 +3,10 @@ #include "Python.h" #include "Python-ast.h" -#include "pycore_hash.h" -#include "pycore_lifecycle.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pyhash.h" +#include "pycore_pylifecycle.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "errcode.h" #include "marshal.h" #include "code.h" diff --git a/Python/pathconfig.c b/Python/pathconfig.c index 2d8b417..6a86880 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -2,10 +2,10 @@ #include "Python.h" #include "osdefs.h" -#include "pycore_mem.h" #include "pycore_fileutils.h" #include "pycore_pathconfig.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include #ifdef __cplusplus diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 318d7cb..4ccea2e 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -5,10 +5,10 @@ #include "Python-ast.h" #include "pycore_context.h" #include "pycore_hamt.h" -#include "pycore_lifecycle.h" -#include "pycore_mem.h" #include "pycore_pathconfig.h" -#include "pycore_state.h" +#include "pycore_pylifecycle.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #include "grammar.h" #include "node.h" #include "token.h" diff --git a/Python/pystate.c b/Python/pystate.c index c193a10..f86f5a9 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -2,8 +2,8 @@ /* Thread and interpreter state structures and their interfaces */ #include "Python.h" -#include "pycore_mem.h" -#include "pycore_state.h" +#include "pycore_pymem.h" +#include "pycore_pystate.h" #define _PyThreadState_SET(value) \ _Py_atomic_store_relaxed(&_PyRuntime.gilstate.tstate_current, \ diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 2b9f4f0..1bf822c 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -11,7 +11,7 @@ #include "Python.h" #include "Python-ast.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "grammar.h" #include "node.h" #include "token.h" diff --git a/Python/symtable.c b/Python/symtable.c index 40f9178..c095c82 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1,5 +1,5 @@ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "symtable.h" #include "structmember.h" diff --git a/Python/sysmodule.c b/Python/sysmodule.c index c0f168c..99cab2b 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -17,10 +17,10 @@ Data members: #include "Python.h" #include "code.h" #include "frameobject.h" -#include "pycore_lifecycle.h" -#include "pycore_mem.h" +#include "pycore_pylifecycle.h" +#include "pycore_pymem.h" #include "pycore_pathconfig.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "pythread.h" #include "osdefs.h" diff --git a/Python/thread.c b/Python/thread.c index 6355381..c5364f9 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -6,7 +6,7 @@ Stuff shared by all thread_*.h files is collected here. */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #ifndef _POSIX_THREADS /* This means pthreads are not implemented in libc headers, hence the macro diff --git a/Python/traceback.c b/Python/traceback.c index e2070f0..daaf287 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -2,7 +2,7 @@ /* Traceback implementation */ #include "Python.h" -#include "pycore_state.h" +#include "pycore_pystate.h" #include "code.h" #include "frameobject.h" -- cgit v0.12