14 #ifndef LLVM_LIB_SUPPORT_UNIX_UNIX_H 15 #define LLVM_LIB_SUPPORT_UNIX_UNIX_H 22 #include "llvm/Config/config.h" 32 #include <sys/types.h> 39 #ifdef HAVE_SYS_PARAM_H 40 #include <sys/param.h> 43 #ifdef HAVE_SYS_TIME_H 44 # include <sys/time.h> 64 std::string* ErrMsg,
const std::string& prefix,
int errnum = -1) {
78 inline std::chrono::microseconds
toDuration(
const struct timeval &TV) {
79 return std::chrono::seconds(TV.tv_sec) +
80 std::chrono::microseconds(TV.tv_usec);
85 using namespace std::chrono;
87 struct timespec RetVal;
89 RetVal.tv_nsec = (TP.time_since_epoch() % seconds(1)).
count();
95 using namespace std::chrono;
97 struct timeval RetVal;
99 RetVal.tv_usec = (TP.time_since_epoch() % seconds(1)).
count();
LLVM_ATTRIBUTE_ALWAYS_INLINE std::time_t toTimeT(TimePoint<> TP)
Convert a TimePoint to std::time_t.
This class represents lattice values for constants.
struct timespec toTimeSpec(TimePoint<> TP)
Convert a time point to struct timespec.
std::string StrError()
Returns a string representation of the errno value, using whatever thread-safe variant of strerror() ...
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
struct timeval toTimeVal(TimePoint< std::chrono::microseconds > TP)
Convert a time point to struct timeval.
std::chrono::microseconds toDuration(const struct timeval &TV)
Convert a struct timeval to a duration.
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...
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.