aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/internal/generic/global-config.cpp
blob: 264a984f5e9486f152a828a9920019df87cd8f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdlib.h>
#include <string.h>
#include <mlibc/global-config.hpp>

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");
}

}