Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/internal/pycore_runtime_init.h
1 #ifndef Py_INTERNAL_RUNTIME_INIT_H 2 #define Py_INTERNAL_RUNTIME_INIT_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #ifndef Py_BUILD_CORE 8 # error "this header requires Py_BUILD_CORE define" 9 #endif 10 11 #include "pycore_structs.h" 12 #include "pycore_ceval_state.h" // _PyEval_RUNTIME_PERF_INIT 13 #include "pycore_debug_offsets.h" // _Py_DebugOffsets_INIT() 14 #include "pycore_dtoa.h" // _dtoa_state_INIT() 15 #include "pycore_faulthandler.h" // _faulthandler_runtime_state_INIT 16 #include "pycore_floatobject.h" // _py_float_format_unknown 17 #include "pycore_function.h" 18 #include "pycore_hamt.h" // _PyHamt_BitmapNode_Type 19 #include "pycore_import.h" // IMPORTS_INIT 20 #include "pycore_object.h" // _PyObject_HEAD_INIT 21 #include "pycore_obmalloc_init.h" // _obmalloc_global_state_INIT 22 #include "pycore_parser.h" // _parser_runtime_state_INIT 23 #include "pycore_pyhash.h" // pyhash_state_INIT 24 #include "pycore_pymem_init.h" // _pymem_allocators_standard_INIT 25 #include "pycore_pythread.h" // _pythread_RUNTIME_INIT 26 #include "pycore_qsbr.h" // QSBR_INITIAL 27 #include "pycore_runtime_init_generated.h" // _Py_bytes_characters_INIT 28 #include "pycore_signal.h" // _signals_RUNTIME_INIT 29 #include "pycore_tracemalloc.h" // _tracemalloc_runtime_state_INIT 30 #include "pycore_tuple.h" // _PyTuple_HASH_EMPTY 31 32 33 extern PyTypeObject _PyExc_MemoryError; 34 35 36 /* The static initializers defined here should only be used 37 in the runtime init code (in pystate.c and pylifecycle.c). */ 38 39 #define _PyRuntimeState_INIT(runtime, debug_cookie) \ 40 { \ 41 .debug_offsets = _Py_DebugOffsets_INIT(debug_cookie), \ 42 .allocators = { \ 43 .standard = _pymem_allocators_standard_INIT(runtime), \ 44 .debug = _pymem_allocators_debug_INIT, \ 45 .obj_arena = _pymem_allocators_obj_arena_INIT, \ 46 .is_debug_enabled = _pymem_is_debug_enabled_INIT, \ 47 }, \ 48 .obmalloc = _obmalloc_global_state_INIT, \ 49 .pyhash_state = pyhash_state_INIT, \ 50 .threads = _pythread_RUNTIME_INIT(runtime.threads), \ 51 .signals = _signals_RUNTIME_INIT, \ 52 .interpreters = { \ 53 /* This prevents interpreters from getting created \ 54 until _PyInterpreterState_Enable() is called. */ \ 55 .next_id = -1, \ 56 }, \ 57 .xi = { \ 58 .data_lookup = { \ 59 .registry = { \ 60 .global = 1, \ 61 }, \ 62 }, \ 63 }, \ 64 /* A TSS key must be initialized with Py_tss_NEEDS_INIT \ 65 in accordance with the specification. */ \ 66 .autoTSSkey = Py_tss_NEEDS_INIT, \ 67 .parser = _parser_runtime_state_INIT, \ 68 .ceval = { \ 69 .pending_mainthread = { \ 70 .max = MAXPENDINGCALLS_MAIN, \ 71 .maxloop = MAXPENDINGCALLSLOOP_MAIN, \ 72 }, \ 73 .perf = _PyEval_RUNTIME_PERF_INIT, \ 74 }, \ 75 .gilstate = { \ 76 .check_enabled = 1, \ 77 }, \ 78 .fileutils = { \ 79 .force_ascii = -1, \ 80 }, \ 81 .faulthandler = _faulthandler_runtime_state_INIT, \ 82 .tracemalloc = _tracemalloc_runtime_state_INIT, \ 83 .ref_tracer = { \ 84 .tracer_func = NULL, \ 85 .tracer_data = NULL, \ 86 }, \ 87 .stoptheworld = { \ 88 .is_global = 1, \ 89 }, \ 90 .float_state = { \ 91 .float_format = _py_float_format_unknown, \ 92 .double_format = _py_float_format_unknown, \ 93 }, \ 94 .types = { \ 95 .next_version_tag = _Py_TYPE_VERSION_NEXT, \ 96 }, \ 97 .static_objects = { \ 98 .singletons = { \ 99 .small_ints = _Py_small_ints_INIT, \ 100 .bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \ 101 .bytes_characters = _Py_bytes_characters_INIT, \ 102 .strings = { \ 103 .literals = _Py_str_literals_INIT, \ 104 .identifiers = _Py_str_identifiers_INIT, \ 105 .ascii = _Py_str_ascii_INIT, \ 106 .latin1 = _Py_str_latin1_INIT, \ 107 }, \ 108 .tuple_empty = { \ 109 .ob_base = _PyVarObject_HEAD_INIT(&PyTuple_Type, 0), \ 110 .ob_hash = _PyTuple_HASH_EMPTY, \ 111 }, \ 112 .hamt_bitmap_node_empty = { \ 113 .ob_base = _PyVarObject_HEAD_INIT(&_PyHamt_BitmapNode_Type, 0), \ 114 }, \ 115 .context_token_missing = { \ 116 .ob_base = _PyObject_HEAD_INIT(&_PyContextTokenMissing_Type), \ 117 }, \ 118 }, \ 119 }, \ 120 ._main_interpreter = _PyInterpreterState_INIT(runtime._main_interpreter), \ 121 } 122 123 #define _PyInterpreterState_INIT(INTERP) \ 124 { \ 125 .id_refcount = -1, \ 126 ._whence = _PyInterpreterState_WHENCE_NOTSET, \ 127 .threads = { \ 128 .preallocated = &(INTERP)._initial_thread, \ 129 }, \ 130 .imports = IMPORTS_INIT, \ 131 .ceval = { \ 132 .recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \ 133 .pending = { \ 134 .max = MAXPENDINGCALLS, \ 135 .maxloop = MAXPENDINGCALLSLOOP, \ 136 }, \ 137 }, \ 138 .gc = { \ 139 .enabled = 1, \ 140 .young = { .threshold = 2000, }, \ 141 .old = { \ 142 { .threshold = 10, }, \ 143 { .threshold = 0, }, \ 144 }, \ 145 .work_to_do = -5000, \ 146 .phase = GC_PHASE_MARK, \ 147 }, \ 148 .qsbr = { \ 149 .wr_seq = QSBR_INITIAL, \ 150 .rd_seq = QSBR_INITIAL, \ 151 }, \ 152 .dtoa = _dtoa_state_INIT(&(INTERP)), \ 153 .dict_state = _dict_state_INIT, \ 154 .mem_free_queue = _Py_mem_free_queue_INIT(INTERP.mem_free_queue), \ 155 .func_state = { \ 156 .next_version = FUNC_VERSION_FIRST_VALID, \ 157 }, \ 158 .types = { \ 159 .next_version_tag = _Py_TYPE_BASE_VERSION_TAG, \ 160 }, \ 161 .static_objects = { \ 162 .singletons = { \ 163 ._not_used = 1, \ 164 .hamt_empty = { \ 165 .ob_base = _PyObject_HEAD_INIT(&_PyHamt_Type), \ 166 .h_root = (PyHamtNode*)&_Py_SINGLETON(hamt_bitmap_node_empty), \ 167 }, \ 168 .last_resort_memory_error = { \ 169 _PyObject_HEAD_INIT(&_PyExc_MemoryError), \ 170 .args = (PyObject*)&_Py_SINGLETON(tuple_empty) \ 171 }, \ 172 }, \ 173 }, \ 174 ._initial_thread = _PyThreadStateImpl_INIT, \ 175 } 176 177 #define _PyThreadStateImpl_INIT \ 178 { \ 179 .base = _PyThreadState_INIT, \ 180 /* The thread and the interpreter's linked list hold a reference */ \ 181 .refcount = 2, \ 182 } 183 184 #define _PyThreadState_INIT \ 185 { \ 186 ._whence = _PyThreadState_WHENCE_NOTSET, \ 187 .py_recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \ 188 .context_ver = 1, \ 189 } 190 191 192 // global objects 193 194 #define _PyBytes_SIMPLE_INIT(CH, LEN) \ 195 { \ 196 _PyVarObject_HEAD_INIT(&PyBytes_Type, (LEN)), \ 197 .ob_shash = -1, \ 198 .ob_sval = { (CH) }, \ 199 } 200 #define _PyBytes_CHAR_INIT(CH) \ 201 { \ 202 _PyBytes_SIMPLE_INIT((CH), 1) \ 203 } 204 205 #define _PyUnicode_ASCII_BASE_INIT(LITERAL, ASCII) \ 206 { \ 207 .ob_base = _PyObject_HEAD_INIT(&PyUnicode_Type), \ 208 .length = sizeof(LITERAL) - 1, \ 209 .hash = -1, \ 210 .state = { \ 211 .kind = 1, \ 212 .compact = 1, \ 213 .ascii = (ASCII), \ 214 .statically_allocated = 1, \ 215 }, \ 216 } 217 #define _PyASCIIObject_INIT(LITERAL) \ 218 { \ 219 ._ascii = _PyUnicode_ASCII_BASE_INIT((LITERAL), 1), \ 220 ._data = (LITERAL) \ 221 } 222 #define INIT_STR(NAME, LITERAL) \ 223 ._py_ ## NAME = _PyASCIIObject_INIT(LITERAL) 224 #define INIT_ID(NAME) \ 225 ._py_ ## NAME = _PyASCIIObject_INIT(#NAME) 226 #define _PyUnicode_LATIN1_INIT(LITERAL, UTF8) \ 227 { \ 228 ._latin1 = { \ 229 ._base = _PyUnicode_ASCII_BASE_INIT((LITERAL), 0), \ 230 .utf8 = (UTF8), \ 231 .utf8_length = sizeof(UTF8) - 1, \ 232 }, \ 233 ._data = (LITERAL), \ 234 } 235 236 #ifdef __cplusplus 237 } 238 #endif 239 #endif /* !Py_INTERNAL_RUNTIME_INIT_H */