diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2020-05-07 21:37:28 +0200 |
---|---|---|
committer | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2020-05-15 20:20:08 +0200 |
commit | db71d315479762eefbf2bcda8be3b44b1867133f (patch) | |
tree | 26882b4aee7fc084d89ee5198af7272d5c7c8fc0 /apps/lib | |
parent | c6601bd2d728d4c61711a016c6267fb45910e7cd (diff) |
Guard use of struct tms with #ifdef __TMS like done earlier in apps/lib/apps.c
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/11755)
Diffstat (limited to 'apps/lib')
-rw-r--r-- | apps/lib/apps.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 6facdf3e5b..4b7201166c 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -2320,17 +2320,30 @@ double app_tminterval(int stop, int usertime) double app_tminterval(int stop, int usertime) { double ret = 0; - struct tms rus; - clock_t now = times(&rus); + clock_t now; static clock_t tmstart; + long int tck = sysconf(_SC_CLK_TCK); +# ifdef __TMS + struct tms rus; + now = times(&rus); if (usertime) now = rus.tms_utime; +# else + if (usertime) + now = clock(); /* sum of user and kernel times */ + else { + struct timeval tv; + gettimeofday(&tv, NULL); + now = (clock_t)((unsigned long long)tv.tv_sec * tck + + (unsigned long long)tv.tv_usec * (1000000 / tck) + ); + } +# endif if (stop == TM_START) { tmstart = now; } else { - long int tck = sysconf(_SC_CLK_TCK); ret = (now - tmstart) / (double)tck; } |