codekingpro/portable-devtools
114k
1#ifndef Py_INTERNAL_MIMALLOC_H2#define Py_INTERNAL_MIMALLOC_H3 4#ifndef Py_BUILD_CORE5# error "this header requires Py_BUILD_CORE define"6#endif7 8#if defined(MIMALLOC_H) || defined(MIMALLOC_TYPES_H)9# error "pycore_mimalloc.h must be included before mimalloc.h"10#endif11 12typedef enum {13 _Py_MIMALLOC_HEAP_MEM = 0, // PyMem_Malloc() and friends14 _Py_MIMALLOC_HEAP_OBJECT = 1, // non-GC objects15 _Py_MIMALLOC_HEAP_GC = 2, // GC objects without pre-header16 _Py_MIMALLOC_HEAP_GC_PRE = 3, // GC objects with pre-header17 _Py_MIMALLOC_HEAP_COUNT18} _Py_mimalloc_heap_id;19 20#include "pycore_pymem.h"21 22#ifdef WITH_MIMALLOC23# ifdef Py_GIL_DISABLED24# define MI_PRIM_THREAD_ID _Py_ThreadId25# endif26# define MI_DEBUG_UNINIT PYMEM_CLEANBYTE27# define MI_DEBUG_FREED PYMEM_DEADBYTE28# define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE29#ifdef Py_DEBUG30# define MI_DEBUG 231#else32# define MI_DEBUG 033#endif34 35#ifdef _Py_THREAD_SANITIZER36# define MI_TSAN 137#endif38 39#ifdef __cplusplus40extern "C++" {41#endif42 43#include "mimalloc/mimalloc.h"44#include "mimalloc/mimalloc/types.h"45#include "mimalloc/mimalloc/internal.h"46 47#ifdef __cplusplus48}49#endif50 51#endif52 53#ifdef Py_GIL_DISABLED54struct _mimalloc_interp_state {55 // When exiting, threads place any segments with live blocks in this56 // shared pool for other threads to claim and reuse.57 mi_abandoned_pool_t abandoned_pool;58};59 60struct _mimalloc_thread_state {61 mi_heap_t *current_object_heap;62 mi_heap_t heaps[_Py_MIMALLOC_HEAP_COUNT];63 mi_tld_t tld;64 int initialized;65 struct llist_node page_list;66};67#endif68 69#endif // Py_INTERNAL_MIMALLOC_H70 