| 877 | } |
| 878 | |
| 879 | void SetupEnvironment() |
| 880 | { |
| 881 | // On most POSIX systems (e.g. Linux, but not BSD) the environment's locale |
| 882 | // may be invalid, in which case the "C" locale is used as fallback. |
| 883 | #if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) |
| 884 | try { |
| 885 | std::locale(""); // Raises a runtime error if current locale is invalid |
| 886 | } catch (const std::runtime_error&) { |
| 887 | setenv("LC_ALL", "C", 1); |
| 888 | } |
| 889 | #endif |
| 890 | // The path locale is lazy initialized and to avoid deinitialization errors |
| 891 | // in multithreading environments, it is set explicitly by the main thread. |
| 892 | // A dummy locale is used to extract the internal default locale, used by |
| 893 | // boost::filesystem::path, which is then used to explicitly imbue the path. |
| 894 | std::locale loc = boost::filesystem::path::imbue(std::locale::classic()); |
| 895 | boost::filesystem::path::imbue(loc); |
| 896 | } |
| 897 | |
| 898 | void SetThreadPriority(int nPriority) |
| 899 | { |