13#ifndef LLVM_LIB_SUPPORT_UNIX_UNIX_H
14#define LLVM_LIB_SUPPORT_UNIX_UNIX_H
21#include "llvm/Config/config.h"
32#include <sys/resource.h>
55 std::string* ErrMsg,
const std::string& prefix,
int errnum = -1) {
76inline std::chrono::microseconds
toDuration(
const struct timeval &TV) {
77 return std::chrono::seconds(TV.tv_sec) +
78 std::chrono::microseconds(TV.tv_usec);
83 std::chrono::microseconds UserT =
toDuration(RU.ru_utime);
84 std::chrono::microseconds KernelT =
toDuration(RU.ru_stime);
86#if !defined(__HAIKU__) && !defined(__MVS__)
87 PeakMemory =
static_cast<uint64_t>(RU.ru_maxrss);
97 using namespace std::chrono;
99 struct timespec RetVal;
101 RetVal.tv_nsec = (TP.time_since_epoch() % seconds(1)).count();
107 using namespace std::chrono;
109 struct timeval RetVal;
111 RetVal.tv_usec = (TP.time_since_epoch() % seconds(1)).count();
static bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix, int errnum=-1)
This function builds an error message into ErrMsg using the prefix string and the Unix error number g...
static void ReportErrnumFatal(const char *Msg, int errnum)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::chrono::nanoseconds toDuration(FILETIME Time)
LLVM_ABI std::string StrError()
Returns a string representation of the errno value, using whatever thread-safe variant of strerror() ...
ProcessStatistics toProcessStatistics(const struct rusage &RU)
Convert resource usage of this process or a waited child to statistics.
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.
struct timespec toTimeSpec(TimePoint<> TP)
Convert a time point to struct timespec.
struct timeval toTimeVal(TimePoint< std::chrono::microseconds > TP)
Convert a time point to struct timeval.
std::time_t toTimeT(TimePoint<> TP)
Convert a TimePoint to std::time_t.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Implement std::hash so that hash_code can be used in STL containers.
This struct encapsulates information about a process execution.