complete, tick-resolution gettimeofday() implementation

This commit is contained in:
Ben Gras
2005-07-06 07:08:36 +00:00
parent 493ab97a8d
commit f0817fbd4c
7 changed files with 54 additions and 8 deletions

View File

@@ -86,6 +86,7 @@ _PROTOTYPE( void check_pending, (struct mproc *rmp) );
_PROTOTYPE( int do_stime, (void) );
_PROTOTYPE( int do_time, (void) );
_PROTOTYPE( int do_times, (void) );
_PROTOTYPE( int do_gettimeofday, (void) );
/* trace.c */
_PROTOTYPE( int do_trace, (void) );

View File

@@ -106,6 +106,7 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {
no_sys, /* 87 = fsync */
do_getsetpriority, /* 88 = getpriority */
do_getsetpriority, /* 89 = setpriority */
do_gettimeofday, /* 90 = gettimeofday */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];

View File

@@ -84,3 +84,20 @@ PUBLIC int do_times()
return(OK);
}
/*===========================================================================*
* do_gettimeofday *
*===========================================================================*/
PUBLIC int do_gettimeofday(void)
{
clock_t uptime;
int s;
if ( (s=sys_getuptime(&uptime)) != OK)
panic(__FILE__,"do_gettimeofday couldn't get uptime", s);
mp->mp_reply.m2_l1 = boottime + uptime/HZ;
mp->mp_reply.m2_l2 = (uptime%HZ)*1000000/HZ;
return(OK);
}