mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 00:53:34 +08:00
Inline ts_to_abstime and abstime_to_ts
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Beat Küng
parent
3e6a35fe8a
commit
9f049b4dca
+15
-2
@@ -97,12 +97,25 @@ __EXPORT extern hrt_abstime hrt_absolute_time(void);
|
||||
/**
|
||||
* Convert a timespec to absolute time.
|
||||
*/
|
||||
__EXPORT extern hrt_abstime ts_to_abstime(const struct timespec *ts);
|
||||
static inline hrt_abstime ts_to_abstime(const struct timespec *ts)
|
||||
{
|
||||
hrt_abstime result;
|
||||
|
||||
result = (hrt_abstime)(ts->tv_sec) * 1000000;
|
||||
result += ts->tv_nsec / 1000;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert absolute time to a timespec.
|
||||
*/
|
||||
__EXPORT extern void abstime_to_ts(struct timespec *ts, hrt_abstime abstime);
|
||||
static inline void abstime_to_ts(struct timespec *ts, hrt_abstime abstime)
|
||||
{
|
||||
ts->tv_sec = abstime / 1000000;
|
||||
abstime -= ts->tv_sec * 1000000;
|
||||
ts->tv_nsec = abstime * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the delta between a timestamp taken in the past
|
||||
|
||||
Reference in New Issue
Block a user