Skip to content

Commit e78cecc

Browse files
committed
base import
1 parent 367adc9 commit e78cecc

16 files changed

+650
-257
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ struct _Py_global_strings {
318318
STRUCT_FOR_ID(c_call)
319319
STRUCT_FOR_ID(c_exception)
320320
STRUCT_FOR_ID(c_return)
321+
STRUCT_FOR_ID(cached_datetime_module)
321322
STRUCT_FOR_ID(cached_statements)
322323
STRUCT_FOR_ID(cadata)
323324
STRUCT_FOR_ID(cafile)

Include/internal/pycore_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ _PyObject_GET_WEAKREFS_LISTPTR(PyObject *op)
589589
if (PyType_Check(op) &&
590590
((PyTypeObject *)op)->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
591591
PyInterpreterState *interp = _PyInterpreterState_GET();
592-
static_builtin_state *state = _PyStaticType_GetState(
592+
managed_static_type_state *state = _PyStaticType_GetState(
593593
interp, (PyTypeObject *)op);
594594
return _PyStaticType_GET_WEAKREFS_LISTPTR(state);
595595
}

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_typeobject.h

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ struct type_cache {
4444

4545
/* For now we hard-code this to a value for which we are confident
4646
all the static builtin types will fit (for all builds). */
47-
#define _Py_MAX_STATIC_BUILTIN_TYPES 200
47+
#define _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES 200
48+
#define _Py_MAX_MANAGED_STATIC_EXT_TYPES 10
4849

4950
typedef struct {
5051
PyTypeObject *type;
52+
int isbuiltin;
5153
int readying;
5254
int ready;
5355
// XXX tp_dict can probably be statically allocated,
@@ -59,7 +61,7 @@ typedef struct {
5961
are also some diagnostic uses for the list of weakrefs,
6062
so we still keep it. */
6163
PyObject *tp_weaklist;
62-
} static_builtin_state;
64+
} managed_static_type_state;
6365

6466
struct types_state {
6567
/* Used to set PyTypeObject.tp_version_tag.
@@ -105,8 +107,16 @@ struct types_state {
105107
num_builtins_initialized is incremented once for each static
106108
builtin type. Once initialization is over for a subinterpreter,
107109
the value will be the same as for all other interpreters. */
108-
size_t num_builtins_initialized;
109-
static_builtin_state builtins[_Py_MAX_STATIC_BUILTIN_TYPES];
110+
struct {
111+
size_t num_initialized;
112+
managed_static_type_state initialized[_Py_MAX_MANAGED_STATIC_BUILTIN_TYPES];
113+
} builtins;
114+
/* We apply a similar strategy for managed extension modules. */
115+
struct {
116+
size_t num_initialized;
117+
size_t next_index;
118+
managed_static_type_state initialized[_Py_MAX_MANAGED_STATIC_EXT_TYPES];
119+
} for_extensions;
110120
PyMutex mutex;
111121
};
112122

@@ -130,12 +140,35 @@ typedef struct wrapperbase pytype_slotdef;
130140

131141

132142
static inline PyObject **
133-
_PyStaticType_GET_WEAKREFS_LISTPTR(static_builtin_state *state)
143+
_PyStaticType_GET_WEAKREFS_LISTPTR(managed_static_type_state *state)
134144
{
135145
assert(state != NULL);
136146
return &state->tp_weaklist;
137147
}
138148

149+
extern int _PyStaticType_InitBuiltin(
150+
PyInterpreterState *interp,
151+
PyTypeObject *type);
152+
extern void _PyStaticType_FiniBuiltin(
153+
PyInterpreterState *interp,
154+
PyTypeObject *type);
155+
extern void _PyStaticType_ClearWeakRefs(
156+
PyInterpreterState *interp,
157+
PyTypeObject *type);
158+
extern managed_static_type_state * _PyStaticType_GetState(
159+
PyInterpreterState *interp,
160+
PyTypeObject *type);
161+
162+
// Export for '_datetime' shared extension.
163+
PyAPI_FUNC(int) _PyStaticType_InitForExtension(
164+
PyInterpreterState *interp,
165+
PyTypeObject *self);
166+
PyAPI_FUNC(void) _PyStaticType_FiniForExtension(
167+
PyInterpreterState *interp,
168+
PyTypeObject *self,
169+
int final);
170+
171+
139172
/* Like PyType_GetModuleState, but skips verification
140173
* that type is a heap type with an associated module */
141174
static inline void *
@@ -151,11 +184,6 @@ _PyType_GetModuleState(PyTypeObject *type)
151184
}
152185

153186

154-
extern int _PyStaticType_InitBuiltin(PyInterpreterState *, PyTypeObject *type);
155-
extern static_builtin_state * _PyStaticType_GetState(PyInterpreterState *, PyTypeObject *);
156-
extern void _PyStaticType_ClearWeakRefs(PyInterpreterState *, PyTypeObject *type);
157-
extern void _PyStaticType_Dealloc(PyInterpreterState *, PyTypeObject *);
158-
159187
// Export for 'math' shared extension, used via _PyType_IsReady() static inline
160188
// function
161189
PyAPI_FUNC(PyObject *) _PyType_GetDict(PyTypeObject *);

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)