|
|
@@ -27,24 +27,15 @@
|
|
|
#define PK_ENABLE_CUSTOM_SNAME 0
|
|
|
#endif
|
|
|
|
|
|
+#ifndef PK_ENABLE_MIMALLOC // can be overridden by cmake
|
|
|
+#define PK_ENABLE_MIMALLOC 0
|
|
|
+#endif
|
|
|
+
|
|
|
// GC min threshold
|
|
|
#ifndef PK_GC_MIN_THRESHOLD // can be overridden by cmake
|
|
|
#define PK_GC_MIN_THRESHOLD 32768
|
|
|
#endif
|
|
|
|
|
|
-// Memory allocation functions
|
|
|
-#ifndef PK_MALLOC
|
|
|
- #ifndef __cplusplus
|
|
|
- #define PK_MALLOC(size) malloc(size)
|
|
|
- #define PK_REALLOC(ptr, size) realloc(ptr, size)
|
|
|
- #define PK_FREE(ptr) free(ptr)
|
|
|
- #else
|
|
|
- #define PK_MALLOC(size) std::malloc(size)
|
|
|
- #define PK_REALLOC(ptr, size) std::realloc(ptr, size)
|
|
|
- #define PK_FREE(ptr) std::free(ptr)
|
|
|
- #endif
|
|
|
-#endif
|
|
|
-
|
|
|
// This is the maximum size of the value stack in py_TValue units
|
|
|
// The actual size in bytes equals `sizeof(py_TValue) * PK_VM_STACK_SIZE`
|
|
|
#ifndef PK_VM_STACK_SIZE // can be overridden by cmake
|
|
|
@@ -90,3 +81,25 @@
|
|
|
#else
|
|
|
#define PK_THREAD_LOCAL
|
|
|
#endif
|
|
|
+
|
|
|
+// Memory allocation functions
|
|
|
+#ifndef PK_MALLOC
|
|
|
+ #if PK_ENABLE_MIMALLOC
|
|
|
+ #include <mimalloc.h>
|
|
|
+ #define PK_MALLOC(size) mi_malloc(size)
|
|
|
+ #define PK_REALLOC(ptr, size) mi_realloc(ptr, size)
|
|
|
+ #define PK_FREE(ptr) mi_free(ptr)
|
|
|
+ #else
|
|
|
+ #ifndef __cplusplus
|
|
|
+ #include <stdlib.h>
|
|
|
+ #define PK_MALLOC(size) malloc(size)
|
|
|
+ #define PK_REALLOC(ptr, size) realloc(ptr, size)
|
|
|
+ #define PK_FREE(ptr) free(ptr)
|
|
|
+ #else
|
|
|
+ #include <cstdlib>
|
|
|
+ #define PK_MALLOC(size) std::malloc(size)
|
|
|
+ #define PK_REALLOC(ptr, size) std::realloc(ptr, size)
|
|
|
+ #define PK_FREE(ptr) std::free(ptr)
|
|
|
+ #endif
|
|
|
+ #endif
|
|
|
+#endif
|