Since Mac OS X doesn't support clock_gettime, implement it if running on Mac.
This commit is contained in:
parent
f749ad66f1
commit
098f16a4fe
24
src/cpp-utils/system/clock_gettime.h
Normal file
24
src/cpp-utils/system/clock_gettime.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#ifndef MESSMER_CPPUTILS_SYSTEM_CLOCKGETTIME_H
|
||||
#define MESSMER_CPPUTILS_SYSTEM_CLOCKGETTIME_H
|
||||
|
||||
// Implements clock_gettime for Mac OS X (where it is not implemented by in the standard library)
|
||||
// Source: http://stackoverflow.com/a/9781275/829568
|
||||
// Caution: The returned value is less precise than the returned value from a linux clock_gettime would be.
|
||||
|
||||
#ifdef __MACH__
|
||||
#include <sys/time.h>
|
||||
#define CLOCK_REALTIME 0
|
||||
int clock_gettime(int /*clk_id*/, struct timespec *result) {
|
||||
struct timeval now;
|
||||
int rv = gettimeofday(&now, nullptr);
|
||||
if (rv) {
|
||||
return rv;
|
||||
}
|
||||
result->tv_sec = now.tv_sec;
|
||||
result->tv_nsec = now.tv_sec * 1000;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
#include "DirEntryList.h"
|
||||
#include <limits>
|
||||
#include <cpp-utils/system/clock_gettime.h>
|
||||
|
||||
//TODO Get rid of that in favor of better error handling
|
||||
#include <fspp/fuse/FuseErrnoException.h>
|
||||
|
Loading…
Reference in New Issue
Block a user