scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

time.c (310B)


      1 #include <time.h>
      2 
      3 struct timeval {
      4 	time_t tv_sec;
      5 	int tv_usec; /* TODO use a arch type */
      6 };
      7 
      8 int
      9 _gettimeofday(struct timeval * restrict tp, void * restrict tzp);
     10 
     11 time_t
     12 time(time_t *t)
     13 {
     14 	struct timeval tv;
     15 
     16 	if (_gettimeofday(&tv, NULL) == -1)
     17 		return -1;
     18 	if (t)
     19 		*t =tv.tv_sec;
     20 	return tv.tv_sec;
     21 }