From 399a39c720380bb2c7403a572027e3fd889a8da4 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Sat, 24 Sep 2005 10:39:35 +0200 Subject: [PATCH] re PR libfortran/23380 ([mingw32] cpu_time intrinsic malfunction) PR libfortran/23380 * intrinsics/cpu_time.c (__cpu_time_1): Provide a MS Windows version. From-SVN: r104598 --- libgfortran/ChangeLog | 6 +++++ libgfortran/intrinsics/cpu_time.c | 40 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index bd2b872c857..760d40b84f4 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2005-09-24 Francois-Xavier Coudert + + PR libfortran/23380 + * intrinsics/cpu_time.c (__cpu_time_1): Provide a MS Windows + version. + 2005-09-14 Jerry DeLisle + +static void +__cpu_time_1 (long *sec, long *usec) +{ + union { + FILETIME ft; + unsigned long long ulltime; + } kernel_time, user_time; + + FILETIME unused1, unused2; + unsigned long long total_time; + + /* No support for Win9x. The high order bit of the DWORD + returned by GetVersion is 0 for NT and higher. */ + if (GetVersion () >= 0x80000000) + { + *sec = -1; + *usec = 0; + return; + } + + /* The FILETIME structs filled in by GetProcessTimes represent + time in 100 nanosecond units. */ + GetProcessTimes (GetCurrentProcess (), &unused1, &unused2, + &kernel_time.ft, &user_time.ft); + + total_time = (kernel_time.ulltime + user_time.ulltime)/10; + *sec = total_time / 1000000; + *usec = total_time % 1000000; +} + +#else + static inline void __cpu_time_1 (long *sec, long *usec) { @@ -110,6 +148,8 @@ __cpu_time_1 (long *sec, long *usec) #endif /* HAVE_GETRUSAGE */ } +#endif + extern void cpu_time_4 (GFC_REAL_4 *); iexport_proto(cpu_time_4);