summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2025-05-11 14:47:02 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-05-22 18:32:10 +0900
commitc239069d07c860e5b01ca139cf322b7535405686 (patch)
tree7698ca33dc48c4f2527958bb7d28c974f91fd219
parent395e5de8d47fe61da470c45bc20be7bfe66e07c0 (diff)
Fix redefinition of `clock_gettime` and `clock_getres`
winpthreads-git 12.0.0.r720 provides `clock_gettime` and `clock_getres` as inline functions.
-rw-r--r--include/ruby/win32.h7
-rw-r--r--win32/win32.c4
2 files changed, 11 insertions, 0 deletions
diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index 197eb8a802..18de3a17d8 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -125,8 +125,15 @@ typedef unsigned int uintptr_t;
#define O_SHARE_DELETE 0x20000000 /* for rb_w32_open(), rb_w32_wopen() */
typedef int clockid_t;
+#if defined(__MINGW32__)
+#undef CLOCK_PROCESS_CPUTIME_ID
+#undef CLOCK_THREAD_CPUTIME_ID
+#undef CLOCK_REALTIME_COARSE
+#endif
+#if defined(HAVE_CLOCK_GETTIME) && !defined(CLOCK_REALTIME)
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 1
+#endif
#undef utime
#undef lseek
diff --git a/win32/win32.c b/win32/win32.c
index e1741c0522..89d221550a 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4806,6 +4806,7 @@ gettimeofday(struct timeval *tv, struct timezone *tz)
return 0;
}
+#if !defined(__MINGW32__) || !defined(HAVE_CLOCK_GETTIME)
/* License: Ruby's */
int
clock_gettime(clockid_t clock_id, struct timespec *sp)
@@ -4845,7 +4846,9 @@ clock_gettime(clockid_t clock_id, struct timespec *sp)
return -1;
}
}
+#endif
+#if !defined(__MINGW32__) || !defined(HAVE_CLOCK_GETRES)
/* License: Ruby's */
int
clock_getres(clockid_t clock_id, struct timespec *sp)
@@ -4873,6 +4876,7 @@ clock_getres(clockid_t clock_id, struct timespec *sp)
return -1;
}
}
+#endif
/* License: Ruby's */
static char *