diff options
author | Sam Gross <colesbury@gmail.com> | 2023-12-12 00:04:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 00:04:48 (GMT) |
commit | fdee7b7b3e15931d58f07e5449de2e55b4d48b05 (patch) | |
tree | e04dca3c8005a42f1d5973938e6e41c64a6a6a26 /Objects | |
parent | fed294c6453527addd1644633849e2d8492058c5 (diff) | |
download | cpython-fdee7b7b3e15931d58f07e5449de2e55b4d48b05.zip cpython-fdee7b7b3e15931d58f07e5449de2e55b4d48b05.tar.gz cpython-fdee7b7b3e15931d58f07e5449de2e55b4d48b05.tar.bz2 |
gh-112532: Require mimalloc in `--disable-gil` builds (gh-112883)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/obmalloc.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index b737c03..99c95d9 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -16,6 +16,10 @@ # include "mimalloc/internal.h" // for stats #endif +#if defined(Py_GIL_DISABLED) && !defined(WITH_MIMALLOC) +# error "Py_GIL_DISABLED requires WITH_MIMALLOC" +#endif + #undef uint #define uint pymem_uint @@ -153,7 +157,12 @@ void* _PyObject_Realloc(void *ctx, void *ptr, size_t size); # define PYMALLOC_ALLOC {NULL, _PyObject_Malloc, _PyObject_Calloc, _PyObject_Realloc, _PyObject_Free} #endif // WITH_PYMALLOC -#if defined(WITH_PYMALLOC) +#if defined(Py_GIL_DISABLED) +// Py_GIL_DISABLED requires using mimalloc for "mem" and "obj" domains. +# define PYRAW_ALLOC MALLOC_ALLOC +# define PYMEM_ALLOC MIMALLOC_ALLOC +# define PYOBJ_ALLOC MIMALLOC_OBJALLOC +#elif defined(WITH_PYMALLOC) # define PYRAW_ALLOC MALLOC_ALLOC # define PYMEM_ALLOC PYMALLOC_ALLOC # define PYOBJ_ALLOC PYMALLOC_ALLOC @@ -350,7 +359,7 @@ _PyMem_GetAllocatorName(const char *name, PyMemAllocatorName *allocator) else if (strcmp(name, "debug") == 0) { *allocator = PYMEM_ALLOCATOR_DEBUG; } -#ifdef WITH_PYMALLOC +#if defined(WITH_PYMALLOC) && !defined(Py_GIL_DISABLED) else if (strcmp(name, "pymalloc") == 0) { *allocator = PYMEM_ALLOCATOR_PYMALLOC; } @@ -366,12 +375,14 @@ _PyMem_GetAllocatorName(const char *name, PyMemAllocatorName *allocator) *allocator = PYMEM_ALLOCATOR_MIMALLOC_DEBUG; } #endif +#ifndef Py_GIL_DISABLED else if (strcmp(name, "malloc") == 0) { *allocator = PYMEM_ALLOCATOR_MALLOC; } else if (strcmp(name, "malloc_debug") == 0) { *allocator = PYMEM_ALLOCATOR_MALLOC_DEBUG; } +#endif else { /* unknown allocator */ return -1; |