summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-time
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-05-08 10:34:38 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-05-08 10:34:38 +0900
commit033aa98cf46f329e528dd810feab9e052f7dd20f (patch)
tree9cdcbf71f643fbcef475d7cfd3206f9ceae9e5b8 /mrbgems/mruby-time
parentf8345dbc44da4f46f9ef906a255404adff57de33 (diff)
downloadmruby-033aa98cf46f329e528dd810feab9e052f7dd20f.tar.gz
mruby-033aa98cf46f329e528dd810feab9e052f7dd20f.zip
time.c: Windows API provides `clock_gettime`.
`gettimeofday` emulation needed no longer.
Diffstat (limited to 'mrbgems/mruby-time')
-rw-r--r--mrbgems/mruby-time/src/time.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c
index 2a5e9dd6b..299d4d7e1 100644
--- a/mrbgems/mruby-time/src/time.c
+++ b/mrbgems/mruby-time/src/time.c
@@ -85,8 +85,12 @@ double round(double x) {
/** end of Time class configuration */
-#ifndef NO_GETTIMEOFDAY
-# ifdef _WIN32
+#if (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) && defined(CLOCK_REALTIME)
+# define USE_CLOCK_GETTIME
+#endif
+
+#if !defined(NO_GETTIMEOFDAY)
+# if defined(_WIN32) && !defined(USE_CLOCK_GETTIME)
# define WIN32_LEAN_AND_MEAN /* don't include winsock.h */
# include <windows.h>
# define gettimeofday my_gettimeofday
@@ -389,7 +393,7 @@ current_mrb_time(mrb_state *mrb)
sec = ts.tv_sec;
usec = ts.tv_nsec / 1000;
}
-#elif (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) && defined(CLOCK_REALTIME)
+#elif defined(USE_CLOCK_GETTIME)
{
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);