Home | History | Annotate | Download | only in sys
      1 #ifndef __SYS_TIMEB_H
      2 #define __SYS_TIMEB_H
      3 
      4 #include <time.h>
      5 
      6 struct timeb {
      7     time_t time;
      8     unsigned short millitm;
      9     short timezone;
     10     short dstflag;
     11 };
     12 
     13 static inline int ftime(struct timeb *tp) {
     14     const unsigned int ONE_MS_IN_NS = 100000;
     15     struct timespec ts;
     16 
     17     int err = clock_gettime(CLOCK_REALTIME, &ts);
     18     if (err)
     19         return -1;
     20 
     21     tp->time = ts.tv_sec;
     22     tp->millitm = ts.tv_nsec / ONE_MS_IN_NS;
     23     return 0;
     24 }
     25 
     26 #endif /* __SYS_TIMEB_H */
     27