v29.4-roots.3 · Commit 2: [PATCH 02/30] 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. The two line-number columns refer to before and after.
src/common/system.cpp
CHANGED
|
@@ -13,26 +13,29 @@
|
|
|
13
13
|
|
|
14
14
|
#ifndef WIN32
|
|
15
15
|
#include <sys/stat.h>
|
|
16
|
+
#include <unistd.h>
|
|
16
17
|
#else
|
|
17
18
|
#include <compat/compat.h>
|
|
18
19
|
#include <codecvt>
|
|
20
|
+
#include <windows.h>
|
|
19
21
|
#endif
|
|
20
22
|
|
|
21
23
|
#ifdef HAVE_MALLOPT_ARENA_MAX
|
|
22
24
|
#include <malloc.h>
|
|
23
25
|
#endif
|
|
24
26
|
|
|
27
|
+
#include <algorithm>
|
|
28
|
+
#include <cstddef>
|
|
29
|
+
#include <cstdint>
|
|
25
30
|
#include <cstdlib>
|
|
26
31
|
#include <locale>
|
|
32
|
+
#include <optional>
|
|
27
33
|
#include <stdexcept>
|
|
28
34
|
#include <string>
|
|
29
35
|
#include <thread>
|
|
30
36
|
|
|
31
37
|
using util::ReplaceAll;
|
|
32
38
|
|
|
33
|
-
// Application startup time (used for uptime calculation)
|
|
34
|
-
const int64_t nStartupTime = GetTime();
|
|
35
|
-
|
|
36
39
|
#ifndef WIN32
|
|
37
40
|
std::string ShellEscape(const std::string& arg)
|
|
38
41
|
{
|
|
@@ -51,8 +54,9 @@ void runCommand(const std::string& strCommand)
|
|
|
51
54
|
#else
|
|
52
55
|
int nErr = ::_wsystem(std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().from_bytes(strCommand).c_str());
|
|
53
56
|
#endif
|
|
54
|
-
if (nErr)
|
|
55
|
-
LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr);
|
|
57
|
+
if (nErr) {
|
|
58
|
+
LogWarning("runCommand error: system(%s) returned %d", strCommand, nErr);
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
#endif
|
|
58
62
|
|
|
@@ -105,8 +109,8 @@ int GetNumCores()
|
|
|
105
109
|
return std::thread::hardware_concurrency();
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
// Obtain the application startup time (used for uptime calculation)
|
|
109
|
-
int64_t GetStartupTime()
|
|
110
|
-
{
|
|
111
|
-
return nStartupTime;
|
|
112
|
-
}
|
|
112
|
+
namespace {
|
|
113
|
+
const auto g_startup_time{SteadyClock::now()};
|
|
114
|
+
} // namespace
|
|
115
|
+
|
|
116
|
+
SteadyClock::duration GetUptime() { return SteadyClock::now() - g_startup_time; }
|