codekingpro/portable-devtools
114k
1/* This files contains various key structs that are widely used2 * and do not depend on other headers. */3 4#ifndef Py_INTERNAL_STRUCTS_H5#define Py_INTERNAL_STRUCTS_H6#ifdef __cplusplus7extern "C" {8#endif9 10#include <stdint.h> // uint16_t11 12 13typedef struct {14 uint16_t value_and_backoff;15} _Py_BackoffCounter;16 17/* Each instruction in a code object is a fixed-width value,18 * currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG19 * opcode allows for larger values but the current limit is 3 uses20 * of EXTENDED_ARG (see Python/compile.c), for a maximum21 * 32-bit value. This aligns with the note in Python/compile.c22 * (compiler_addop_i_line) indicating that the max oparg value is23 * 2**32 - 1, rather than INT_MAX.24 */25typedef union {26 uint16_t cache;27 struct {28 uint8_t code;29 uint8_t arg;30 } op;31 _Py_BackoffCounter counter; // First cache entry of specializable op32} _Py_CODEUNIT;33 34 35/* Abstract tree node. */36typedef struct {37 PyObject_HEAD38} PyHamtNode;39 40 41/* An HAMT immutable mapping collection. */42typedef struct {43 PyObject_HEAD44 PyHamtNode *h_root;45 PyObject *h_weakreflist;46 Py_ssize_t h_count;47} PyHamtObject;48 49typedef struct {50 PyObject_VAR_HEAD51 uint32_t b_bitmap;52 PyObject *b_array[1];53} PyHamtNode_Bitmap;54 55#include "pycore_context.h" // _PyContextTokenMissing56 57// Define this to get precise tracking of stackrefs.58// #define Py_STACKREF_DEBUG 159 60// Define this to get precise tracking of closed stackrefs.61// This will use unbounded memory, as it can only grow.62// Use this to track double closes in short-lived programs63// #define Py_STACKREF_CLOSE_DEBUG 164 65 66typedef union _PyStackRef {67#if !defined(Py_GIL_DISABLED) && defined(Py_STACKREF_DEBUG)68 uint64_t index;69#else70 uintptr_t bits;71#endif72} _PyStackRef;73 74// A stackref that can be stored in a regular C local variable and be visible75// to the GC in the free threading build.76// Used in combination with _PyThreadState_PushCStackRef().77typedef struct _PyCStackRef {78 _PyStackRef ref;79#ifdef Py_GIL_DISABLED80 struct _PyCStackRef *next;81#endif82} _PyCStackRef;83 84 85#ifdef __cplusplus86}87#endif88#endif /* Py_INTERNAL_STRUCTS_H */89 