| 1353 | } |
| 1354 | |
| 1355 | void SetupEnvironment() |
| 1356 | { |
| 1357 | #ifdef HAVE_MALLOPT_ARENA_MAX |
| 1358 | // glibc-specific: On 32-bit systems set the number of arenas to 1. |
| 1359 | // By default, since glibc 2.10, the C library will create up to two heap |
| 1360 | // arenas per core. This is known to cause excessive virtual address space |
| 1361 | // usage in our usage. Work around it by setting the maximum number of |
| 1362 | // arenas to 1. |
| 1363 | if (sizeof(void*) == 4) { |
| 1364 | mallopt(M_ARENA_MAX, 1); |
| 1365 | } |
| 1366 | #endif |
| 1367 | // On most POSIX systems (e.g. Linux, but not BSD) the environment's locale |
| 1368 | // may be invalid, in which case the "C.UTF-8" locale is used as fallback. |
| 1369 | #if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) |
| 1370 | try { |
| 1371 | std::locale(""); // Raises a runtime error if current locale is invalid |
| 1372 | } catch (const std::runtime_error&) { |
| 1373 | setenv("LC_ALL", "C.UTF-8", 1); |
| 1374 | } |
| 1375 | #elif defined(WIN32) |
| 1376 | // Set the default input/output charset is utf-8 |
| 1377 | SetConsoleCP(CP_UTF8); |
| 1378 | SetConsoleOutputCP(CP_UTF8); |
| 1379 | #endif |
| 1380 | } |
| 1381 | |
| 1382 | bool SetupNetworking() |
| 1383 | { |
no outgoing calls