mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-02-14 00:00:27 +00:00
Merge pull request #355 from ggtakec/master
Fixed codes about clock_gettime for osx
This commit is contained in:
commit
1c9d7a9ea9
@ -228,6 +228,9 @@ dnl ----------------------------------------------
|
||||
dnl malloc_trim function
|
||||
AC_CHECK_FUNCS([malloc_trim])
|
||||
|
||||
dnl clock_gettime function(osx)
|
||||
AC_CHECK_FUNCS([clock_gettime])
|
||||
|
||||
dnl ----------------------------------------------
|
||||
dnl check symbols/macros/enums
|
||||
dnl ----------------------------------------------
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef HAVE_CLOCK_GETTIME
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
@ -43,6 +46,23 @@ using namespace std;
|
||||
//-------------------------------------------------------------------
|
||||
// Utility
|
||||
//-------------------------------------------------------------------
|
||||
#if defined(CLOCK_MONOTONIC_COARSE)
|
||||
#define CLOCK_MONOTONIC_COARSE 6
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CLOCK_GETTIME
|
||||
static int clock_gettime(int clk_id, struct timespec* ts)
|
||||
{
|
||||
struct timeval now;
|
||||
if(0 != gettimeofday(&now, NULL)){
|
||||
return -1;
|
||||
}
|
||||
ts->tv_sec = now.tv_sec;
|
||||
ts->tv_nsec = now.tv_usec * 1000;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void SetStatCacheTime(struct timespec& ts)
|
||||
{
|
||||
if(-1 == clock_gettime(CLOCK_MONOTONIC_COARSE, &ts)){
|
||||
|
Loading…
x
Reference in New Issue
Block a user