diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile.sub | 1 | ||||
-rw-r--r-- | win32/win32.c | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 7d615b643c..f7bfc28dcd 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -642,6 +642,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub #define HAVE_MEMMOVE 1 #define HAVE_MKDIR 1 #define HAVE_CLOCK_GETTIME 1 +#define HAVE_CLOCK_GETRES 1 #define HAVE_SPAWNV 1 #define HAVE_STRCASECMP 1 #define HAVE_STRNCASECMP 1 diff --git a/win32/win32.c b/win32/win32.c index d5bf292cdf..b888e9c9e6 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4346,6 +4346,35 @@ clock_gettime(clockid_t clock_id, struct timespec *sp) } /* License: Ruby's */ +int +clock_getres(clockid_t clock_id, struct timespec *sp) +{ + switch (clock_id) { + case CLOCK_REALTIME: + { + sp->tv_sec = 0; + sp->tv_nsec = 1000; + return 0; + } + case CLOCK_MONOTONIC: + { + LARGE_INTEGER freq; + LARGE_INTEGER count; + if (!QueryPerformanceFrequency(&freq)) { + errno = map_errno(GetLastError()); + return -1; + } + sp->tv_sec = 0; + sp->tv_nsec = (long)(1000000000.0 / freq.QuadPart); + return 0; + } + default: + errno = EINVAL; + return -1; + } +} + +/* License: Ruby's */ char * rb_w32_getcwd(char *buffer, int size) { |