From bd5969fc876a10b18613302db7087ef3c40f18e1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:00 -0500 Subject: lib: Add mlibc Signed-off-by: Ian Moffett --- .../options/internal/generic/global-config.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/mlibc/options/internal/generic/global-config.cpp (limited to 'lib/mlibc/options/internal/generic/global-config.cpp') diff --git a/lib/mlibc/options/internal/generic/global-config.cpp b/lib/mlibc/options/internal/generic/global-config.cpp new file mode 100644 index 0000000..264a984 --- /dev/null +++ b/lib/mlibc/options/internal/generic/global-config.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +namespace mlibc { + +struct GlobalConfigGuard { + GlobalConfigGuard(); +}; + +GlobalConfigGuard guard; + +GlobalConfigGuard::GlobalConfigGuard() { + // Force the config to be created during initialization of libc.so. + mlibc::globalConfig(); +} + +static bool envEnabled(const char *env) { + auto value = getenv(env); + return value && *value && *value != '0'; +} + +GlobalConfig::GlobalConfig() { + debugMalloc = envEnabled("MLIBC_DEBUG_MALLOC"); +} + +} -- cgit v1.2.3