Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/ktime.h
Show All 29 Lines | |||||
#ifndef _LINUX_KTIME_H | #ifndef _LINUX_KTIME_H | ||||
#define _LINUX_KTIME_H | #define _LINUX_KTIME_H | ||||
#include <linux/types.h> | #include <linux/types.h> | ||||
#include <linux/time.h> | #include <linux/time.h> | ||||
#include <linux/jiffies.h> | #include <linux/jiffies.h> | ||||
#define ktime_get_ts(x) getnanouptime(x) | |||||
/* time values in nanoseconds */ | /* time values in nanoseconds */ | ||||
typedef s64 ktime_t; | typedef s64 ktime_t; | ||||
#define KTIME_MAX ((s64)~((u64)1 << 63)) | #define KTIME_MAX ((s64)~((u64)1 << 63)) | ||||
#define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) | #define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) | ||||
static inline int64_t | static inline int64_t | ||||
ktime_to_ns(ktime_t kt) | ktime_to_ns(ktime_t kt) | ||||
Show All 40 Lines | |||||
static inline ktime_t | static inline ktime_t | ||||
ktime_add_ms(ktime_t kt, int64_t ms) | ktime_add_ms(ktime_t kt, int64_t ms) | ||||
{ | { | ||||
return (ktime_add_ns(kt, ms * NSEC_PER_MSEC)); | return (ktime_add_ns(kt, ms * NSEC_PER_MSEC)); | ||||
} | } | ||||
static inline ktime_t | static inline ktime_t | ||||
ktime_add_us(ktime_t kt, int64_t us) | |||||
{ | |||||
return (ktime_add_ns(kt, us * NSEC_PER_USEC)); | |||||
} | |||||
static inline ktime_t | |||||
ktime_sub_ns(ktime_t kt, int64_t ns) | ktime_sub_ns(ktime_t kt, int64_t ns) | ||||
{ | { | ||||
return (kt - ns); | return (kt - ns); | ||||
} | } | ||||
static inline ktime_t | static inline ktime_t | ||||
ktime_set(const long secs, const unsigned long nsecs) | ktime_set(const long secs, const unsigned long nsecs) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static inline ktime_t | static inline ktime_t | ||||
timeval_to_ktime(struct timeval tv) | timeval_to_ktime(struct timeval tv) | ||||
{ | { | ||||
return (ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC)); | return (ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC)); | ||||
} | } | ||||
static inline int64_t | |||||
timespec64_to_ns(struct timespec64 *ts) | |||||
{ | |||||
return (timespec_to_ns(ts)); | |||||
} | |||||
#define ktime_to_timespec(kt) ns_to_timespec(kt) | #define ktime_to_timespec(kt) ns_to_timespec(kt) | ||||
#define ktime_to_timespec64(kt) ns_to_timespec(kt) | #define ktime_to_timespec64(kt) ns_to_timespec(kt) | ||||
#define ktime_to_timeval(kt) ns_to_timeval(kt) | #define ktime_to_timeval(kt) ns_to_timeval(kt) | ||||
#define ktime_to_ns(kt) (kt) | #define ktime_to_ns(kt) (kt) | ||||
#define ktime_get_ts64(ts) ktime_get_ts(ts) | #define ktime_get_ts64(ts) getnanouptime(ts) | ||||
#define ktime_get_raw_ts64(ts) getnanouptime(ts) | |||||
#define getrawmonotonic64(ts) getnanouptime(ts) | |||||
static inline int64_t | static inline int64_t | ||||
ktime_get_ns(void) | ktime_get_ns(void) | ||||
{ | { | ||||
struct timespec ts; | struct timespec ts; | ||||
ktime_get_ts(&ts); | ktime_get_ts64(&ts); | ||||
return (ktime_to_ns(timespec_to_ktime(ts))); | return (ktime_to_ns(timespec_to_ktime(ts))); | ||||
} | } | ||||
static inline ktime_t | static inline ktime_t | ||||
ktime_get(void) | ktime_get(void) | ||||
{ | { | ||||
struct timespec ts; | struct timespec ts; | ||||
ktime_get_ts(&ts); | ktime_get_ts64(&ts); | ||||
return (timespec_to_ktime(ts)); | return (timespec_to_ktime(ts)); | ||||
} | } | ||||
static inline ktime_t | static inline ktime_t | ||||
ktime_get_boottime(void) | ktime_get_boottime(void) | ||||
{ | { | ||||
struct timespec ts; | struct timespec ts; | ||||
Show All 19 Lines | ktime_get_real_seconds(void) | ||||
return (ts.tv_sec); | return (ts.tv_sec); | ||||
} | } | ||||
static inline ktime_t | static inline ktime_t | ||||
ktime_get_raw(void) | ktime_get_raw(void) | ||||
{ | { | ||||
struct timespec ts; | struct timespec ts; | ||||
nanotime(&ts); | nanouptime(&ts); | ||||
return (timespec_to_ktime(ts)); | return (timespec_to_ktime(ts)); | ||||
} | } | ||||
static inline u64 | static inline u64 | ||||
ktime_get_raw_ns(void) | ktime_get_raw_ns(void) | ||||
{ | { | ||||
struct timespec ts; | struct timespec ts; | ||||
nanouptime(&ts); | nanouptime(&ts); | ||||
return (ktime_to_ns(timespec_to_ktime(ts))); | return (ktime_to_ns(timespec_to_ktime(ts))); | ||||
} | } | ||||
#endif /* _LINUX_KTIME_H */ | #endif /* _LINUX_KTIME_H */ |