File indexing completed on 2025-11-19 09:50:48
0001 #ifndef Py_INTERNAL_MIMALLOC_H
0002 #define Py_INTERNAL_MIMALLOC_H
0003
0004 #ifndef Py_BUILD_CORE
0005 # error "this header requires Py_BUILD_CORE define"
0006 #endif
0007
0008 #if defined(MIMALLOC_H) || defined(MIMALLOC_TYPES_H)
0009 # error "pycore_mimalloc.h must be included before mimalloc.h"
0010 #endif
0011
0012 typedef enum {
0013 _Py_MIMALLOC_HEAP_MEM = 0,
0014 _Py_MIMALLOC_HEAP_OBJECT = 1,
0015 _Py_MIMALLOC_HEAP_GC = 2,
0016 _Py_MIMALLOC_HEAP_GC_PRE = 3,
0017 _Py_MIMALLOC_HEAP_COUNT
0018 } _Py_mimalloc_heap_id;
0019
0020 #include "pycore_pymem.h"
0021
0022 #ifdef WITH_MIMALLOC
0023 # ifdef Py_GIL_DISABLED
0024 # define MI_PRIM_THREAD_ID _Py_ThreadId
0025 # endif
0026 # define MI_DEBUG_UNINIT PYMEM_CLEANBYTE
0027 # define MI_DEBUG_FREED PYMEM_DEADBYTE
0028 # define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
0029 #ifdef Py_DEBUG
0030 # define MI_DEBUG 2
0031 #else
0032 # define MI_DEBUG 0
0033 #endif
0034
0035 #ifdef _Py_THREAD_SANITIZER
0036 # define MI_TSAN 1
0037 #endif
0038
0039 #ifdef __cplusplus
0040 extern "C++" {
0041 #endif
0042
0043 #include "mimalloc/mimalloc.h"
0044 #include "mimalloc/mimalloc/types.h"
0045 #include "mimalloc/mimalloc/internal.h"
0046
0047 #ifdef __cplusplus
0048 }
0049 #endif
0050
0051 #endif
0052
0053 #ifdef Py_GIL_DISABLED
0054 struct _mimalloc_interp_state {
0055
0056
0057 mi_abandoned_pool_t abandoned_pool;
0058 };
0059
0060 struct _mimalloc_thread_state {
0061 mi_heap_t *current_object_heap;
0062 mi_heap_t heaps[_Py_MIMALLOC_HEAP_COUNT];
0063 mi_tld_t tld;
0064 int initialized;
0065 struct llist_node page_list;
0066 };
0067 #endif
0068
0069 #endif