18 #ifndef _COBALT_POSIX_CLOCK_H 19 #define _COBALT_POSIX_CLOCK_H 21 #include <linux/types.h> 22 #include <linux/time.h> 23 #include <linux/cpumask.h> 24 #include <cobalt/uapi/time.h> 25 #include <xenomai/posix/syscall.h> 27 #define ONE_BILLION 1000000000 31 static inline void ns2ts(
struct timespec *ts, xnticks_t nsecs)
33 ts->tv_sec = xnclock_divrem_billion(nsecs, &ts->tv_nsec);
36 static inline xnticks_t ts2ns(
const struct timespec *ts)
38 xnticks_t nsecs = ts->tv_nsec;
41 nsecs += (xnticks_t)ts->tv_sec * ONE_BILLION;
46 static inline xnticks_t tv2ns(
const struct timeval *tv)
48 xnticks_t nsecs = tv->tv_usec * 1000;
51 nsecs += (xnticks_t)tv->tv_sec * ONE_BILLION;
56 static inline void ticks2tv(
struct timeval *tv, xnticks_t ticks)
60 tv->tv_sec = xnclock_divrem_billion(ticks, &nsecs);
61 tv->tv_usec = nsecs / 1000;
64 static inline xnticks_t clock_get_ticks(clockid_t clock_id)
66 return clock_id == CLOCK_REALTIME ?
67 xnclock_read_realtime(&nkclock) :
68 xnclock_read_monotonic(&nkclock);
71 static inline int clock_flag(
int flag, clockid_t clock_id)
73 if ((flag & TIMER_ABSTIME) == 0)
76 if (clock_id == CLOCK_REALTIME)
82 int __cobalt_clock_getres(clockid_t clock_id,
85 int __cobalt_clock_gettime(clockid_t clock_id,
88 int __cobalt_clock_settime(clockid_t clock_id,
89 const struct timespec *ts);
91 int __cobalt_clock_adjtime(clockid_t clock_id,
94 int __cobalt_clock_nanosleep(clockid_t clock_id,
int flags,
95 const struct timespec *rqt,
96 struct timespec *rmt);
99 (clockid_t clock_id,
struct timespec __user *u_ts));
102 (clockid_t clock_id,
struct timespec __user *u_ts));
105 (clockid_t clock_id,
const struct timespec __user *u_ts));
107 COBALT_SYSCALL_DECL(clock_adjtime,
108 (clockid_t clock_id,
struct timex __user *u_tx));
111 (clockid_t clock_id,
int flags,
112 const struct timespec __user *u_rqt,
113 struct timespec __user *u_rmt));
115 int cobalt_clock_register(
struct xnclock *clock,
116 const cpumask_t *affinity,
119 void cobalt_clock_deregister(
struct xnclock *clock);
121 struct xnclock *cobalt_clock_find(clockid_t clock_id);
123 extern DECLARE_BITMAP(cobalt_clock_extids, COBALT_MAX_EXTCLOCKS);
int clock_getres(clockid_t clock_id, struct timespec *tp)
Get the resolution of the specified clock.
Definition: clock.c:101
int clock_settime(clockid_t clock_id, const struct timespec *tp)
Set the specified clock.
Definition: clock.c:239
int clock_gettime(clockid_t clock_id, struct timespec *tp)
Read the specified clock.
Definition: clock.c:183
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
Sleep some amount of time.
Definition: clock.c:311