aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/compat/simd-asm
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-07 00:19:14 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-07 02:24:31 +0200
commitbddaca79f57aac71d63d2cb4713de5ee4320cc28 (patch)
tree7e3bdb638ccdbdcdaf8289acca2cc39bff49aed4 /src/compat/simd-asm
parentcompat: account for ancient ARM assembler (diff)
downloadwireguard-monolithic-historical-bddaca79f57aac71d63d2cb4713de5ee4320cc28.tar.xz
wireguard-monolithic-historical-bddaca79f57aac71d63d2cb4713de5ee4320cc28.zip
compat: make asm/simd.h conditional on its existence
Android kernels backported it, complicating things.
Diffstat (limited to 'src/compat/simd-asm')
-rw-r--r--src/compat/simd-asm/include/asm/simd.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/compat/simd-asm/include/asm/simd.h b/src/compat/simd-asm/include/asm/simd.h
new file mode 100644
index 0000000..a975b38
--- /dev/null
+++ b/src/compat/simd-asm/include/asm/simd.h
@@ -0,0 +1,21 @@
+#ifndef _COMPAT_ASM_SIMD_H
+#define _COMPAT_ASM_SIMD_H
+
+#if defined(CONFIG_X86_64)
+#include <asm/fpu/api.h>
+#endif
+
+static __must_check inline bool may_use_simd(void)
+{
+#if defined(CONFIG_X86_64)
+ return irq_fpu_usable();
+#elif defined(CONFIG_ARM64) && defined(CONFIG_KERNEL_MODE_NEON)
+ return true;
+#elif defined(CONFIG_ARM) && defined(CONFIG_KERNEL_MODE_NEON)
+ return !in_nmi() && !in_irq() && !in_serving_softirq();
+#else
+ return false;
+#endif
+}
+
+#endif