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

@@ -3,16 +3,19 @@ gettimeofday.c
*/
#include <sys/time.h>
#include <lib.h>
#include <time.h>
int gettimeofday(struct timeval *_RESTRICT tp, void *_RESTRICT tzp)
{
if (time(&tp->tv_sec) == (time_t)-1)
return -1;
tp->tv_usec= 0;
message m;
/* tzp has to be a nul pointer according to the standard. Otherwise
* behavior is undefined. We can just ignore tzp.
*/
return 0;
if (_syscall(MM, GETTIMEOFDAY, &m) < 0)
return -1;
tp->tv_sec = m.m2_l1;
tp->tv_usec = m.m2_l2;
return 0;
}