From db006fd45ea62b4ec8d92f6f1d8f6b5706730a7e Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 13:44:25 -0500 Subject: [PATCH 01/14] [runtime/util] implement filetime_to_int64 --- runtime/flang/util.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/runtime/flang/util.c b/runtime/flang/util.c index 7435d0533d2..3bb05f6b1ae 100644 --- a/runtime/flang/util.c +++ b/runtime/flang/util.c @@ -331,3 +331,15 @@ void __fort_ftnstrcpy(char *dst, /* destination string, blank-filled */ *dst++ = ' '; } + +#ifdef _WIN32 +__int64 filetime_to_int64( const FILETIME *ac_FileTime ) +{ + ULARGE_INTEGER lv_Large ; + + lv_Large.LowPart = ac_FileTime->dwLowDateTime ; + lv_Large.HighPart = ac_FileTime->dwHighDateTime ; + + return (__int64)lv_Large.QuadPart ; +} +#endif From b06c71af273c0615fca0819ed333bb9a96ecd61b Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:03:44 -0500 Subject: [PATCH 02/14] [runtime/include] add filetime header --- runtime/include/times_win32.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 runtime/include/times_win32.h diff --git a/runtime/include/times_win32.h b/runtime/include/times_win32.h new file mode 100644 index 00000000000..7995a456625 --- /dev/null +++ b/runtime/include/times_win32.h @@ -0,0 +1,20 @@ +#ifndef _FLANG_TIMES_WIN32 +#define _FLANG_TIMES_WIN32 + #include + + typedef __int64 clock_t; + + typedef struct tms { + clock_t tms_utime; /* user time */ + clock_t tms_stime; /* system time */ + clock_t tms_cutime; /* user time of children */ + clock_t tms_cstime; /* system time of children */ + } tms; + + clock_t convert_filetime( const FILETIME *ac_FileTime ); + + /* + Thin emulation of the unix times function + */ + void times(&tms); +#endif From 052c08e00f9aa36b9bcfd726809dcbee4fad1f30 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:04:56 -0500 Subject: [PATCH 03/14] [runtime/util] implement filetime emulation --- runtime/flang/util.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/runtime/flang/util.c b/runtime/flang/util.c index 3bb05f6b1ae..06edf2b2c2b 100644 --- a/runtime/flang/util.c +++ b/runtime/flang/util.c @@ -333,13 +333,28 @@ void __fort_ftnstrcpy(char *dst, /* destination string, blank-filled */ #ifdef _WIN32 -__int64 filetime_to_int64( const FILETIME *ac_FileTime ) +#include "times_win32.h" + +clock_t convert_filetime( const FILETIME *ac_FileTime ) { ULARGE_INTEGER lv_Large ; lv_Large.LowPart = ac_FileTime->dwLowDateTime ; lv_Large.HighPart = ac_FileTime->dwHighDateTime ; - return (__int64)lv_Large.QuadPart ; + return (clock_t)lv_Large.QuadPart ; +} + +/* + Thin emulation of the unix times function +*/ +void times(&tms) { + FILETIME time_create, time_exit, accum_sys, accum_user; + + GetProcessTimes( GetCurrentProcess(), + &time_create, &time_exit, &accum_sys, &accum_user ); + + tms.tms_utime = convert_filetime(accum_user); + tms.tms_stime = convert_filetime(accum_sys); } #endif From d5763308acbf9ed1c5b67fe29ef8aa41886bd518 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:06:19 -0500 Subject: [PATCH 04/14] [runtime/dtime] include header --- runtime/flang/dtime3f.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/runtime/flang/dtime3f.c b/runtime/flang/dtime3f.c index b1433772cea..175e736c37b 100644 --- a/runtime/flang/dtime3f.c +++ b/runtime/flang/dtime3f.c @@ -35,7 +35,10 @@ #define CLK_TCK sysconf(_SC_CLK_TCK) #endif -#ifndef _WIN32 +#ifdef _WIN32 + #include "times_win32.h" +#endif + static clock_t accum_user = 0, accum_sys = 0; float ENT3F(DTIME, dtime)(float *tarray) @@ -50,33 +53,5 @@ float ENT3F(DTIME, dtime)(float *tarray) accum_sys = b.tms_stime; return (tarray[0] + tarray[1]); } -#else -#include -static FILETIME accum_user; -static FILETIME accum_sys; - -float convert_filetime( const FILETIME *ac_FileTime ) -{ - ULARGE_INTEGER lv_Large ; - - lv_Large.LowPart = ac_FileTime->dwLowDateTime ; - lv_Large.HighPart = ac_FileTime->dwHighDateTime ; - - return (float)lv_Large.QuadPart ; -} -float ENT3F(DTIME, dtime)(float *tarray) -{ - - FILETIME time_create; - FILETIME time_exit; - - GetProcessTimes( GetCurrentProcess(), - &time_create, &time_exit, &accum_sys, &accum_user ); - - tarray[0] = ((float)(convert_filetime(&accum_user))); - tarray[1] = ((float)(convert_filetime(&accum_sys))); - return (tarray[0] + tarray[1]); -} -#endif From 75c159a79f0f257bc514bbfa29715cc1c2947572 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:07:16 -0500 Subject: [PATCH 05/14] [runtime/etime] include header --- runtime/flang/etime3f.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/runtime/flang/etime3f.c b/runtime/flang/etime3f.c index cb8b6cc2ebd..194d66ab4f4 100644 --- a/runtime/flang/etime3f.c +++ b/runtime/flang/etime3f.c @@ -37,7 +37,10 @@ #define CLK_TCK sysconf(_SC_CLK_TCK) #endif -#ifndef _WIN32 +#ifdef _WIN32 + #include "times_win32.h" +#endif + float ENT3F(ETIME, etime)(float *tarray) { struct tms b; @@ -49,21 +52,3 @@ float ENT3F(ETIME, etime)(float *tarray) return (tarray[0] + tarray[1]); } -#else -#include - -float ENT3F(ETIME, etime)(float *tarray) -{ - FILETIME accum_user; - FILETIME accum_sys; - FILETIME time_create; - FILETIME time_exit; - - GetProcessTimes( GetCurrentProcess(), - &time_create, &time_exit, &accum_sys, &accum_user ); - - tarray[0] = ((float)(convert_filetime(&accum_user))); - tarray[1] = ((float)(convert_filetime(&accum_sys))); - return (tarray[0] + tarray[1]); -} -#endif From 70d29afc8747da1ac1cff5e06ff1b70df5568304 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:08:59 -0500 Subject: [PATCH 06/14] [runtime/include] fix header --- runtime/include/times_win32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/include/times_win32.h b/runtime/include/times_win32.h index 7995a456625..4c76ee6e24e 100644 --- a/runtime/include/times_win32.h +++ b/runtime/include/times_win32.h @@ -16,5 +16,5 @@ /* Thin emulation of the unix times function */ - void times(&tms); + void times(tms *time_struct); #endif From 45595a6d822bb1eb6548de7426860f160c0adab6 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:09:44 -0500 Subject: [PATCH 07/14] [runtime/util] fix function --- runtime/flang/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/flang/util.c b/runtime/flang/util.c index 06edf2b2c2b..31ce163d061 100644 --- a/runtime/flang/util.c +++ b/runtime/flang/util.c @@ -348,13 +348,13 @@ clock_t convert_filetime( const FILETIME *ac_FileTime ) /* Thin emulation of the unix times function */ -void times(&tms) { +void times(tms *time_struct) { FILETIME time_create, time_exit, accum_sys, accum_user; GetProcessTimes( GetCurrentProcess(), &time_create, &time_exit, &accum_sys, &accum_user ); - tms.tms_utime = convert_filetime(accum_user); - tms.tms_stime = convert_filetime(accum_sys); + tms.time_struct = convert_filetime(accum_user); + tms.time_struct = convert_filetime(accum_sys); } #endif From 85b7f5fad15e999fed626aaa4be4621286bd691c Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:22:39 -0500 Subject: [PATCH 08/14] [runtime/etime] fix CLK_TCK --- runtime/flang/etime3f.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/flang/etime3f.c b/runtime/flang/etime3f.c index 194d66ab4f4..07ae47f7985 100644 --- a/runtime/flang/etime3f.c +++ b/runtime/flang/etime3f.c @@ -33,12 +33,14 @@ #include #include -#ifndef CLK_TCK -#define CLK_TCK sysconf(_SC_CLK_TCK) -#endif #ifdef _WIN32 #include "times_win32.h" + #define CLK_TCK 1 +#else + #ifndef CLK_TCK + #define CLK_TCK sysconf(_SC_CLK_TCK) + #endif #endif float ENT3F(ETIME, etime)(float *tarray) From 31c2fd22caebec40498990fd23acb65111aa7e80 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:23:28 -0500 Subject: [PATCH 09/14] [runtime/dtime] fix CLK_TCK --- runtime/flang/dtime3f.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/runtime/flang/dtime3f.c b/runtime/flang/dtime3f.c index 175e736c37b..b9ee4ba6a1f 100644 --- a/runtime/flang/dtime3f.c +++ b/runtime/flang/dtime3f.c @@ -31,12 +31,13 @@ #include #include -#ifndef CLK_TCK -#define CLK_TCK sysconf(_SC_CLK_TCK) -#endif - #ifdef _WIN32 #include "times_win32.h" + #define CLK_TCK 1 +#else + #ifndef CLK_TCK + #define CLK_TCK sysconf(_SC_CLK_TCK) + #endif #endif static clock_t accum_user = 0, accum_sys = 0; From dbc255c1d478f453a44aeb87e8a42d83bcbc516b Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:31:34 -0500 Subject: [PATCH 10/14] [runtime/dtime] fix clk_tick --- runtime/flang/dtime3f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/flang/dtime3f.c b/runtime/flang/dtime3f.c index b9ee4ba6a1f..2745e1aa1f9 100644 --- a/runtime/flang/dtime3f.c +++ b/runtime/flang/dtime3f.c @@ -33,7 +33,7 @@ #ifdef _WIN32 #include "times_win32.h" - #define CLK_TCK 1 + #define CLK_TCK 10000000.0 #else #ifndef CLK_TCK #define CLK_TCK sysconf(_SC_CLK_TCK) From e93ad4cd73492693be19bf55b46ccd319b040d78 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:32:00 -0500 Subject: [PATCH 11/14] [runtime/etime] fix clk_tick --- runtime/flang/etime3f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/flang/etime3f.c b/runtime/flang/etime3f.c index 07ae47f7985..e0931ee10e7 100644 --- a/runtime/flang/etime3f.c +++ b/runtime/flang/etime3f.c @@ -36,7 +36,7 @@ #ifdef _WIN32 #include "times_win32.h" - #define CLK_TCK 1 + #define CLK_TCK 10000000.0 #else #ifndef CLK_TCK #define CLK_TCK sysconf(_SC_CLK_TCK) From 3e678693b3e7ae89b37e41750795da1503361957 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 14:56:20 -0500 Subject: [PATCH 12/14] [runtime/util] fix --- runtime/flang/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/flang/util.c b/runtime/flang/util.c index 31ce163d061..a2e411a132e 100644 --- a/runtime/flang/util.c +++ b/runtime/flang/util.c @@ -354,7 +354,7 @@ void times(tms *time_struct) { GetProcessTimes( GetCurrentProcess(), &time_create, &time_exit, &accum_sys, &accum_user ); - tms.time_struct = convert_filetime(accum_user); - tms.time_struct = convert_filetime(accum_sys); + time_struct.tms_utime = convert_filetime(accum_user); + time_struct.tms_stime = convert_filetime(accum_sys); } #endif From deb83653c16e22de7763588b482269f98d6efa1c Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 15:14:43 -0500 Subject: [PATCH 13/14] [runtime/util] fix --- runtime/flang/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/flang/util.c b/runtime/flang/util.c index a2e411a132e..5b451f4916b 100644 --- a/runtime/flang/util.c +++ b/runtime/flang/util.c @@ -354,7 +354,7 @@ void times(tms *time_struct) { GetProcessTimes( GetCurrentProcess(), &time_create, &time_exit, &accum_sys, &accum_user ); - time_struct.tms_utime = convert_filetime(accum_user); - time_struct.tms_stime = convert_filetime(accum_sys); + time_struct->tms_utime = convert_filetime(accum_user); + time_struct->tms_stime = convert_filetime(accum_sys); } #endif From a56292ec757fc07a0a2f6d85f600b62782fd3591 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 29 Oct 2017 15:24:58 -0500 Subject: [PATCH 14/14] Update util.c --- runtime/flang/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/flang/util.c b/runtime/flang/util.c index 5b451f4916b..8d122523475 100644 --- a/runtime/flang/util.c +++ b/runtime/flang/util.c @@ -354,7 +354,7 @@ void times(tms *time_struct) { GetProcessTimes( GetCurrentProcess(), &time_create, &time_exit, &accum_sys, &accum_user ); - time_struct->tms_utime = convert_filetime(accum_user); - time_struct->tms_stime = convert_filetime(accum_sys); + time_struct->tms_utime = convert_filetime(&accum_user); + time_struct->tms_stime = convert_filetime(&accum_sys); } #endif