freebsd-dev/contrib/libf2c/libF77/etime_.c

44 lines
685 B
C
Raw Normal View History

1999-09-18 10:51:31 +00:00
#include "time.h"
1999-09-19 05:59:11 +00:00
#ifdef MSDOS
#undef USE_CLOCK
#define USE_CLOCK
#endif
1999-09-18 10:51:31 +00:00
#ifndef USE_CLOCK
#define _INCLUDE_POSIX_SOURCE /* for HP-UX */
#define _INCLUDE_XOPEN_SOURCE /* for HP-UX */
#include "sys/types.h"
#include "sys/times.h"
#endif
#undef Hz
#ifdef CLK_TCK
#define Hz CLK_TCK
#else
#ifdef HZ
#define Hz HZ
#else
#define Hz 60
#endif
#endif
2003-07-11 03:42:19 +00:00
double
etime_ (float *tarray)
1999-09-18 10:51:31 +00:00
{
#ifdef USE_CLOCK
#ifndef CLOCKS_PER_SECOND
#define CLOCKS_PER_SECOND Hz
#endif
2003-07-11 03:42:19 +00:00
double t = clock ();
tarray[1] = 0;
return tarray[0] = t / CLOCKS_PER_SECOND;
1999-09-18 10:51:31 +00:00
#else
2003-07-11 03:42:19 +00:00
struct tms t;
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
times (&t);
return (tarray[0] = (double) t.tms_utime / Hz)
+ (tarray[1] = (double) t.tms_stime / Hz);
1999-09-18 10:51:31 +00:00
#endif
2003-07-11 03:42:19 +00:00
}