summaryrefslogtreecommitdiffhomepage
path: root/src/compat
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-07-04 11:14:41 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-07-04 11:15:48 +0200
commit87b809b88e1bf41a9c142d22a6e29f08d992ca41 (patch)
tree5d8cfcd9d6cc7709e027fa73cd68ecd0585e716e /src/compat
parente5f1727c7175cce6e65ad700934a8e609fbf9336 (diff)
compat: define conversion constants for ancient kernels
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/compat')
-rw-r--r--src/compat/Kbuild.include4
-rw-r--r--src/compat/compat.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/compat/Kbuild.include b/src/compat/Kbuild.include
index 95041a9..1b555f8 100644
--- a/src/compat/Kbuild.include
+++ b/src/compat/Kbuild.include
@@ -47,6 +47,10 @@ ccflags-y += -include $(kbuild-dir)/compat/memneq/include.h
wireguard-y += compat/memneq/memneq.o
endif
+ifeq ($(wildcard $(srctree)/include/generated/timeconst.h),)
+ccflags-y += $(shell echo 'define gcd(a,b){auto t;while(b){t=b;b=a%b;a=t;};return a;};hz=$(CONFIG_HZ);cd=gcd(hz,1000000);print "-DHZ_TO_USEC_NUM=",1000000/cd," -DHZ_TO_USEC_DEN=",hz/cd;halt;' | bc -q)
+endif
+
ifeq ($(wildcard $(srctree)/arch/arm/include/asm/neon.h)$(CONFIG_ARM),y)
ccflags-y += -I$(kbuild-dir)/compat/neon-arm/include
endif
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 239fa58..6288550 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -406,7 +406,7 @@ static inline u64 __compat_jiffies64_to_nsecs(u64 j)
{
#if !(NSEC_PER_SEC % HZ)
return (NSEC_PER_SEC / HZ) * j;
-# else
+#else
return div_u64(j * HZ_TO_USEC_NUM, HZ_TO_USEC_DEN) * 1000;
#endif
}