Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 1,290 Lines • ▼ Show 20 Lines | #ifdef HAVE_MALLOPT_ARENA_MAX | ||||
// arenas per core. This is known to cause excessive virtual address space | // arenas per core. This is known to cause excessive virtual address space | ||||
// usage in our usage. Work around it by setting the maximum number of | // usage in our usage. Work around it by setting the maximum number of | ||||
// arenas to 1. | // arenas to 1. | ||||
if (sizeof(void *) == 4) { | if (sizeof(void *) == 4) { | ||||
mallopt(M_ARENA_MAX, 1); | mallopt(M_ARENA_MAX, 1); | ||||
} | } | ||||
#endif | #endif | ||||
// On most POSIX systems (e.g. Linux, but not BSD) the environment's locale may | // On most POSIX systems (e.g. Linux, but not BSD) the environment's locale may | ||||
// be invalid, in which case the "C" locale is used as fallback. | // be invalid, in which case the "C.UTF-8" locale is used as fallback. | ||||
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && \ | #if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && \ | ||||
!defined(__OpenBSD__) | !defined(__OpenBSD__) | ||||
try { | try { | ||||
// Raises a runtime error if current locale is invalid. | // Raises a runtime error if current locale is invalid. | ||||
std::locale(""); | std::locale(""); | ||||
} catch (const std::runtime_error &) { | } catch (const std::runtime_error &) { | ||||
setenv("LC_ALL", "C", 1); | setenv("LC_ALL", "C.UTF-8", 1); | ||||
} | } | ||||
#elif defined(WIN32) | #elif defined(WIN32) | ||||
// Set the default input/output charset is utf-8 | // Set the default input/output charset is utf-8 | ||||
SetConsoleCP(CP_UTF8); | SetConsoleCP(CP_UTF8); | ||||
SetConsoleOutputCP(CP_UTF8); | SetConsoleOutputCP(CP_UTF8); | ||||
#endif | #endif | ||||
// The path locale is lazy initialized and to avoid deinitialization errors | // The path locale is lazy initialized and to avoid deinitialization errors | ||||
// in multithreading environments, it is set explicitly by the main thread. | // in multithreading environments, it is set explicitly by the main thread. | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |