v29.4-roots.1 · Commit 2: [PATCH 02/13] runtime: preserve shared operator controls
src/common/system.cpp
Before: src/common/system.cpp · After: src/common/system.cpp
File metadata
index 7af792db44c355c0cff903fa59f486c8d41f94ed..0e74e45c99ef4507b957a2e985636d2c2ad71771 100644
Download original patch · Release notes
Diff rows 1–56 of 56. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/common/system.cpp
CHANGED
|
@@ -13,26 +13,29 @@
|
|
| 13 |
|
| 14 |
#ifndef WIN32
|
| 15 |
#include <sys/stat.h>
|
|
|
|
| 16 |
#else
|
| 17 |
#include <compat/compat.h>
|
| 18 |
#include <codecvt>
|
|
|
|
| 19 |
#endif
|
| 20 |
|
| 21 |
#ifdef HAVE_MALLOPT_ARENA_MAX
|
| 22 |
#include <malloc.h>
|
| 23 |
#endif
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
#include <cstdlib>
|
| 26 |
#include <locale>
|
|
|
|
| 27 |
#include <stdexcept>
|
| 28 |
#include <string>
|
| 29 |
#include <thread>
|
| 30 |
|
| 31 |
using util::ReplaceAll;
|
| 32 |
|
| 33 |
-
// Application startup time (used for uptime calculation)
|
| 34 |
-
const int64_t nStartupTime = GetTime();
|
| 35 |
-
|
| 36 |
#ifndef WIN32
|
| 37 |
std::string ShellEscape(const std::string& arg)
|
| 38 |
{
|
|
@@ -51,8 +54,9 @@ void runCommand(const std::string& strCommand)
|
|
| 51 |
#else
|
| 52 |
int nErr = ::_wsystem(std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().from_bytes(strCommand).c_str());
|
| 53 |
#endif
|
| 54 |
-
if (nErr)
|
| 55 |
-
LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr);
|
|
|
|
| 56 |
}
|
| 57 |
#endif
|
| 58 |
|
|
@@ -105,8 +109,8 @@ int GetNumCores()
|
|
| 105 |
return std::thread::hardware_concurrency();
|
| 106 |
}
|
| 107 |
|
| 108 |
-
// Obtain the application startup time (used for uptime calculation)
|
| 109 |
-
int64_t GetStartupTime()
|
| 110 |
-
{
|
| 111 |
-
return nStartupTime;
|
| 112 |
-
}
|
|
|
|
| 13 |
|
| 14 |
#ifndef WIN32
|
| 15 |
#include <sys/stat.h>
|
| 16 |
+
#include <unistd.h>
|
| 17 |
#else
|
| 18 |
#include <compat/compat.h>
|
| 19 |
#include <codecvt>
|
| 20 |
+
#include <windows.h>
|
| 21 |
#endif
|
| 22 |
|
| 23 |
#ifdef HAVE_MALLOPT_ARENA_MAX
|
| 24 |
#include <malloc.h>
|
| 25 |
#endif
|
| 26 |
|
| 27 |
+
#include <algorithm>
|
| 28 |
+
#include <cstddef>
|
| 29 |
+
#include <cstdint>
|
| 30 |
#include <cstdlib>
|
| 31 |
#include <locale>
|
| 32 |
+
#include <optional>
|
| 33 |
#include <stdexcept>
|
| 34 |
#include <string>
|
| 35 |
#include <thread>
|
| 36 |
|
| 37 |
using util::ReplaceAll;
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
#ifndef WIN32
|
| 40 |
std::string ShellEscape(const std::string& arg)
|
| 41 |
{
|
|
|
|
| 54 |
#else
|
| 55 |
int nErr = ::_wsystem(std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().from_bytes(strCommand).c_str());
|
| 56 |
#endif
|
| 57 |
+
if (nErr) {
|
| 58 |
+
LogWarning("runCommand error: system(%s) returned %d", strCommand, nErr);
|
| 59 |
+
}
|
| 60 |
}
|
| 61 |
#endif
|
| 62 |
|
|
|
|
| 109 |
return std::thread::hardware_concurrency();
|
| 110 |
}
|
| 111 |
|
| 112 |
+
namespace {
|
| 113 |
+
const auto g_startup_time{SteadyClock::now()};
|
| 114 |
+
} // namespace
|
| 115 |
+
|
| 116 |
+
SteadyClock::duration GetUptime() { return SteadyClock::now() - g_startup_time; }
|