Skip to content

Instantly share code, notes, and snippets.

@godlygeek
Created June 26, 2023 17:21
Show Gist options
  • Select an option

  • Save godlygeek/341ce879a638c0fece9d0081d63e5ad9 to your computer and use it in GitHub Desktop.

Select an option

Save godlygeek/341ce879a638c0fece9d0081d63e5ad9 to your computer and use it in GitHub Desktop.
namespace Python3_12 {
typedef struct
{
void* ctx;
void* (*malloc)(void* ctx, size_t size);
void* (*calloc)(void* ctx, size_t nelem, size_t elsize);
void* (*realloc)(void* ctx, void* ptr, size_t new_size);
void (*free)(void* ctx, void* ptr);
} PyMemAllocatorEx;
typedef struct
{
char api_id;
PyMemAllocatorEx alloc;
} debug_alloc_api_t;
typedef struct
{
void* ctx;
void* (*alloc)(void* ctx, size_t size);
void (*free)(void* ctx, void* ptr, size_t size);
} PyObjectArenaAllocator;
struct _pymem_allocators
{
PyThread_type_lock mutex;
struct
{
PyMemAllocatorEx raw;
PyMemAllocatorEx mem;
PyMemAllocatorEx obj;
} standard;
struct
{
debug_alloc_api_t raw;
debug_alloc_api_t mem;
debug_alloc_api_t obj;
} debug;
PyObjectArenaAllocator obj_arena;
};
struct _obmalloc_global_state
{
int dump_debug_stats;
Py_ssize_t interpreter_leaks;
};
struct pyhash_runtime_state
{
struct
{
int fd;
dev_t st_dev;
ino_t st_ino;
} urandom_cache;
};
struct _time_runtime_state
{
int ticks_per_second_initialized;
long ticks_per_second;
};
struct _pythread_runtime_state
{
int initialized;
struct
{
pthread_condattr_t* ptr;
pthread_condattr_t val;
} _condattr_monotonic;
};
struct _signals_runtime_state
{
volatile struct
{
_Py_atomic_int tripped;
_Py_atomic_address func;
} handlers[NSIG];
volatile struct
{
sig_atomic_t fd;
int warn_on_full_buffer;
} wakeup;
_Py_atomic_int is_tripped;
PyObject* default_handler;
PyObject* ignore_handler;
int unhandled_keyboard_interrupt;
};
typedef struct
{
Py_ssize_t length;
wchar_t** items;
} PyWideStringList;
struct _gilstate_runtime_state {
int check_enabled;
PyInterpreterState *autoInterpreterState;
};
typedef struct pyruntimestate
{
int _initialized;
int preinitializing;
int preinitialized;
int core_initialized;
int initialized;
PyThreadState* _finalizing;
struct _pymem_allocators allocators;
struct _obmalloc_global_state obmalloc;
struct pyhash_runtime_state pyhash_state;
struct _time_runtime_state time;
struct _pythread_runtime_state threads;
struct _signals_runtime_state signals;
struct pyinterpreters
{
PyThread_type_lock mutex;
PyInterpreterState* head;
PyInterpreterState* main;
int64_t next_id;
} interpreters;
struct _xidregistry
{
PyThread_type_lock mutex;
struct _xidregitem* head;
} xidregistry;
unsigned long main_thread;
_Py_tss_t autoTSSkey;
_Py_tss_t trashTSSkey;
PyWideStringList orig_argv;
struct _gilstate_runtime_state gilstate;
int gc; // This is fake, but is here for compatibility
} PyRuntimeState;
} // namespace Python3_12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment