diff options
author | Alexander Kabaev <kan@FreeBSD.org> | 2003-07-11 03:42:19 +0000 |
---|---|---|
committer | Alexander Kabaev <kan@FreeBSD.org> | 2003-07-11 03:42:19 +0000 |
commit | eb05e163fcadd646f28a1b1ef1182677b325a045 (patch) | |
tree | 01f695ddb223c95a40652601894e4291cdf92786 /contrib/libf2c/libU77/etime_.c | |
parent | 865328879900c99b2516e0cb403295aac55ff45a (diff) | |
parent | 6bdbd039fdee37985426b3cfdb6ec9b43f1c96aa (diff) |
This commit was generated by cvs2svn to compensate for changes in r117401,
which included commits to RCS files with non-trunk default branches.
Notes
Notes:
svn path=/head/; revision=117402
Diffstat (limited to 'contrib/libf2c/libU77/etime_.c')
-rw-r--r-- | contrib/libf2c/libU77/etime_.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/contrib/libf2c/libU77/etime_.c b/contrib/libf2c/libU77/etime_.c index 88eead3fbb47..d0edb2fbcd3e 100644 --- a/contrib/libf2c/libU77/etime_.c +++ b/contrib/libf2c/libU77/etime_.c @@ -44,19 +44,8 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> /* for ENOSYS */ #include "f2c.h" -/* For dtime, etime we store the clock tick parameter (clk_tck) the - first time either of them is invoked rather than each time. This - approach probably speeds up each invocation by avoiding a system - call each time, but means that the overhead of the first call is - different to all others. */ -static long clk_tck = 0; - -#ifdef KR_headers -double G77_etime_0 (tarray) - real tarray[2]; -#else -double G77_etime_0 (real tarray[2]) -#endif +double +G77_etime_0 (real tarray[2]) { #if defined (_WIN32) static int win32_platform = -1; @@ -69,7 +58,7 @@ double G77_etime_0 (real tarray[2]) GetVersionEx (&osv); win32_platform = osv.dwPlatformId; } - + /* non-NT platforms don't have a clue as to how long a process has been running, so simply return the uptime. Bad judgement call? */ if (win32_platform != VER_PLATFORM_WIN32_NT) @@ -82,7 +71,7 @@ double G77_etime_0 (real tarray[2]) if (clock_freq == 0) { LARGE_INTEGER freq; - if (! QueryPerformanceFrequency (&freq)) + if (!QueryPerformanceFrequency (&freq)) { errno = ENOSYS; return 0.0; @@ -90,19 +79,19 @@ double G77_etime_0 (real tarray[2]) else { clock_freq = ((unsigned long long) freq.HighPart << 32) - + ((unsigned) freq.LowPart); - if (! QueryPerformanceCounter (&counter_val)) + + ((unsigned) freq.LowPart); + if (!QueryPerformanceCounter (&counter_val)) return -1.0; old_count = ((unsigned long long) counter_val.HighPart << 32) - + (unsigned) counter_val.LowPart; + + (unsigned) counter_val.LowPart; } } - if (! QueryPerformanceCounter (&counter_val)) + if (!QueryPerformanceCounter (&counter_val)) return -1.0; count = ((unsigned long long) counter_val.HighPart << 32) - + (unsigned) counter_val.LowPart; + + (unsigned) counter_val.LowPart; tarray[0] = usertime = (double) (count - old_count) / clock_freq; tarray[1] = systime = 0.0; } @@ -114,13 +103,13 @@ double G77_etime_0 (real tarray[2]) GetProcessTimes (GetCurrentProcess (), &creation_time, &exit_time, &kernel_time, &user_time); utime = ((unsigned long long) user_time.dwHighDateTime << 32) - + (unsigned) user_time.dwLowDateTime; + + (unsigned) user_time.dwLowDateTime; stime = ((unsigned long long) kernel_time.dwHighDateTime << 32) - + (unsigned) kernel_time.dwLowDateTime; + + (unsigned) kernel_time.dwLowDateTime; tarray[0] = usertime = utime / 1.0e7; tarray[1] = systime = stime / 1.0e7; - } + } return usertime + systime; #elif defined (HAVE_GETRUSAGE) || defined (HAVE_TIMES) @@ -128,34 +117,45 @@ double G77_etime_0 (real tarray[2]) #ifdef HAVE_GETRUSAGE struct rusage rbuff; - if (getrusage (RUSAGE_SELF, &rbuff) != 0) - abort (); - tarray[0] = ((float) (rbuff.ru_utime).tv_sec + - (float) (rbuff.ru_utime).tv_usec/1000000.0); - tarray[1] = ((float) (rbuff.ru_stime).tv_sec + - (float) (rbuff.ru_stime).tv_usec/1000000.0); -#else /* HAVE_GETRUSAGE */ + if (getrusage (RUSAGE_SELF, &rbuff) != 0) + abort (); + tarray[0] = ((float) (rbuff.ru_utime).tv_sec + + (float) (rbuff.ru_utime).tv_usec / 1000000.0); + tarray[1] = ((float) (rbuff.ru_stime).tv_sec + + (float) (rbuff.ru_stime).tv_usec / 1000000.0); +#else /* HAVE_GETRUSAGE */ + /* For dtime, etime we store the clock tick parameter (clk_tck) the + first time either of them is invoked rather than each time. This + approach probably speeds up each invocation by avoiding a system + call each time, but means that the overhead of the first call is + different to all others. */ + static long clk_tck = 0; struct tms buffer; /* NeXTStep seems to define _SC_CLK_TCK but not to have sysconf; fixme: does using _POSIX_VERSION help? */ # if defined _SC_CLK_TCK && defined _POSIX_VERSION - if (! clk_tck) clk_tck = sysconf(_SC_CLK_TCK); + if (!clk_tck) + clk_tck = sysconf (_SC_CLK_TCK); # elif defined CLOCKS_PER_SECOND - if (! clk_tck) clk_tck = CLOCKS_PER_SECOND; + if (!clk_tck) + clk_tck = CLOCKS_PER_SECOND; # elif defined CLK_TCK - if (! clk_tck) clk_tck = CLK_TCK; + if (!clk_tck) + clk_tck = CLK_TCK; # elif defined HZ - if (! clk_tck) clk_tck = HZ; + if (!clk_tck) + clk_tck = HZ; # elif defined HAVE_GETRUSAGE # else - #error Dont know clock tick length +#error Dont know clock tick length # endif - if (times(&buffer) == (clock_t)-1) return -1.0; - tarray[0] = (float) buffer.tms_utime / (float)clk_tck; - tarray[1] = (float) buffer.tms_stime / (float)clk_tck; + if (times (&buffer) == (clock_t) - 1) + return -1.0; + tarray[0] = (float) buffer.tms_utime / (float) clk_tck; + tarray[1] = (float) buffer.tms_stime / (float) clk_tck; #endif /* HAVE_GETRUSAGE */ - return (tarray[0]+tarray[1]); + return (tarray[0] + tarray[1]); #else /* ! HAVE_GETRUSAGE && ! HAVE_TIMES */ errno = ENOSYS; return 0.0; |