From 5c8164fa9622602e9939387a0a1560fcaee44784 Mon Sep 17 00:00:00 2001 From: Remy Wang Date: Thu, 19 Sep 2024 14:30:45 -0700 Subject: [PATCH] add USE_MALLOC_USEABLE_SIZE option --- CMakeLists.txt | 2 +- src/util/memory_manager.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11a6ec2a4..d35385f80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,7 +213,7 @@ list(APPEND Z3_COMPONENT_EXTRA_INCLUDE_DIRS option(Z3_USE_MALLOC_USABLE_SIZE "Use malloc_usable_size (or equivalents like malloc_size or _msize)" ON) if (Z3_USE_MALLOC_USABLE_SIZE) message(STATUS "Using malloc_usable_size") - list(APPEND Z3_COMPONENT_CXX_DEFINES "-DHAS_MALLOC_USABLE_SIZE") + list(APPEND Z3_COMPONENT_CXX_DEFINES "-DUSE_MALLOC_USABLE_SIZE") else() message(STATUS "Not using malloc_usable_size") endif() diff --git a/src/util/memory_manager.cpp b/src/util/memory_manager.cpp index ac2e402f8..1ad062aa3 100644 --- a/src/util/memory_manager.cpp +++ b/src/util/memory_manager.cpp @@ -13,17 +13,21 @@ Copyright (c) 2015 Microsoft Corporation #include "util/error_codes.h" #include "util/debug.h" #include "util/scoped_timer.h" -#ifndef HAS_MALLOC_USABLE_SIZE +#ifndef USE_MALLOC_USABLE_SIZE // drop calls to malloc_usable_size #elif defined(__GLIBC__) # include +# define HAS_MALLOC_USABLE_SIZE #elif defined(__APPLE__) # include +# define HAS_MALLOC_USABLE_SIZE # define malloc_usable_size malloc_size #elif defined(__FreeBSD__) # include +# define HAS_MALLOC_USABLE_SIZE #elif defined(_WINDOWS) # include +# define HAS_MALLOC_USABLE_SIZE # define malloc_usable_size _msize #endif