Helpers for converting time to and from tsc ticks
[akaros.git] / kern / include / time.h
1 #ifndef ROS_KERN_TIME_H
2 #define ROS_KERN_TIME_H
3
4 #include <ros/common.h>
5 #include <arch/time.h>
6
7 /* (newlib) Time Value Specification Structures, P1003.1b-1993, p. 261 */
8 typedef long time_t;
9
10 struct timespec {
11   time_t  tv_sec;   /* Seconds */
12   long    tv_nsec;  /* Nanoseconds */
13 };
14
15 struct itimerspec {
16   struct timespec  it_interval;  /* Timer period */
17   struct timespec  it_value;     /* Timer expiration */
18 };
19
20 void udelay(uint64_t usec);
21 uint64_t tsc2sec(uint64_t tsc_time);
22 uint64_t tsc2msec(uint64_t tsc_time);
23 uint64_t tsc2usec(uint64_t tsc_time);
24 uint64_t tsc2nsec(uint64_t tsc_time);
25 uint64_t sec2tsc(uint64_t sec);
26 uint64_t msec2tsc(uint64_t msec);
27 uint64_t usec2tsc(uint64_t usec);
28 uint64_t nsec2tsc(uint64_t nsec);
29
30 #endif /* ROS_KERN_TIME_H */