SolarCapture C Bindings
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
time.h
Go to the documentation of this file.
1 
8 #ifndef __SOLAR_CAPTURE_TIME_H__
9 #define __SOLAR_CAPTURE_TIME_H__
10 
11 
12 struct sc_attr;
13 struct sc_thread;
14 
15 
29 extern void sc_timer_expire_at(struct sc_callback* cb,
30  const struct timespec* time);
31 
42 extern void sc_timer_expire_after_ns(struct sc_callback* cb, int64_t delta_ns);
43 
62 extern void sc_timer_push_back_ns(struct sc_callback* cb, int64_t delta_ns);
63 
71 extern int sc_timer_get_expiry_time(const struct sc_callback* cb,
72  struct timespec* ts_out);
73 
79 static inline uint64_t sc_ns_from_ts(const struct timespec* ts)
80 {
81  return (uint64_t) ts->tv_sec * 1000000000 + ts->tv_nsec;
82 }
83 
89 static inline uint64_t sc_ns_from_tv(const struct timeval* tv)
90 {
91  return (uint64_t) tv->tv_sec * 1000000000 + (uint64_t) tv->tv_usec * 1000;
92 }
93 
94 
100 static inline uint64_t sc_ns_from_ms(uint64_t ms)
101 {
102  return ms * 1000000;
103 }
104 
105 
111 static inline uint64_t sc_ns_from_us(uint64_t us)
112 {
113  return us * 1000;
114 }
115 
116 
117 #endif /* __SOLAR_CAPTURE_TIME_H__ */
118 
Attribute object.
static uint64_t sc_ns_from_us(uint64_t us)
Convert microseconds to nanoseconds.
Definition: time.h:111
int sc_timer_get_expiry_time(const struct sc_callback *cb, struct timespec *ts_out)
Return the expiry time of a timer callback.
void sc_timer_push_back_ns(struct sc_callback *cb, int64_t delta_ns)
Push the expiry time further into the future.
static uint64_t sc_ns_from_tv(const struct timeval *tv)
Convert a timeval struct to nanoseconds.
Definition: time.h:89
static uint64_t sc_ns_from_ts(const struct timespec *ts)
Convert a timespec struct to nanoseconds.
Definition: time.h:79
static uint64_t sc_ns_from_ms(uint64_t ms)
Convert milliseconds to nanoseconds.
Definition: time.h:100
A callback object.
Definition: event.h:33
void sc_timer_expire_at(struct sc_callback *cb, const struct timespec *time)
Request a callback at a given time.
void sc_timer_expire_after_ns(struct sc_callback *cb, int64_t delta_ns)
Request a callback in the future.