aboutsummaryrefslogtreecommitdiffstats
path: root/android/include/sys/timeb.h
blob: 9954a0d0ce2b8e6cd96a4cede9daa2fbdc4c15df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef __SYS_TIMEB_H
#define __SYS_TIMEB_H

#include <time.h>

struct timeb {
    time_t time;
    unsigned short millitm;
    short timezone;
    short dstflag;
};

static inline int ftime(struct timeb *tp) {
    const unsigned int ONE_MS_IN_NS = 100000;
    struct timespec ts;

    int err = clock_gettime(CLOCK_REALTIME, &ts);
    if (err)
        return -1;

    tp->time = ts.tv_sec;
    tp->millitm = ts.tv_nsec / ONE_MS_IN_NS;
    return 0;
}

#endif /* __SYS_TIMEB_H */