mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-23 13:58:24 +00:00
Always call clock_gettime(2) (#1871)
e01ded9e27f41af45e8614860b29164d13c0101e introduced this compatibility shim but macOS 10.12 (2016) added this: https://stackoverflow.com/a/39801564 . Also remove fallback to time(3) which loses precision.
This commit is contained in:
parent
de0c87c801
commit
662882d2f0
@ -68,7 +68,7 @@ Many systems provide pre-built packages:
|
|||||||
sudo zypper install s3fs
|
sudo zypper install s3fs
|
||||||
```
|
```
|
||||||
|
|
||||||
* macOS via [Homebrew](https://brew.sh/):
|
* macOS 10.12 and newer via [Homebrew](https://brew.sh/):
|
||||||
|
|
||||||
```
|
```
|
||||||
brew install --cask osxfuse
|
brew install --cask osxfuse
|
||||||
|
@ -18,11 +18,9 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cerrno>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#ifndef HAVE_CLOCK_GETTIME
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -45,29 +43,11 @@
|
|||||||
#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
|
#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CLOCK_GETTIME
|
|
||||||
static int s3fs_clock_gettime(int clk_id, struct timespec* ts)
|
|
||||||
{
|
|
||||||
return clock_gettime(static_cast<clockid_t>(clk_id), ts);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static int s3fs_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)
|
inline void SetStatCacheTime(struct timespec& ts)
|
||||||
{
|
{
|
||||||
if(-1 == s3fs_clock_gettime(CLOCK_MONOTONIC_COARSE, &ts)){
|
if(-1 == clock_gettime(static_cast<clockid_t>(CLOCK_MONOTONIC_COARSE), &ts)){
|
||||||
ts.tv_sec = time(NULL);
|
S3FS_PRN_CRIT("clock_gettime failed: %d", errno);
|
||||||
ts.tv_nsec = 0;
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user