summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ctx.c2
-rw-r--r--src/eval.c19
-rw-r--r--src/xtime.c14
-rw-r--r--src/xtime.h10
-rw-r--r--tests/xtouch.c4
5 files changed, 10 insertions, 39 deletions
diff --git a/src/ctx.c b/src/ctx.c
index 8fafb32..b33e0e3 100644
--- a/src/ctx.c
+++ b/src/ctx.c
@@ -71,7 +71,7 @@ struct bfs_ctx *bfs_ctx_new(void) {
goto fail;
}
- if (xgettime(&ctx->now) != 0) {
+ if (clock_gettime(CLOCK_REALTIME, &ctx->now) != 0) {
goto fail;
}
diff --git a/src/eval.c b/src/eval.c
index 7c814ed..8ec6908 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1014,25 +1014,20 @@ bool eval_xtype(const struct bfs_expr *expr, struct bfs_eval *state) {
}
}
-#if _POSIX_MONOTONIC_CLOCK > 0
-# define BFS_CLOCK CLOCK_MONOTONIC
-#elif _POSIX_TIMERS > 0
-# define BFS_CLOCK CLOCK_REALTIME
-#endif
-
/**
- * Call clock_gettime(), if available.
+ * clock_gettime() wrapper.
*/
static int eval_gettime(struct bfs_eval *state, struct timespec *ts) {
-#ifdef BFS_CLOCK
- int ret = clock_gettime(BFS_CLOCK, ts);
+#if _POSIX_MONOTONIC_CLOCK > 0
+ int ret = clock_gettime(CLOCK_MONOTONIC, ts);
+#else
+ int ret = clock_gettime(CLOCK_REALTIME, ts);
+#endif
+
if (ret != 0) {
bfs_warning(state->ctx, "%pP: clock_gettime(): %s.\n", state->ftwbuf, errstr());
}
return ret;
-#else
- return -1;
-#endif
}
/**
diff --git a/src/xtime.c b/src/xtime.c
index 186651b..df8fd61 100644
--- a/src/xtime.c
+++ b/src/xtime.c
@@ -350,17 +350,3 @@ invalid:
error:
return -1;
}
-
-int xgettime(struct timespec *result) {
-#if _POSIX_TIMERS > 0
- return clock_gettime(CLOCK_REALTIME, result);
-#else
- struct timeval tv;
- int ret = gettimeofday(&tv, NULL);
- if (ret == 0) {
- result->tv_sec = tv.tv_sec;
- result->tv_nsec = tv.tv_usec * 1000L;
- }
- return ret;
-#endif
-}
diff --git a/src/xtime.h b/src/xtime.h
index fb60ae4..a3547a7 100644
--- a/src/xtime.h
+++ b/src/xtime.h
@@ -46,14 +46,4 @@ int xtimegm(struct tm *tm, time_t *timep);
*/
int xgetdate(const char *str, struct timespec *result);
-/**
- * Get the current time.
- *
- * @param[out] result
- * A pointer to the result.
- * @return
- * 0 on success, -1 on failure.
- */
-int xgettime(struct timespec *result);
-
#endif // BFS_XTIME_H
diff --git a/tests/xtouch.c b/tests/xtouch.c
index 427e3e0..8660ea5 100644
--- a/tests/xtouch.c
+++ b/tests/xtouch.c
@@ -247,8 +247,8 @@ int main(int argc, char *argv[]) {
times[1] = times[0];
} else {
// Don't use UTIME_NOW, so that multiple paths all get the same timestamp
- if (xgettime(&times[0]) != 0) {
- perror("xgettime()");
+ if (clock_gettime(CLOCK_REALTIME, &times[0]) != 0) {
+ perror("clock_gettime()");
return EXIT_FAILURE;
}
times[1] = times[0];