Skip to content

Commit

Permalink
Fix build error with kernels too old to support ktime_get_real (#1624)
Browse files Browse the repository at this point in the history
* Fix build error with kernels too old to support ktime_get_real

* fix(driver): use timespec instead of timeval for kernels < 3.17

Co-Authored-By: Leonardo Di Donato <[email protected]>
Signed-off-by: Lorenzo Fontana <[email protected]>

Co-authored-by: Lorenzo Fontana <[email protected]>
Co-authored-by: Leonardo Di Donato <[email protected]>
  • Loading branch information
3 people authored May 6, 2020
1 parent c4af1a9 commit 96bd9bc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions driver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,14 @@ do { \

static inline nanoseconds ppm_nsecs(void)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))
return ktime_get_real_ns();
#else
/* Don't have ktime_get_real functions */
struct timespec ts;
getnstimeofday(&ts);
return SECOND_IN_NS * ts.tv_sec + ts.tv_nsec;
#endif
}

inline void ppm_syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, unsigned long *args)
Expand Down

0 comments on commit 96bd9bc

Please sign in to comment.