xref: /freebsd/sys/contrib/openzfs/config/kernel-fpu.m4 (revision f552d7adebb13e24f65276a6c4822bffeeac3993)
1eda14cbcSMatt Macydnl #
2eda14cbcSMatt Macydnl # Handle differences in kernel FPU code.
3eda14cbcSMatt Macydnl #
4eda14cbcSMatt Macydnl # Kernel
5e3aa18adSMartin Matuskadnl # 5.19:	The asm/fpu/internal.h header was removed, it has been
6e3aa18adSMartin Matuskadnl #		effectively empty since the 5.16 kernel.
7e3aa18adSMartin Matuskadnl #
8c03c5b1cSMartin Matuskadnl # 5.11:	kernel_fpu_begin() is an inlined function now, so don't check
9c03c5b1cSMartin Matuskadnl #		for it inside the kernel symbols.
10c03c5b1cSMartin Matuskadnl #
11eda14cbcSMatt Macydnl # 5.0:	Wrappers have been introduced to save/restore the FPU state.
12eda14cbcSMatt Macydnl #		This change was made to the 4.19.38 and 4.14.120 LTS kernels.
13eda14cbcSMatt Macydnl #		HAVE_KERNEL_FPU_INTERNAL
14eda14cbcSMatt Macydnl #
15eda14cbcSMatt Macydnl # 4.2:	Use __kernel_fpu_{begin,end}()
16eda14cbcSMatt Macydnl #		HAVE_UNDERSCORE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
17eda14cbcSMatt Macydnl #
18eda14cbcSMatt Macydnl # Pre-4.2:	Use kernel_fpu_{begin,end}()
19eda14cbcSMatt Macydnl #		HAVE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
20eda14cbcSMatt Macydnl #
21eda14cbcSMatt Macydnl # N.B. The header check is performed before all other checks since it
22eda14cbcSMatt Macydnl # depends on HAVE_KERNEL_FPU_API_HEADER being set in confdefs.h.
23eda14cbcSMatt Macydnl #
24eda14cbcSMatt MacyAC_DEFUN([ZFS_AC_KERNEL_FPU_HEADER], [
25eda14cbcSMatt Macy	AC_MSG_CHECKING([whether fpu headers are available])
26eda14cbcSMatt Macy	ZFS_LINUX_TRY_COMPILE([
27eda14cbcSMatt Macy		#include <linux/module.h>
28eda14cbcSMatt Macy		#include <asm/fpu/api.h>
29eda14cbcSMatt Macy	],[
30eda14cbcSMatt Macy	],[
31eda14cbcSMatt Macy		AC_DEFINE(HAVE_KERNEL_FPU_API_HEADER, 1,
32eda14cbcSMatt Macy		    [kernel has asm/fpu/api.h])
33e3aa18adSMartin Matuska
34e3aa18adSMartin Matuska		ZFS_LINUX_TRY_COMPILE([
35e3aa18adSMartin Matuska			#include <linux/module.h>
36e3aa18adSMartin Matuska			#include <asm/fpu/internal.h>
37681ce946SMartin Matuska		],[
38e3aa18adSMartin Matuska		],[
39e3aa18adSMartin Matuska			AC_DEFINE(HAVE_KERNEL_FPU_INTERNAL_HEADER, 1,
40e3aa18adSMartin Matuska			    [kernel has asm/fpu/internal.h])
41e3aa18adSMartin Matuska			AC_MSG_RESULT([asm/fpu/api.h asm/fpu/internal.h])
42e3aa18adSMartin Matuska		],[
43e3aa18adSMartin Matuska			AC_MSG_RESULT([asm/fpu/api.h])
44eda14cbcSMatt Macy		])
45e3aa18adSMartin Matuska	],[
46e3aa18adSMartin Matuska		AC_MSG_RESULT([i387.h])
47e3aa18adSMartin Matuska	])
48e3aa18adSMartin Matuska
49eda14cbcSMatt Macy])
50eda14cbcSMatt Macy
51eda14cbcSMatt MacyAC_DEFUN([ZFS_AC_KERNEL_SRC_FPU], [
52eda14cbcSMatt Macy	ZFS_LINUX_TEST_SRC([kernel_fpu], [
53eda14cbcSMatt Macy		#include <linux/types.h>
54eda14cbcSMatt Macy		#ifdef HAVE_KERNEL_FPU_API_HEADER
55eda14cbcSMatt Macy		#include <asm/fpu/api.h>
56e3aa18adSMartin Matuska		#ifdef HAVE_KERNEL_FPU_INTERNAL_HEADER
57da5137abSMartin Matuska		#include <asm/fpu/internal.h>
58e3aa18adSMartin Matuska		#endif
59eda14cbcSMatt Macy		#else
60eda14cbcSMatt Macy		#include <asm/i387.h>
61eda14cbcSMatt Macy		#endif
62eda14cbcSMatt Macy	], [
63eda14cbcSMatt Macy		kernel_fpu_begin();
64eda14cbcSMatt Macy		kernel_fpu_end();
657877fdebSMatt Macy	], [], [ZFS_META_LICENSE])
66eda14cbcSMatt Macy
67eda14cbcSMatt Macy	ZFS_LINUX_TEST_SRC([__kernel_fpu], [
68eda14cbcSMatt Macy		#include <linux/types.h>
69eda14cbcSMatt Macy		#ifdef HAVE_KERNEL_FPU_API_HEADER
70eda14cbcSMatt Macy		#include <asm/fpu/api.h>
71e3aa18adSMartin Matuska		#ifdef HAVE_KERNEL_FPU_INTERNAL_HEADER
72da5137abSMartin Matuska		#include <asm/fpu/internal.h>
73e3aa18adSMartin Matuska		#endif
74eda14cbcSMatt Macy		#else
75eda14cbcSMatt Macy		#include <asm/i387.h>
76eda14cbcSMatt Macy		#endif
77eda14cbcSMatt Macy	], [
78eda14cbcSMatt Macy		__kernel_fpu_begin();
79eda14cbcSMatt Macy		__kernel_fpu_end();
807877fdebSMatt Macy	], [], [ZFS_META_LICENSE])
81eda14cbcSMatt Macy
82*f552d7adSMartin Matuska	ZFS_LINUX_TEST_SRC([kernel_neon], [
83*f552d7adSMartin Matuska		#include <asm/neon.h>
84*f552d7adSMartin Matuska	], [
85*f552d7adSMartin Matuska		kernel_neon_begin();
86*f552d7adSMartin Matuska		kernel_neon_end();
87*f552d7adSMartin Matuska	], [], [ZFS_META_LICENSE])
88eda14cbcSMatt Macy])
89eda14cbcSMatt Macy
90eda14cbcSMatt MacyAC_DEFUN([ZFS_AC_KERNEL_FPU], [
91eda14cbcSMatt Macy	dnl #
92eda14cbcSMatt Macy	dnl # Legacy kernel
93eda14cbcSMatt Macy	dnl #
94eda14cbcSMatt Macy	AC_MSG_CHECKING([whether kernel fpu is available])
95c03c5b1cSMartin Matuska	ZFS_LINUX_TEST_RESULT([kernel_fpu_license], [
96eda14cbcSMatt Macy		AC_MSG_RESULT(kernel_fpu_*)
97eda14cbcSMatt Macy		AC_DEFINE(HAVE_KERNEL_FPU, 1,
98eda14cbcSMatt Macy		    [kernel has kernel_fpu_* functions])
99eda14cbcSMatt Macy		AC_DEFINE(KERNEL_EXPORTS_X86_FPU, 1,
100eda14cbcSMatt Macy		    [kernel exports FPU functions])
101eda14cbcSMatt Macy	],[
102eda14cbcSMatt Macy		dnl #
103eda14cbcSMatt Macy		dnl # Linux 4.2 kernel
104eda14cbcSMatt Macy		dnl #
105eda14cbcSMatt Macy		ZFS_LINUX_TEST_RESULT_SYMBOL([__kernel_fpu_license],
106eda14cbcSMatt Macy		    [__kernel_fpu_begin],
107eda14cbcSMatt Macy		    [arch/x86/kernel/fpu/core.c arch/x86/kernel/i387.c], [
108eda14cbcSMatt Macy			AC_MSG_RESULT(__kernel_fpu_*)
109eda14cbcSMatt Macy			AC_DEFINE(HAVE_UNDERSCORE_KERNEL_FPU, 1,
110eda14cbcSMatt Macy			    [kernel has __kernel_fpu_* functions])
111eda14cbcSMatt Macy			AC_DEFINE(KERNEL_EXPORTS_X86_FPU, 1,
112eda14cbcSMatt Macy			    [kernel exports FPU functions])
113eda14cbcSMatt Macy		],[
114*f552d7adSMartin Matuska			dnl #
115*f552d7adSMartin Matuska			dnl # ARM neon symbols (only on arm and arm64)
116*f552d7adSMartin Matuska			dnl # could be GPL-only on arm64 after Linux 6.2
117*f552d7adSMartin Matuska			dnl #
118*f552d7adSMartin Matuska			ZFS_LINUX_TEST_RESULT([kernel_neon_license],[
119*f552d7adSMartin Matuska				AC_MSG_RESULT(kernel_neon_*)
120*f552d7adSMartin Matuska				AC_DEFINE(HAVE_KERNEL_NEON, 1,
121*f552d7adSMartin Matuska				    [kernel has kernel_neon_* functions])
122*f552d7adSMartin Matuska			],[
123*f552d7adSMartin Matuska				# catch-all
124eda14cbcSMatt Macy				AC_MSG_RESULT(internal)
125eda14cbcSMatt Macy				AC_DEFINE(HAVE_KERNEL_FPU_INTERNAL, 1,
126eda14cbcSMatt Macy				    [kernel fpu internal])
127eda14cbcSMatt Macy			])
128eda14cbcSMatt Macy		])
129c03c5b1cSMartin Matuska	])
130*f552d7adSMartin Matuska])
131