1 #include <machine/syscall.h>
5 #include "internal_syscall.h"
7 extern int _gettimeofday(struct timeval
*, void *);
9 /* Timing information for current process. From
10 newlib/libc/include/sys/times.h the tms struct fields are as follows:
12 - clock_t tms_utime : user clock ticks
13 - clock_t tms_stime : system clock ticks
14 - clock_t tms_cutime : children's user clock ticks
15 - clock_t tms_cstime : children's system clock ticks
17 Since maven does not currently support processes we set both of the
18 children's times to zero. Eventually we might want to separately
19 account for user vs system time, but for now we just return the total
20 number of cycles since starting the program. */
22 _times(struct tms
*buf
)
24 static char initialized
;
25 static struct timeval t0
;
28 _gettimeofday (&t
, 0);
30 // when called for the first time, initialize t0
33 t0
.tv_usec
= t
.tv_usec
;
37 long long utime
= (t
.tv_sec
- t0
.tv_sec
) * 1000000 + (t
.tv_usec
- t0
.tv_usec
);
38 buf
->tms_utime
= utime
* CLOCKS_PER_SEC
/ 1000000;
39 buf
->tms_stime
= buf
->tms_cstime
= buf
->tms_cutime
= 0;
41 return buf
->tms_utime
;