Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:08:49

0001 #ifndef Py_INTERNAL_RUNTIME_INIT_H
0002 #define Py_INTERNAL_RUNTIME_INIT_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 #include "pycore_long.h"
0012 #include "pycore_object.h"
0013 #include "pycore_parser.h"
0014 #include "pycore_pymem_init.h"
0015 #include "pycore_obmalloc_init.h"
0016 
0017 
0018 extern PyTypeObject _PyExc_MemoryError;
0019 
0020 
0021 /* The static initializers defined here should only be used
0022    in the runtime init code (in pystate.c and pylifecycle.c). */
0023 
0024 
0025 #define _PyRuntimeState_INIT(runtime) \
0026     { \
0027         .allocators = { \
0028             .standard = _pymem_allocators_standard_INIT(runtime), \
0029             .debug = _pymem_allocators_debug_INIT, \
0030             .obj_arena = _pymem_allocators_obj_arena_INIT, \
0031         }, \
0032         .obmalloc = _obmalloc_global_state_INIT, \
0033         .pyhash_state = pyhash_state_INIT, \
0034         .signals = _signals_RUNTIME_INIT, \
0035         .interpreters = { \
0036             /* This prevents interpreters from getting created \
0037               until _PyInterpreterState_Enable() is called. */ \
0038             .next_id = -1, \
0039         }, \
0040         /* A TSS key must be initialized with Py_tss_NEEDS_INIT \
0041            in accordance with the specification. */ \
0042         .autoTSSkey = Py_tss_NEEDS_INIT, \
0043         .parser = _parser_runtime_state_INIT, \
0044         .ceval = { \
0045             .perf = _PyEval_RUNTIME_PERF_INIT, \
0046         }, \
0047         .gilstate = { \
0048             .check_enabled = 1, \
0049         }, \
0050         .fileutils = { \
0051             .force_ascii = -1, \
0052         }, \
0053         .faulthandler = _faulthandler_runtime_state_INIT, \
0054         .tracemalloc = _tracemalloc_runtime_state_INIT, \
0055         .float_state = { \
0056             .float_format = _py_float_format_unknown, \
0057             .double_format = _py_float_format_unknown, \
0058         }, \
0059         .types = { \
0060             .next_version_tag = 1, \
0061         }, \
0062         .static_objects = { \
0063             .singletons = { \
0064                 .small_ints = _Py_small_ints_INIT, \
0065                 .bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \
0066                 .bytes_characters = _Py_bytes_characters_INIT, \
0067                 .strings = { \
0068                     .literals = _Py_str_literals_INIT, \
0069                     .identifiers = _Py_str_identifiers_INIT, \
0070                     .ascii = _Py_str_ascii_INIT, \
0071                     .latin1 = _Py_str_latin1_INIT, \
0072                 }, \
0073                 .tuple_empty = { \
0074                     .ob_base = _PyVarObject_HEAD_INIT(&PyTuple_Type, 0) \
0075                 }, \
0076                 .hamt_bitmap_node_empty = { \
0077                     .ob_base = _PyVarObject_HEAD_INIT(&_PyHamt_BitmapNode_Type, 0) \
0078                 }, \
0079                 .context_token_missing = { \
0080                     .ob_base = _PyObject_HEAD_INIT(&_PyContextTokenMissing_Type) \
0081                 }, \
0082             }, \
0083         }, \
0084         ._main_interpreter = _PyInterpreterState_INIT(runtime._main_interpreter), \
0085     }
0086 
0087 #define _PyInterpreterState_INIT(INTERP) \
0088     { \
0089         .id_refcount = -1, \
0090         .imports = IMPORTS_INIT, \
0091         .obmalloc = _obmalloc_state_INIT(INTERP.obmalloc), \
0092         .ceval = { \
0093             .recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
0094         }, \
0095         .gc = { \
0096             .enabled = 1, \
0097             .generations = { \
0098                 /* .head is set in _PyGC_InitState(). */ \
0099                 { .threshold = 700, }, \
0100                 { .threshold = 10, }, \
0101                 { .threshold = 10, }, \
0102             }, \
0103         }, \
0104         .object_state = _py_object_state_INIT(INTERP), \
0105         .dtoa = _dtoa_state_INIT(&(INTERP)), \
0106         .dict_state = _dict_state_INIT, \
0107         .func_state = { \
0108             .next_version = 1, \
0109         }, \
0110         .types = { \
0111             .next_version_tag = _Py_TYPE_BASE_VERSION_TAG, \
0112         }, \
0113         .static_objects = { \
0114             .singletons = { \
0115                 ._not_used = 1, \
0116                 .hamt_empty = { \
0117                     .ob_base = _PyObject_HEAD_INIT(&_PyHamt_Type) \
0118                     .h_root = (PyHamtNode*)&_Py_SINGLETON(hamt_bitmap_node_empty), \
0119                 }, \
0120                 .last_resort_memory_error = { \
0121                     _PyObject_HEAD_INIT(&_PyExc_MemoryError) \
0122                     .args = (PyObject*)&_Py_SINGLETON(tuple_empty) \
0123                 }, \
0124             }, \
0125         }, \
0126         ._initial_thread = _PyThreadState_INIT, \
0127     }
0128 
0129 #define _PyThreadState_INIT \
0130     { \
0131         .py_recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
0132         .context_ver = 1, \
0133     }
0134 
0135 # define _py_object_state_INIT(INTERP) \
0136     { 0 }
0137 
0138 
0139 // global objects
0140 
0141 #define _PyBytes_SIMPLE_INIT(CH, LEN) \
0142     { \
0143         _PyVarObject_HEAD_INIT(&PyBytes_Type, (LEN)) \
0144         .ob_shash = -1, \
0145         .ob_sval = { (CH) }, \
0146     }
0147 #define _PyBytes_CHAR_INIT(CH) \
0148     { \
0149         _PyBytes_SIMPLE_INIT((CH), 1) \
0150     }
0151 
0152 #define _PyUnicode_ASCII_BASE_INIT(LITERAL, ASCII) \
0153     { \
0154         .ob_base = _PyObject_HEAD_INIT(&PyUnicode_Type) \
0155         .length = sizeof(LITERAL) - 1, \
0156         .hash = -1, \
0157         .state = { \
0158             .kind = 1, \
0159             .compact = 1, \
0160             .ascii = (ASCII), \
0161             .statically_allocated = 1, \
0162         }, \
0163     }
0164 #define _PyASCIIObject_INIT(LITERAL) \
0165     { \
0166         ._ascii = _PyUnicode_ASCII_BASE_INIT((LITERAL), 1), \
0167         ._data = (LITERAL) \
0168     }
0169 #define INIT_STR(NAME, LITERAL) \
0170     ._py_ ## NAME = _PyASCIIObject_INIT(LITERAL)
0171 #define INIT_ID(NAME) \
0172     ._py_ ## NAME = _PyASCIIObject_INIT(#NAME)
0173 #define _PyUnicode_LATIN1_INIT(LITERAL, UTF8) \
0174     { \
0175         ._latin1 = { \
0176             ._base = _PyUnicode_ASCII_BASE_INIT((LITERAL), 0), \
0177             .utf8 = (UTF8), \
0178             .utf8_length = sizeof(UTF8) - 1, \
0179         }, \
0180         ._data = (LITERAL), \
0181     }
0182 
0183 #include "pycore_runtime_init_generated.h"
0184 
0185 #ifdef __cplusplus
0186 }
0187 #endif
0188 #endif /* !Py_INTERNAL_RUNTIME_INIT_H */