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
This commit is contained in:
Francois-Xavier Coudert 2005-09-24 10:39:35 +02:00 committed by François-Xavier Coudert
parent 46919f9ce3
commit 399a39c720
2 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -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);