Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:18:06

0001 #ifndef Py_INTERNAL_GLOBAL_OBJECTS_H
0002 #define Py_INTERNAL_GLOBAL_OBJECTS_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_hashtable.h"       // _Py_hashtable_t
0012 #include "pycore_gc.h"              // PyGC_Head
0013 #include "pycore_global_strings.h"  // struct _Py_global_strings
0014 #include "pycore_hamt.h"            // PyHamtNode_Bitmap
0015 #include "pycore_context.h"         // _PyContextTokenMissing
0016 #include "pycore_typeobject.h"      // pytype_slotdef
0017 
0018 
0019 // These would be in pycore_long.h if it weren't for an include cycle.
0020 #define _PY_NSMALLPOSINTS           257
0021 #define _PY_NSMALLNEGINTS           5
0022 
0023 
0024 // Only immutable objects should be considered runtime-global.
0025 // All others must be per-interpreter.
0026 
0027 #define _Py_GLOBAL_OBJECT(NAME) \
0028     _PyRuntime.static_objects.NAME
0029 #define _Py_SINGLETON(NAME) \
0030     _Py_GLOBAL_OBJECT(singletons.NAME)
0031 
0032 struct _Py_cached_objects {
0033     // XXX We could statically allocate the hashtable.
0034     _Py_hashtable_t *interned_strings;
0035 };
0036 
0037 struct _Py_static_objects {
0038     struct {
0039         /* Small integers are preallocated in this array so that they
0040          * can be shared.
0041          * The integers that are preallocated are those in the range
0042          * -_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (exclusive).
0043          */
0044         PyLongObject small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS];
0045 
0046         PyBytesObject bytes_empty;
0047         struct {
0048             PyBytesObject ob;
0049             char eos;
0050         } bytes_characters[256];
0051 
0052         struct _Py_global_strings strings;
0053 
0054         _PyGC_Head_UNUSED _tuple_empty_gc_not_used;
0055         PyTupleObject tuple_empty;
0056 
0057         _PyGC_Head_UNUSED _hamt_bitmap_node_empty_gc_not_used;
0058         PyHamtNode_Bitmap hamt_bitmap_node_empty;
0059         _PyContextTokenMissing context_token_missing;
0060     } singletons;
0061 };
0062 
0063 #define _Py_INTERP_CACHED_OBJECT(interp, NAME) \
0064     (interp)->cached_objects.NAME
0065 
0066 struct _Py_interp_cached_objects {
0067     PyObject *interned_strings;
0068 
0069     /* AST */
0070     PyObject *str_replace_inf;
0071 
0072     /* object.__reduce__ */
0073     PyObject *objreduce;
0074     PyObject *type_slots_pname;
0075     pytype_slotdef *type_slots_ptrs[MAX_EQUIV];
0076 
0077     /* TypeVar and related types */
0078     PyTypeObject *generic_type;
0079     PyTypeObject *typevar_type;
0080     PyTypeObject *typevartuple_type;
0081     PyTypeObject *paramspec_type;
0082     PyTypeObject *paramspecargs_type;
0083     PyTypeObject *paramspeckwargs_type;
0084 };
0085 
0086 #define _Py_INTERP_STATIC_OBJECT(interp, NAME) \
0087     (interp)->static_objects.NAME
0088 #define _Py_INTERP_SINGLETON(interp, NAME) \
0089     _Py_INTERP_STATIC_OBJECT(interp, singletons.NAME)
0090 
0091 struct _Py_interp_static_objects {
0092     struct {
0093         int _not_used;
0094         // hamt_empty is here instead of global because of its weakreflist.
0095         _PyGC_Head_UNUSED _hamt_empty_gc_not_used;
0096         PyHamtObject hamt_empty;
0097         PyBaseExceptionObject last_resort_memory_error;
0098     } singletons;
0099 };
0100 
0101 
0102 #ifdef __cplusplus
0103 }
0104 #endif
0105 #endif /* !Py_INTERNAL_GLOBAL_OBJECTS_H */