diff --git a/CMakeLists.txt b/CMakeLists.txt index 3db4d7d..34f6e53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,9 +177,7 @@ if(USE_POSIX_COMMIT_CHECKS) endif() if(SNMALLOC_PLATFORM_HAS_GETENTROPY) - target_compile_definitions(snmalloc_lib INTERFACE -DSNMALLOC_PLATFORM_HAS_GETENTROPY=Entropy) -else() - target_compile_definitions(snmalloc_lib INTERFACE -DSNMALLOC_PLATFORM_HAS_GETENTROPY=0) + target_compile_definitions(snmalloc_lib INTERFACE -DSNMALLOC_PLATFORM_HAS_GETENTROPY) endif() if(CONST_QUALIFIED_MALLOC_USABLE_SIZE) diff --git a/src/pal/pal_posix.h b/src/pal/pal_posix.h index fbb037e..9622ec8 100644 --- a/src/pal/pal_posix.h +++ b/src/pal/pal_posix.h @@ -19,12 +19,6 @@ # include #endif -// default value for builds not using CMake -#ifndef SNMALLOC_PLATFORM_HAS_GETENTROPY -# define SNMALLOC_PLATFORM_HAS_GETENTROPY 0 -# warning snmalloc not using entropy source. To silence this warning please define SNMALLOC_PLATFORM_HAS_GETENTROPY to 0, or to Entropy if your platform implements getentropy(). -#endif - extern "C" int puts(const char* str); namespace snmalloc @@ -126,8 +120,11 @@ namespace snmalloc * POSIX systems are assumed to support lazy commit. The build system checks * getentropy is available, only then this PAL supports Entropy. */ - static constexpr uint64_t pal_features = - LazyCommit | SNMALLOC_PLATFORM_HAS_GETENTROPY; + static constexpr uint64_t pal_features = LazyCommit +#if defined(SNMALLOC_PLATFORM_HAS_GETENTROPY) + | Entropy +#endif + ; static constexpr size_t page_size = Aal::smallest_page_size;