13 #if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
15 #include <pthread_np.h>
25 #ifdef HAVE_MALLOPT_ARENA_MAX
41 std::string escaped = arg;
43 return "'" + escaped +
"'";
48 void runCommand(
const std::string& strCommand)
50 if (strCommand.empty())
return;
52 int nErr = ::system(strCommand.c_str());
54 int nErr = ::_wsystem(std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,
wchar_t>().from_bytes(strCommand).c_str());
57 LogPrintf(
"runCommand error: system(%s) returned %d\n", strCommand, nErr);
63 #ifdef HAVE_MALLOPT_ARENA_MAX
69 if (
sizeof(
void*) == 4) {
70 mallopt(M_ARENA_MAX, 1);
75 #if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
78 }
catch (
const std::runtime_error&) {
79 setenv(
"LC_ALL",
"C.UTF-8", 1);
83 SetConsoleCP(CP_UTF8);
84 SetConsoleOutputCP(CP_UTF8);
88 constexpr mode_t private_umask = 0077;
98 int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
99 if (
ret != NO_ERROR || LOBYTE(wsadata.wVersion ) != 2 || HIBYTE(wsadata.wVersion) != 2)
107 return std::thread::hardware_concurrency();
119 const static sched_param param{};
120 const int rc = pthread_setschedparam(pthread_self(), SCHED_BATCH, ¶m);
std::string SysErrorString(int err)
Return system error string from errno value.
void ReplaceAll(std::string &in_out, const std::string &search, const std::string &substitute)
void ScheduleBatchPriority()
On platforms that support it, tell the kernel the calling thread is CPU-intensive and non-interactive...
const int64_t nStartupTime
int GetNumCores()
Return the number of cores available on the current system.
std::string ShellEscape(const std::string &arg)