Changeset View
Changeset View
Standalone View
Standalone View
src/util.cpp
Show All 38 Lines | |||||
#endif | #endif | ||||
#define _POSIX_C_SOURCE 200112L | #define _POSIX_C_SOURCE 200112L | ||||
#endif // __linux__ | #endif // __linux__ | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <sched.h> | |||||
#include <sys/resource.h> | #include <sys/resource.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#else | #else | ||||
#ifdef _MSC_VER | #ifdef _MSC_VER | ||||
#pragma warning(disable : 4786) | #pragma warning(disable : 4786) | ||||
#pragma warning(disable : 4804) | #pragma warning(disable : 4804) | ||||
▲ Show 20 Lines • Show All 1,251 Lines • ▼ Show 20 Lines | |||||
// Obtain the application startup time (used for uptime calculation) | // Obtain the application startup time (used for uptime calculation) | ||||
int64_t GetStartupTime() { | int64_t GetStartupTime() { | ||||
return nStartupTime; | return nStartupTime; | ||||
} | } | ||||
fs::path AbsPathForConfigVal(const fs::path &path, bool net_specific) { | fs::path AbsPathForConfigVal(const fs::path &path, bool net_specific) { | ||||
return fs::absolute(path, GetDataDir(net_specific)); | return fs::absolute(path, GetDataDir(net_specific)); | ||||
} | } | ||||
int ScheduleBatchPriority() { | |||||
#ifdef SCHED_BATCH | |||||
const static sched_param param{.sched_priority = 0}; | |||||
if (int ret = pthread_setschedparam(0, SCHED_BATCH, ¶m)) { | |||||
LogPrintf("Failed to pthread_setschedparam: %s\n", strerror(errno)); | |||||
return ret; | |||||
} | |||||
return 0; | |||||
#else | |||||
return 1; | |||||
#endif | |||||
} |