workaround for ftime usage under mingw, still needed as long no compatible solution is found

This commit is contained in:
dwarning 2024-10-18 19:55:19 +02:00
parent 567cea1d86
commit 2e6a1f4dfb
3 changed files with 22 additions and 10 deletions

View File

@ -908,7 +908,18 @@ AC_STRUCT_TM
AC_STRUCT_TIMEZONE
AC_CHECK_FUNCS([localtime])
AC_CHECK_FUNCS([gettimeofday times ftime])
case $host_os in
*mingw* | *msys* )
AC_CHECK_FUNCS([gettimeofday times])
AC_CHECK_LIB([msvcr100], [ftime],
[AC_DEFINE([HAVE_FTIME], [1], [Have ftime routines in libmsvcr100])
LIBS="$LIBS -lmsvcr100"])
;;
*)
AC_CHECK_FUNCS([gettimeofday times ftime])
;;
esac
# Do not use time or getrusage function for CPU time measurement under OpenMP
if test "x$enable_openmp" = xno; then
AC_CHECK_FUNCS([time getrusage])

View File

@ -182,14 +182,15 @@ printres(char *name)
total_msec = ((x % hz) * 1000) / hz;
cpu_elapsed = "CPU";
# else
# ifdef HAVE_FTIME
struct timeb timenow;
ftime(&timenow);
timediff(&timenow, &timebegin, &total_sec, &total_msec);
cpu_elapsed = "elapsed";
# else
# ifdef HAVE_FTIME
struct timeb timenow;
struct timeb ftimezero;
ftime(&timenow);
timediff(&timenow, &ftimezero, &total_sec, &total_msec);
cpu_elapsed = "elapsed";
# else
# define NO_RUDATA
# endif
# endif
# endif
# endif

View File

@ -80,9 +80,9 @@ void timebegin(void) {
}
#else
#ifdef HAVE_FTIME
struct timeb timezero;
struct timeb ftimezero;
void timebegin(void) {
ftime(&timezero);
ftime(&ftimezero);
}
#endif /* FTIME */
#endif /* TIMES */