File indexing completed on 2025-01-30 10:18:08
0001 #ifndef Py_LIMITED_API
0002 #ifndef Py_INTERNAL_IMPORT_H
0003 #define Py_INTERNAL_IMPORT_H
0004 #ifdef __cplusplus
0005 extern "C" {
0006 #endif
0007
0008 #include "pycore_hashtable.h" // _Py_hashtable_t
0009 #include "pycore_time.h" // _PyTime_t
0010
0011
0012 struct _import_runtime_state {
0013
0014 struct _inittab *inittab;
0015
0016
0017
0018
0019 Py_ssize_t last_module_index;
0020 struct {
0021
0022 PyThread_type_lock mutex;
0023
0024
0025
0026
0027
0028
0029 _Py_hashtable_t *hashtable;
0030 } extensions;
0031
0032 const char * pkgcontext;
0033 };
0034
0035 struct _import_state {
0036
0037 PyObject *modules;
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 PyObject *modules_by_index;
0058
0059 PyObject *importlib;
0060
0061
0062 int override_frozen_modules;
0063 int override_multi_interp_extensions_check;
0064 #ifdef HAVE_DLOPEN
0065 int dlopenflags;
0066 #endif
0067 PyObject *import_func;
0068
0069 struct {
0070 PyThread_type_lock mutex;
0071 unsigned long thread;
0072 int level;
0073 } lock;
0074
0075 struct {
0076 int import_level;
0077 _PyTime_t accumulated;
0078 int header;
0079 } find_and_load;
0080 };
0081
0082 #ifdef HAVE_DLOPEN
0083 # include <dlfcn.h>
0084 # if HAVE_DECL_RTLD_NOW
0085 # define _Py_DLOPEN_FLAGS RTLD_NOW
0086 # else
0087 # define _Py_DLOPEN_FLAGS RTLD_LAZY
0088 # endif
0089 # define DLOPENFLAGS_INIT .dlopenflags = _Py_DLOPEN_FLAGS,
0090 #else
0091 # define _Py_DLOPEN_FLAGS 0
0092 # define DLOPENFLAGS_INIT
0093 #endif
0094
0095 #define IMPORTS_INIT \
0096 { \
0097 DLOPENFLAGS_INIT \
0098 .lock = { \
0099 .mutex = NULL, \
0100 .thread = PYTHREAD_INVALID_THREAD_ID, \
0101 .level = 0, \
0102 }, \
0103 .find_and_load = { \
0104 .header = 1, \
0105 }, \
0106 }
0107
0108 extern void _PyImport_ClearCore(PyInterpreterState *interp);
0109
0110 extern Py_ssize_t _PyImport_GetNextModuleIndex(void);
0111 extern const char * _PyImport_ResolveNameWithPackageContext(const char *name);
0112 extern const char * _PyImport_SwapPackageContext(const char *newcontext);
0113
0114 extern int _PyImport_GetDLOpenFlags(PyInterpreterState *interp);
0115 extern void _PyImport_SetDLOpenFlags(PyInterpreterState *interp, int new_val);
0116
0117 extern PyObject * _PyImport_InitModules(PyInterpreterState *interp);
0118 extern PyObject * _PyImport_GetModules(PyInterpreterState *interp);
0119 extern void _PyImport_ClearModules(PyInterpreterState *interp);
0120
0121 extern void _PyImport_ClearModulesByIndex(PyInterpreterState *interp);
0122
0123 extern int _PyImport_InitDefaultImportFunc(PyInterpreterState *interp);
0124 extern int _PyImport_IsDefaultImportFunc(
0125 PyInterpreterState *interp,
0126 PyObject *func);
0127
0128 extern PyObject * _PyImport_GetImportlibLoader(
0129 PyInterpreterState *interp,
0130 const char *loader_name);
0131 extern PyObject * _PyImport_GetImportlibExternalLoader(
0132 PyInterpreterState *interp,
0133 const char *loader_name);
0134 extern PyObject * _PyImport_BlessMyLoader(
0135 PyInterpreterState *interp,
0136 PyObject *module_globals);
0137 extern PyObject * _PyImport_ImportlibModuleRepr(
0138 PyInterpreterState *interp,
0139 PyObject *module);
0140
0141
0142 extern PyStatus _PyImport_Init(void);
0143 extern void _PyImport_Fini(void);
0144 extern void _PyImport_Fini2(void);
0145
0146 extern PyStatus _PyImport_InitCore(
0147 PyThreadState *tstate,
0148 PyObject *sysmod,
0149 int importlib);
0150 extern PyStatus _PyImport_InitExternal(PyThreadState *tstate);
0151 extern void _PyImport_FiniCore(PyInterpreterState *interp);
0152 extern void _PyImport_FiniExternal(PyInterpreterState *interp);
0153
0154
0155 #ifdef HAVE_FORK
0156 extern PyStatus _PyImport_ReInitLock(PyInterpreterState *interp);
0157 #endif
0158
0159
0160 extern PyObject* _PyImport_GetBuiltinModuleNames(void);
0161
0162 struct _module_alias {
0163 const char *name;
0164 const char *orig;
0165 };
0166
0167 PyAPI_DATA(const struct _frozen *) _PyImport_FrozenBootstrap;
0168 PyAPI_DATA(const struct _frozen *) _PyImport_FrozenStdlib;
0169 PyAPI_DATA(const struct _frozen *) _PyImport_FrozenTest;
0170 extern const struct _module_alias * _PyImport_FrozenAliases;
0171
0172 PyAPI_FUNC(int) _PyImport_CheckSubinterpIncompatibleExtensionAllowed(
0173 const char *name);
0174
0175
0176
0177 PyAPI_FUNC(int) _PyImport_ClearExtension(PyObject *name, PyObject *filename);
0178
0179 #ifdef __cplusplus
0180 }
0181 #endif
0182 #endif
0183 #endif