Skip to content

Commit 3e47e7a

Browse files
committed
Fix redefinition of clock_gettime and clock_getres
winpthreads-git 12.0.0.r720 provides `clock_gettime` and `clock_getres` as inline functions.
1 parent f2e5f6d commit 3e47e7a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/ruby/win32.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,15 @@ typedef unsigned int uintptr_t;
126126
#define O_SHARE_DELETE 0x20000000 /* for rb_w32_open(), rb_w32_wopen() */
127127

128128
typedef int clockid_t;
129+
#if defined(__MINGW32__)
130+
#undef CLOCK_PROCESS_CPUTIME_ID
131+
#undef CLOCK_THREAD_CPUTIME_ID
132+
#undef CLOCK_REALTIME_COARSE
133+
#endif
134+
#if defined(HAVE_CLOCK_GETTIME) && !defined(CLOCK_REALTIME)
129135
#define CLOCK_REALTIME 0
130136
#define CLOCK_MONOTONIC 1
137+
#endif
131138

132139
#undef utime
133140
#undef lseek

win32/win32.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4761,6 +4761,7 @@ gettimeofday(struct timeval *tv, struct timezone *tz)
47614761
return 0;
47624762
}
47634763

4764+
#if !defined(__MINGW32__) || !defined(HAVE_CLOCK_GETTIME)
47644765
/* License: Ruby's */
47654766
int
47664767
clock_gettime(clockid_t clock_id, struct timespec *sp)
@@ -4800,7 +4801,9 @@ clock_gettime(clockid_t clock_id, struct timespec *sp)
48004801
return -1;
48014802
}
48024803
}
4804+
#endif
48034805

4806+
#if !defined(__MINGW32__) || !defined(HAVE_CLOCK_GETRES)
48044807
/* License: Ruby's */
48054808
int
48064809
clock_getres(clockid_t clock_id, struct timespec *sp)
@@ -4828,6 +4831,7 @@ clock_getres(clockid_t clock_id, struct timespec *sp)
48284831
return -1;
48294832
}
48304833
}
4834+
#endif
48314835

48324836
/* License: Ruby's */
48334837
static char *

0 commit comments

Comments
 (0)