complete, tick-resolution gettimeofday() implementation
This commit is contained in:
@@ -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) );
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user