diff options
-rw-r--r-- | libgfortran/ChangeLog | 6 | ||||
-rw-r--r-- | libgfortran/intrinsics/cpu_time.c | 40 |
2 files changed, 46 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index bd2b872..760d40b 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2005-09-24 Francois-Xavier Coudert <coudert@clipper.ens.fr> + + PR libfortran/23380 + * intrinsics/cpu_time.c (__cpu_time_1): Provide a MS Windows + version. + 2005-09-14 Jerry DeLisle <jvdelisle@verizon.net PR fortran/21875 Internal Unit Array I/O, NIST diff --git a/libgfortran/intrinsics/cpu_time.c b/libgfortran/intrinsics/cpu_time.c index 4d9525a..8469a43 100644 --- a/libgfortran/intrinsics/cpu_time.c +++ b/libgfortran/intrinsics/cpu_time.c @@ -88,6 +88,44 @@ static inline void __cpu_time_1 (long *, long *) ATTRIBUTE_ALWAYS_INLINE; /* Helper function for the actual implementation of the CPU_TIME intrnsic. Returns a CPU time in microseconds or -1 if no CPU time could be computed. */ + +#ifdef __MINGW32__ + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +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); |