summaryrefslogtreecommitdiffhomepage
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
commit318893096ba2474c83cfd7b4f8ba4cb163b53430 (patch)
tree321e0086b0e831f24dbcc045c35c55275e22bec4 /src/compat/simd-asm
parentb4484a96aa8488ed8e4f04d6947af23677504fe7 (diff)
compat: make asm/simd.h conditional on its existence
Android kernels backported it, complicating things. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
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