1#include <sys/timeb.h>
2#include <time.h>
3
4int ftime(struct timeb* tp) {
5    struct timespec ts;
6    clock_gettime(CLOCK_REALTIME, &ts);
7    tp->time = ts.tv_sec;
8    tp->millitm = ts.tv_nsec / 1000000;
9    tp->timezone = tp->dstflag = 0;
10    return 0;
11}
12