Fix for old mingw without clock_gettime and clock_getres

This commit is contained in:
Nobuyoshi Nakada 2025-05-22 11:28:26 +09:00 committed by Nobuyoshi Nakada
parent 0564973196
commit ec41b1e823
Notes: git 2025-05-22 04:08:53 +00:00
2 changed files with 18 additions and 5 deletions

View File

@ -127,13 +127,26 @@ typedef unsigned int uintptr_t;
typedef int clockid_t; typedef int clockid_t;
#if defined(__MINGW32__) #if defined(__MINGW32__)
/* I don't know why but these return some strange values. */
#undef CLOCK_PROCESS_CPUTIME_ID #undef CLOCK_PROCESS_CPUTIME_ID
#undef CLOCK_THREAD_CPUTIME_ID #undef CLOCK_THREAD_CPUTIME_ID
#undef CLOCK_REALTIME_COARSE #undef CLOCK_REALTIME_COARSE
#endif #endif
#if defined(HAVE_CLOCK_GETTIME) && !defined(CLOCK_REALTIME)
#define CLOCK_REALTIME 0 /* defined in win32/win32.c for old versions */
#define CLOCK_MONOTONIC 1 #if !defined(__MINGW32__) || !defined(HAVE_CLOCK_GETTIME)
# define HAVE_CLOCK_GETTIME 1
# define NEED_CLOCK_GETTIME 1
#endif
#if !defined(__MINGW32__) || !defined(HAVE_CLOCK_GETRES)
# define HAVE_CLOCK_GETRES 1
# define NEED_CLOCK_GETRES 1
#endif
#ifndef CLOCK_REALTIME
# define CLOCK_REALTIME 0
#endif
#ifndef CLOCK_MONOTONIC
# define CLOCK_MONOTONIC 1
#endif #endif
#undef utime #undef utime

View File

@ -4761,7 +4761,7 @@ gettimeofday(struct timeval *tv, struct timezone *tz)
return 0; return 0;
} }
#if !defined(__MINGW32__) || !defined(HAVE_CLOCK_GETTIME) #ifdef NEED_CLOCK_GETTIME
/* License: Ruby's */ /* License: Ruby's */
int int
clock_gettime(clockid_t clock_id, struct timespec *sp) clock_gettime(clockid_t clock_id, struct timespec *sp)
@ -4803,7 +4803,7 @@ clock_gettime(clockid_t clock_id, struct timespec *sp)
} }
#endif #endif
#if !defined(__MINGW32__) || !defined(HAVE_CLOCK_GETRES) #ifdef NEED_CLOCK_GETRES
/* License: Ruby's */ /* License: Ruby's */
int int
clock_getres(clockid_t clock_id, struct timespec *sp) clock_getres(clockid_t clock_id, struct timespec *sp)