]>
Commit | Line | Data |
---|---|---|
716154c5 BB |
1 | ############################################################################### |
2 | # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. | |
3 | # Copyright (C) 2007 The Regents of the University of California. | |
4 | # Written by Brian Behlendorf <behlendorf1@llnl.gov>. | |
5 | ############################################################################### | |
6 | # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration. | |
7 | ############################################################################### | |
8 | ||
86933a6e BB |
9 | AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ |
10 | SPL_AC_KERNEL | |
11 | ||
86933a6e BB |
12 | if test "${LINUX_OBJ}" != "${LINUX}"; then |
13 | KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" | |
14 | fi | |
86933a6e | 15 | AC_SUBST(KERNELMAKE_PARAMS) |
a7958f7e BB |
16 | |
17 | KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes" | |
86933a6e BB |
18 | AC_SUBST(KERNELCPPFLAGS) |
19 | ||
20 | SPL_AC_DEBUG | |
21 | SPL_AC_DEBUG_KMEM | |
055ffd98 | 22 | SPL_AC_DEBUG_KMEM_TRACKING |
0408008b | 23 | SPL_AC_TEST_MODULE |
5e9b5d83 | 24 | SPL_AC_ATOMIC_SPINLOCK |
c3d9c0df | 25 | SPL_AC_SHRINKER_CALLBACK |
79a3bf13 | 26 | SPL_AC_CTL_NAME |
4b9dddf4 | 27 | SPL_AC_CONFIG_TRIM_UNUSED_KSYMS |
1ddf9722 | 28 | SPL_AC_PDE_DATA |
a54718cf | 29 | SPL_AC_SET_FS_PWD_WITH_CONST |
86933a6e BB |
30 | SPL_AC_2ARGS_VFS_UNLINK |
31 | SPL_AC_4ARGS_VFS_RENAME | |
0d0b5237 | 32 | SPL_AC_2ARGS_VFS_FSYNC |
bbdc6ae4 | 33 | SPL_AC_INODE_TRUNCATE_RANGE |
9b2048c2 | 34 | SPL_AC_FS_STRUCT_SPINLOCK |
f7fd6ddd | 35 | SPL_AC_KUIDGID_T |
1c7b3eaf | 36 | SPL_AC_KERNEL_FALLOCATE |
42b3ce62 BB |
37 | SPL_AC_CONFIG_ZLIB_INFLATE |
38 | SPL_AC_CONFIG_ZLIB_DEFLATE | |
3dfc591a | 39 | SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE |
a55bcaad | 40 | SPL_AC_SHRINK_CONTROL_STRUCT |
588d9004 | 41 | SPL_AC_RWSEM_SPINLOCK_IS_RAW |
f58040c0 | 42 | SPL_AC_RWSEM_ACTIVITY |
b7c7008b | 43 | SPL_AC_RWSEM_ATOMIC_LONG_COUNT |
10087fe1 | 44 | SPL_AC_SCHED_RT_HEADER |
9a054d54 | 45 | SPL_AC_SCHED_SIGNAL_HEADER |
94b1ab2a OF |
46 | SPL_AC_4ARGS_VFS_GETATTR |
47 | SPL_AC_3ARGS_VFS_GETATTR | |
2a305c34 | 48 | SPL_AC_2ARGS_VFS_GETATTR |
184c6873 | 49 | SPL_AC_USLEEP_RANGE |
a073aeb0 | 50 | SPL_AC_KMEM_CACHE_ALLOCFLAGS |
2fc44f66 | 51 | SPL_AC_WAIT_ON_BIT |
cdd39dd2 | 52 | SPL_AC_MUTEX_OWNER |
fdbc1ba9 | 53 | SPL_AC_INODE_LOCK |
ae7eda1d | 54 | SPL_AC_GROUP_INFO_GID |
0194e4a0 | 55 | SPL_AC_KMEM_CACHE_CREATE_USERCOPY |
86933a6e BB |
56 | ]) |
57 | ||
58 | AC_DEFUN([SPL_AC_MODULE_SYMVERS], [ | |
bb339d06 | 59 | modpost=$LINUX/scripts/Makefile.modpost |
86933a6e | 60 | AC_MSG_CHECKING([kernel file name for module symbols]) |
0408008b | 61 | if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then |
bb339d06 BB |
62 | if grep -q Modules.symvers $modpost; then |
63 | LINUX_SYMBOLS=Modules.symvers | |
64 | else | |
65 | LINUX_SYMBOLS=Module.symvers | |
66 | fi | |
912fd84d BB |
67 | |
68 | if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then | |
69 | AC_MSG_ERROR([ | |
70 | *** Please make sure the kernel devel package for your distribution | |
7a8a6393 | 71 | *** is installed. If you are building with a custom kernel, make sure the |
912fd84d BB |
72 | *** kernel is configured, built, and the '--with-linux=PATH' configure |
73 | *** option refers to the location of the kernel source.]) | |
74 | fi | |
86933a6e | 75 | else |
bb339d06 | 76 | LINUX_SYMBOLS=NONE |
86933a6e BB |
77 | fi |
78 | AC_MSG_RESULT($LINUX_SYMBOLS) | |
79 | AC_SUBST(LINUX_SYMBOLS) | |
80 | ]) | |
81 | ||
57d86234 | 82 | AC_DEFUN([SPL_AC_KERNEL], [ |
57d86234 | 83 | AC_ARG_WITH([linux], |
84 | AS_HELP_STRING([--with-linux=PATH], | |
85 | [Path to kernel source]), | |
39a3d2a4 | 86 | [kernelsrc="$withval"]) |
57d86234 | 87 | |
88 | AC_ARG_WITH([linux-obj], | |
89 | AS_HELP_STRING([--with-linux-obj=PATH], | |
90 | [Path to kernel build objects]), | |
91 | [kernelbuild="$withval"]) | |
92 | ||
93 | AC_MSG_CHECKING([kernel source directory]) | |
94 | if test -z "$kernelsrc"; then | |
22ccfaa8 BB |
95 | if test -e "/lib/modules/$(uname -r)/source"; then |
96 | headersdir="/lib/modules/$(uname -r)/source" | |
97 | sourcelink=$(readlink -f "$headersdir") | |
98 | elif test -e "/lib/modules/$(uname -r)/build"; then | |
99 | headersdir="/lib/modules/$(uname -r)/build" | |
534c4e38 BM |
100 | sourcelink=$(readlink -f "$headersdir") |
101 | else | |
102 | sourcelink=$(ls -1d /usr/src/kernels/* \ | |
723aa3b0 | 103 | /usr/src/linux-* \ |
534c4e38 BM |
104 | 2>/dev/null | grep -v obj | tail -1) |
105 | fi | |
57d86234 | 106 | |
8fd4e3af | 107 | if test -n "$sourcelink" && test -e ${sourcelink}; then |
d4326403 | 108 | kernelsrc=`readlink -f ${sourcelink}` |
d4326403 | 109 | else |
251677e9 | 110 | kernelsrc="[Not found]" |
57d86234 | 111 | fi |
c5f70460 BB |
112 | else |
113 | if test "$kernelsrc" = "NONE"; then | |
114 | kernsrcver=NONE | |
115 | fi | |
ac48361c | 116 | withlinux=yes |
57d86234 | 117 | fi |
118 | ||
119 | AC_MSG_RESULT([$kernelsrc]) | |
251677e9 BB |
120 | if test ! -d "$kernelsrc"; then |
121 | AC_MSG_ERROR([ | |
122 | *** Please make sure the kernel devel package for your distribution | |
7a8a6393 | 123 | *** is installed and then try again. If that fails, you can specify the |
251677e9 BB |
124 | *** location of the kernel source with the '--with-linux=PATH' option.]) |
125 | fi | |
126 | ||
57d86234 | 127 | AC_MSG_CHECKING([kernel build directory]) |
39a3d2a4 | 128 | if test -z "$kernelbuild"; then |
ac48361c | 129 | if test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"; then |
22ccfaa8 BB |
130 | kernelbuild=`readlink -f /lib/modules/$(uname -r)/build` |
131 | elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then | |
e2d28a37 BB |
132 | kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} |
133 | elif test -d ${kernelsrc}-obj/${target_cpu}/default; then | |
134 | kernelbuild=${kernelsrc}-obj/${target_cpu}/default | |
135 | elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then | |
136 | kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} | |
39a3d2a4 BB |
137 | else |
138 | kernelbuild=${kernelsrc} | |
139 | fi | |
bf338d8d | 140 | fi |
57d86234 | 141 | AC_MSG_RESULT([$kernelbuild]) |
142 | ||
143 | AC_MSG_CHECKING([kernel source version]) | |
fd921c2e BB |
144 | utsrelease1=$kernelbuild/include/linux/version.h |
145 | utsrelease2=$kernelbuild/include/linux/utsrelease.h | |
146 | utsrelease3=$kernelbuild/include/generated/utsrelease.h | |
147 | if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then | |
148 | utsrelease=linux/version.h | |
149 | elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then | |
150 | utsrelease=linux/utsrelease.h | |
151 | elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then | |
152 | utsrelease=generated/utsrelease.h | |
153 | fi | |
57d86234 | 154 | |
fd921c2e BB |
155 | if test "$utsrelease"; then |
156 | kernsrcver=`(echo "#include <$utsrelease>"; | |
57d86234 | 157 | echo "kernsrcver=UTS_RELEASE") | |
d4326403 | 158 | cpp -I $kernelbuild/include | |
57d86234 | 159 | grep "^kernsrcver=" | cut -d \" -f 2` |
57d86234 | 160 | |
fd921c2e BB |
161 | if test -z "$kernsrcver"; then |
162 | AC_MSG_RESULT([Not found]) | |
163 | AC_MSG_ERROR([*** Cannot determine kernel version.]) | |
164 | fi | |
165 | else | |
57d86234 | 166 | AC_MSG_RESULT([Not found]) |
0408008b ED |
167 | if test "x$enable_linux_builtin" != xyes; then |
168 | AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) | |
169 | else | |
170 | AC_MSG_ERROR([ | |
171 | *** Cannot find UTS_RELEASE definition. | |
172 | *** Please run 'make prepare' inside the kernel source tree.]) | |
173 | fi | |
57d86234 | 174 | fi |
175 | ||
176 | AC_MSG_RESULT([$kernsrcver]) | |
177 | ||
57d86234 | 178 | LINUX=${kernelsrc} |
179 | LINUX_OBJ=${kernelbuild} | |
c5f70460 BB |
180 | LINUX_VERSION=${kernsrcver} |
181 | ||
57d86234 | 182 | AC_SUBST(LINUX) |
183 | AC_SUBST(LINUX_OBJ) | |
c5f70460 | 184 | AC_SUBST(LINUX_VERSION) |
57d86234 | 185 | |
86933a6e | 186 | SPL_AC_MODULE_SYMVERS |
2e0e7e69 BB |
187 | ]) |
188 | ||
287b2fb1 BB |
189 | dnl # |
190 | dnl # Default SPL user configuration | |
191 | dnl # | |
ad35b6a6 | 192 | AC_DEFUN([SPL_AC_CONFIG_USER], []) |
287b2fb1 BB |
193 | |
194 | dnl # | |
195 | dnl # Check for rpm+rpmbuild to build RPM packages. If these tools | |
7a8a6393 | 196 | dnl # are missing, it is non-fatal, but you will not be able to build |
287b2fb1 BB |
197 | dnl # RPM packages and will be warned if you try too. |
198 | dnl # | |
7a8a6393 | 199 | dnl # By default, the generic spec file will be used because it requires |
493972c8 BB |
200 | dnl # minimal dependencies. Distribution specific spec files can be |
201 | dnl # placed under the 'rpm/<distribution>' directory and enabled using | |
202 | dnl # the --with-spec=<distribution> configure option. | |
203 | dnl # | |
287b2fb1 BB |
204 | AC_DEFUN([SPL_AC_RPM], [ |
205 | RPM=rpm | |
206 | RPMBUILD=rpmbuild | |
207 | ||
208 | AC_MSG_CHECKING([whether $RPM is available]) | |
209 | AS_IF([tmp=$($RPM --version 2>/dev/null)], [ | |
210 | RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
211 | HAVE_RPM=yes | |
212 | AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)]) | |
213 | ],[ | |
214 | HAVE_RPM=no | |
215 | AC_MSG_RESULT([$HAVE_RPM]) | |
216 | ]) | |
217 | ||
218 | AC_MSG_CHECKING([whether $RPMBUILD is available]) | |
219 | AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [ | |
220 | RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
221 | HAVE_RPMBUILD=yes | |
222 | AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)]) | |
223 | ],[ | |
224 | HAVE_RPMBUILD=no | |
225 | AC_MSG_RESULT([$HAVE_RPMBUILD]) | |
226 | ]) | |
227 | ||
8d9a23e8 | 228 | RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"' |
493972c8 BB |
229 | RPM_DEFINE_UTIL= |
230 | RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"' | |
231 | RPM_DEFINE_DKMS= | |
232 | ||
233 | SRPM_DEFINE_COMMON='--define "build_src_rpm 1"' | |
234 | SRPM_DEFINE_UTIL= | |
235 | SRPM_DEFINE_KMOD= | |
236 | SRPM_DEFINE_DKMS= | |
237 | ||
238 | RPM_SPEC_DIR="rpm/generic" | |
239 | AC_ARG_WITH([spec], | |
240 | AS_HELP_STRING([--with-spec=SPEC], | |
fade6b00 | 241 | [Spec files 'generic|redhat']), |
493972c8 BB |
242 | [RPM_SPEC_DIR="rpm/$withval"]) |
243 | ||
244 | AC_MSG_CHECKING([whether spec files are available]) | |
245 | AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)]) | |
246 | ||
287b2fb1 BB |
247 | AC_SUBST(HAVE_RPM) |
248 | AC_SUBST(RPM) | |
249 | AC_SUBST(RPM_VERSION) | |
250 | ||
251 | AC_SUBST(HAVE_RPMBUILD) | |
252 | AC_SUBST(RPMBUILD) | |
253 | AC_SUBST(RPMBUILD_VERSION) | |
493972c8 BB |
254 | |
255 | AC_SUBST(RPM_SPEC_DIR) | |
256 | AC_SUBST(RPM_DEFINE_UTIL) | |
257 | AC_SUBST(RPM_DEFINE_KMOD) | |
258 | AC_SUBST(RPM_DEFINE_DKMS) | |
259 | AC_SUBST(RPM_DEFINE_COMMON) | |
260 | AC_SUBST(SRPM_DEFINE_UTIL) | |
261 | AC_SUBST(SRPM_DEFINE_KMOD) | |
262 | AC_SUBST(SRPM_DEFINE_DKMS) | |
263 | AC_SUBST(SRPM_DEFINE_COMMON) | |
287b2fb1 BB |
264 | ]) |
265 | ||
266 | dnl # | |
267 | dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these | |
268 | dnl # tools are missing it is non-fatal but you will not be able to build | |
269 | dnl # DEB packages and will be warned if you try too. | |
270 | dnl # | |
271 | AC_DEFUN([SPL_AC_DPKG], [ | |
272 | DPKG=dpkg | |
273 | DPKGBUILD=dpkg-buildpackage | |
274 | ||
275 | AC_MSG_CHECKING([whether $DPKG is available]) | |
276 | AS_IF([tmp=$($DPKG --version 2>/dev/null)], [ | |
277 | DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }') | |
278 | HAVE_DPKG=yes | |
279 | AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)]) | |
280 | ],[ | |
281 | HAVE_DPKG=no | |
282 | AC_MSG_RESULT([$HAVE_DPKG]) | |
283 | ]) | |
284 | ||
285 | AC_MSG_CHECKING([whether $DPKGBUILD is available]) | |
286 | AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [ | |
287 | DPKGBUILD_VERSION=$(echo $tmp | \ | |
288 | $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.') | |
289 | HAVE_DPKGBUILD=yes | |
290 | AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)]) | |
291 | ],[ | |
292 | HAVE_DPKGBUILD=no | |
293 | AC_MSG_RESULT([$HAVE_DPKGBUILD]) | |
294 | ]) | |
295 | ||
296 | AC_SUBST(HAVE_DPKG) | |
297 | AC_SUBST(DPKG) | |
298 | AC_SUBST(DPKG_VERSION) | |
299 | ||
300 | AC_SUBST(HAVE_DPKGBUILD) | |
301 | AC_SUBST(DPKGBUILD) | |
302 | AC_SUBST(DPKGBUILD_VERSION) | |
303 | ]) | |
304 | ||
305 | dnl # | |
306 | dnl # Until native packaging for various different packing systems | |
307 | dnl # can be added the least we can do is attempt to use alien to | |
308 | dnl # convert the RPM packages to the needed package type. This is | |
309 | dnl # a hack but so far it has worked reasonable well. | |
310 | dnl # | |
311 | AC_DEFUN([SPL_AC_ALIEN], [ | |
312 | ALIEN=alien | |
313 | ||
314 | AC_MSG_CHECKING([whether $ALIEN is available]) | |
315 | AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [ | |
316 | ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }') | |
317 | HAVE_ALIEN=yes | |
318 | AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)]) | |
319 | ],[ | |
320 | HAVE_ALIEN=no | |
321 | AC_MSG_RESULT([$HAVE_ALIEN]) | |
322 | ]) | |
323 | ||
324 | AC_SUBST(HAVE_ALIEN) | |
325 | AC_SUBST(ALIEN) | |
326 | AC_SUBST(ALIEN_VERSION) | |
327 | ]) | |
328 | ||
329 | dnl # | |
330 | dnl # Using the VENDOR tag from config.guess set the default | |
331 | dnl # package type for 'make pkg': (rpm | deb | tgz) | |
332 | dnl # | |
333 | AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [ | |
73fc084e | 334 | AC_MSG_CHECKING([linux distribution]) |
a3a69b74 BB |
335 | if test -f /etc/toss-release ; then |
336 | VENDOR=toss ; | |
73fc084e BB |
337 | elif test -f /etc/fedora-release ; then |
338 | VENDOR=fedora ; | |
a3a69b74 BB |
339 | elif test -f /etc/redhat-release ; then |
340 | VENDOR=redhat ; | |
341 | elif test -f /etc/gentoo-release ; then | |
342 | VENDOR=gentoo ; | |
cd2817f8 PS |
343 | elif test -f /etc/arch-release ; then |
344 | VENDOR=arch ; | |
73fc084e BB |
345 | elif test -f /etc/SuSE-release ; then |
346 | VENDOR=sles ; | |
347 | elif test -f /etc/slackware-version ; then | |
348 | VENDOR=slackware ; | |
a3a69b74 BB |
349 | elif test -f /etc/lunar.release ; then |
350 | VENDOR=lunar ; | |
351 | elif test -f /etc/lsb-release ; then | |
352 | VENDOR=ubuntu ; | |
353 | elif test -f /etc/debian_version ; then | |
354 | VENDOR=debian ; | |
73fc084e BB |
355 | else |
356 | VENDOR= ; | |
357 | fi | |
358 | AC_MSG_RESULT([$VENDOR]) | |
359 | AC_SUBST(VENDOR) | |
287b2fb1 BB |
360 | |
361 | AC_MSG_CHECKING([default package type]) | |
362 | case "$VENDOR" in | |
a3a69b74 BB |
363 | toss) DEFAULT_PACKAGE=rpm ;; |
364 | redhat) DEFAULT_PACKAGE=rpm ;; | |
365 | fedora) DEFAULT_PACKAGE=rpm ;; | |
366 | gentoo) DEFAULT_PACKAGE=tgz ;; | |
5f0a4b08 | 367 | arch) DEFAULT_PACKAGE=tgz ;; |
a3a69b74 BB |
368 | sles) DEFAULT_PACKAGE=rpm ;; |
369 | slackware) DEFAULT_PACKAGE=tgz ;; | |
370 | lunar) DEFAULT_PACKAGE=tgz ;; | |
371 | ubuntu) DEFAULT_PACKAGE=deb ;; | |
372 | debian) DEFAULT_PACKAGE=deb ;; | |
373 | *) DEFAULT_PACKAGE=rpm ;; | |
287b2fb1 BB |
374 | esac |
375 | ||
376 | AC_MSG_RESULT([$DEFAULT_PACKAGE]) | |
377 | AC_SUBST(DEFAULT_PACKAGE) | |
378 | ]) | |
379 | ||
380 | dnl # | |
381 | dnl # Default SPL user configuration | |
382 | dnl # | |
383 | AC_DEFUN([SPL_AC_PACKAGE], [ | |
0b14b9f3 | 384 | SPL_AC_DEFAULT_PACKAGE |
287b2fb1 BB |
385 | SPL_AC_RPM |
386 | SPL_AC_DPKG | |
387 | SPL_AC_ALIEN | |
287b2fb1 BB |
388 | ]) |
389 | ||
6a1c3d41 | 390 | AC_DEFUN([SPL_AC_LICENSE], [ |
62032954 BB |
391 | AC_MSG_CHECKING([spl author]) |
392 | AC_MSG_RESULT([$SPL_META_AUTHOR]) | |
393 | ||
86933a6e | 394 | AC_MSG_CHECKING([spl license]) |
62032954 | 395 | AC_MSG_RESULT([$SPL_META_LICENSE]) |
86933a6e BB |
396 | ]) |
397 | ||
398 | AC_DEFUN([SPL_AC_CONFIG], [ | |
0408008b ED |
399 | SPL_CONFIG=all |
400 | AC_ARG_WITH([config], | |
401 | AS_HELP_STRING([--with-config=CONFIG], | |
402 | [Config file 'kernel|user|all|srpm']), | |
403 | [SPL_CONFIG="$withval"]) | |
404 | AC_ARG_ENABLE([linux-builtin], | |
405 | [AC_HELP_STRING([--enable-linux-builtin], | |
406 | [Configure for builtin in-tree kernel modules @<:@default=no@:>@])], | |
407 | [], | |
408 | [enable_linux_builtin=no]) | |
409 | ||
410 | AC_MSG_CHECKING([spl config]) | |
411 | AC_MSG_RESULT([$SPL_CONFIG]); | |
412 | AC_SUBST(SPL_CONFIG) | |
413 | ||
414 | case "$SPL_CONFIG" in | |
415 | kernel) SPL_AC_CONFIG_KERNEL ;; | |
416 | user) SPL_AC_CONFIG_USER ;; | |
417 | all) SPL_AC_CONFIG_KERNEL | |
418 | SPL_AC_CONFIG_USER ;; | |
c1541dfe | 419 | srpm) ;; |
0408008b ED |
420 | *) |
421 | AC_MSG_RESULT([Error!]) | |
422 | AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config, | |
423 | user kernel|user|all|srpm]) ;; | |
424 | esac | |
425 | ||
426 | AM_CONDITIONAL([CONFIG_USER], | |
427 | [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all]) | |
428 | AM_CONDITIONAL([CONFIG_KERNEL], | |
429 | [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] && | |
430 | [test "x$enable_linux_builtin" != xyes ]) | |
6a1c3d41 | 431 | ]) |
432 | ||
055ffd98 BB |
433 | dnl # |
434 | dnl # Enable if the SPL should be compiled with internal debugging enabled. | |
435 | dnl # By default this support is disabled. | |
436 | dnl # | |
57d86234 | 437 | AC_DEFUN([SPL_AC_DEBUG], [ |
c950d148 | 438 | AC_MSG_CHECKING([whether debugging is enabled]) |
055ffd98 BB |
439 | AC_ARG_ENABLE([debug], |
440 | [AS_HELP_STRING([--enable-debug], | |
441 | [Enable generic debug support @<:@default=no@:>@])], | |
442 | [], | |
443 | [enable_debug=no]) | |
444 | ||
445 | AS_IF([test "x$enable_debug" = xyes], | |
c950d148 | 446 | [ |
c950d148 BB |
447 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" |
448 | DEBUG_CFLAGS="-DDEBUG -Werror" | |
3c208a54 BB |
449 | DEBUG_SPL="_with_debug" |
450 | ], [ | |
c950d148 BB |
451 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" |
452 | DEBUG_CFLAGS="-DNDEBUG" | |
3c208a54 | 453 | DEBUG_SPL="_without_debug" |
c950d148 | 454 | ]) |
055ffd98 | 455 | |
c950d148 | 456 | AC_SUBST(DEBUG_CFLAGS) |
3c208a54 | 457 | AC_SUBST(DEBUG_SPL) |
055ffd98 | 458 | AC_MSG_RESULT([$enable_debug]) |
57d86234 | 459 | ]) |
460 | ||
055ffd98 BB |
461 | dnl # |
462 | dnl # Enabled by default it provides a minimal level of memory tracking. | |
463 | dnl # A total count of bytes allocated is kept for each alloc and free. | |
464 | dnl # Then at module unload time a report to the console will be printed | |
9eb361aa | 465 | dnl # if memory was leaked. |
055ffd98 | 466 | dnl # |
57d86234 | 467 | AC_DEFUN([SPL_AC_DEBUG_KMEM], [ |
055ffd98 BB |
468 | AC_ARG_ENABLE([debug-kmem], |
469 | [AS_HELP_STRING([--enable-debug-kmem], | |
9eb361aa | 470 | [Enable basic kmem accounting @<:@default=no@:>@])], |
055ffd98 | 471 | [], |
9eb361aa | 472 | [enable_debug_kmem=no]) |
57d86234 | 473 | |
055ffd98 | 474 | AS_IF([test "x$enable_debug_kmem" = xyes], |
3c208a54 BB |
475 | [ |
476 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" | |
477 | DEBUG_KMEM="_with_debug_kmem" | |
478 | AC_DEFINE([DEBUG_KMEM], [1], | |
055ffd98 | 479 | [Define to 1 to enable basic kmem accounting]) |
3c208a54 BB |
480 | ], [ |
481 | DEBUG_KMEM="_without_debug_kmem" | |
482 | ]) | |
055ffd98 | 483 | |
3c208a54 | 484 | AC_SUBST(DEBUG_KMEM) |
055ffd98 BB |
485 | AC_MSG_CHECKING([whether basic kmem accounting is enabled]) |
486 | AC_MSG_RESULT([$enable_debug_kmem]) | |
57d86234 | 487 | ]) |
488 | ||
055ffd98 BB |
489 | dnl # |
490 | dnl # Disabled by default it provides detailed memory tracking. This | |
491 | dnl # feature also requires --enable-debug-kmem to be set. When enabled | |
492 | dnl # not only will total bytes be tracked but also the location of every | |
493 | dnl # alloc and free. When the SPL module is unloaded a list of all leaked | |
494 | dnl # addresses and where they were allocated will be dumped to the console. | |
495 | dnl # Enabling this feature has a significant impact on performance but it | |
496 | dnl # makes finding memory leaks pretty straight forward. | |
497 | dnl # | |
498 | AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ | |
499 | AC_ARG_ENABLE([debug-kmem-tracking], | |
500 | [AS_HELP_STRING([--enable-debug-kmem-tracking], | |
501 | [Enable detailed kmem tracking @<:@default=no@:>@])], | |
502 | [], | |
503 | [enable_debug_kmem_tracking=no]) | |
504 | ||
505 | AS_IF([test "x$enable_debug_kmem_tracking" = xyes], | |
3c208a54 BB |
506 | [ |
507 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" | |
508 | DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" | |
509 | AC_DEFINE([DEBUG_KMEM_TRACKING], [1], | |
055ffd98 | 510 | [Define to 1 to enable detailed kmem tracking]) |
3c208a54 BB |
511 | ], [ |
512 | DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" | |
513 | ]) | |
055ffd98 | 514 | |
3c208a54 | 515 | AC_SUBST(DEBUG_KMEM_TRACKING) |
055ffd98 BB |
516 | AC_MSG_CHECKING([whether detailed kmem tracking is enabled]) |
517 | AC_MSG_RESULT([$enable_debug_kmem_tracking]) | |
57d86234 | 518 | ]) |
519 | ||
520 | dnl # | |
521 | dnl # SPL_LINUX_CONFTEST | |
522 | dnl # | |
523 | AC_DEFUN([SPL_LINUX_CONFTEST], [ | |
dbe561d8 | 524 | cat confdefs.h - <<_ACEOF >conftest.c |
57d86234 | 525 | $1 |
526 | _ACEOF | |
527 | ]) | |
528 | ||
529 | dnl # | |
530 | dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY]) | |
531 | dnl # | |
532 | m4_define([SPL_LANG_PROGRAM], [ | |
533 | $1 | |
534 | int | |
535 | main (void) | |
536 | { | |
537 | dnl Do *not* indent the following line: there may be CPP directives. | |
538 | dnl Don't move the `;' right after for the same reason. | |
539 | $2 | |
540 | ; | |
541 | return 0; | |
542 | } | |
543 | ]) | |
544 | ||
545 | dnl # | |
546 | dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE | |
547 | dnl # | |
548 | AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [ | |
c5f70460 | 549 | m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])]) |
df7cc5bc | 550 | rm -Rf build && mkdir -p build && touch build/conftest.mod.c |
c5f70460 | 551 | echo "obj-m := conftest.o" >build/Makefile |
df7cc5bc ED |
552 | modpost_flag='' |
553 | test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage | |
c5f70460 | 554 | AS_IF( |
df7cc5bc ED |
555 | [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])], |
556 | [$4], | |
557 | [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])] | |
c5f70460 BB |
558 | ) |
559 | rm -Rf build | |
57d86234 | 560 | ]) |
561 | ||
562 | dnl # | |
563 | dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE | |
564 | dnl # | |
565 | AC_DEFUN([SPL_LINUX_TRY_COMPILE], | |
566 | [SPL_LINUX_COMPILE_IFELSE( | |
d50bd9e2 | 567 | [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])], |
568 | [modules], | |
569 | [test -s build/conftest.o], | |
570 | [$3], [$4]) | |
57d86234 | 571 | ]) |
572 | ||
57d86234 | 573 | dnl # |
574 | dnl # SPL_CHECK_SYMBOL_EXPORT | |
575 | dnl # check symbol exported or not | |
576 | dnl # | |
723aa3b0 | 577 | AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [ |
2e0e7e69 BB |
578 | grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ |
579 | $LINUX_OBJ/Module*.symvers 2>/dev/null | |
57d86234 | 580 | rc=$? |
581 | if test $rc -ne 0; then | |
582 | export=0 | |
583 | for file in $2; do | |
2e0e7e69 BB |
584 | grep -q -E "EXPORT_SYMBOL.*($1)" \ |
585 | "$LINUX_OBJ/$file" 2>/dev/null | |
57d86234 | 586 | rc=$? |
723aa3b0 ED |
587 | if test $rc -eq 0; then |
588 | export=1 | |
589 | break; | |
590 | fi | |
57d86234 | 591 | done |
723aa3b0 | 592 | if test $export -eq 0; then : |
57d86234 | 593 | $4 |
723aa3b0 | 594 | else : |
57d86234 | 595 | $3 |
596 | fi | |
723aa3b0 | 597 | else : |
57d86234 | 598 | $3 |
599 | fi | |
600 | ]) | |
601 | ||
723aa3b0 ED |
602 | dnl # |
603 | dnl # SPL_LINUX_TRY_COMPILE_SYMBOL | |
604 | dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT | |
605 | dnl # is called if not compiling for builtin | |
606 | dnl # | |
607 | AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [ | |
608 | SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1]) | |
609 | if test $rc -ne 0; then : | |
610 | $6 | |
611 | else | |
612 | if test "x$enable_linux_builtin" != xyes; then | |
613 | SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1]) | |
614 | fi | |
615 | if test $rc -ne 0; then : | |
616 | $6 | |
617 | else : | |
618 | $5 | |
619 | fi | |
620 | fi | |
621 | ]) | |
622 | ||
12ff95ff BB |
623 | dnl # |
624 | dnl # SPL_CHECK_SYMBOL_HEADER | |
625 | dnl # check if a symbol prototype is defined in listed headers. | |
626 | dnl # | |
627 | AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [ | |
628 | AC_MSG_CHECKING([whether symbol $1 exists in header]) | |
629 | header=0 | |
630 | for file in $3; do | |
631 | grep -q "$2" "$LINUX/$file" 2>/dev/null | |
632 | rc=$? | |
723aa3b0 ED |
633 | if test $rc -eq 0; then |
634 | header=1 | |
635 | break; | |
636 | fi | |
12ff95ff BB |
637 | done |
638 | if test $header -eq 0; then | |
639 | AC_MSG_RESULT([no]) | |
640 | $5 | |
641 | else | |
642 | AC_MSG_RESULT([yes]) | |
643 | $4 | |
644 | fi | |
645 | ]) | |
646 | ||
86de8532 | 647 | dnl # |
648 | dnl # SPL_CHECK_HEADER | |
649 | dnl # check whether header exists and define HAVE_$2_HEADER | |
650 | dnl # | |
651 | AC_DEFUN([SPL_CHECK_HEADER], | |
652 | [AC_MSG_CHECKING([whether header $1 exists]) | |
653 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 654 | #include <$1> |
86de8532 | 655 | ],[ |
656 | return 0; | |
657 | ],[ | |
658 | AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists]) | |
659 | AC_MSG_RESULT(yes) | |
660 | $3 | |
661 | ],[ | |
662 | AC_MSG_RESULT(no) | |
663 | $4 | |
664 | ]) | |
665 | ]) | |
6a6cafbe | 666 | |
0408008b | 667 | dnl # |
62032954 BB |
668 | dnl # Basic toolchain sanity check. Verify that kernel modules can |
669 | dnl # be built and which symbols can be used. | |
0408008b ED |
670 | dnl # |
671 | AC_DEFUN([SPL_AC_TEST_MODULE], | |
672 | [AC_MSG_CHECKING([whether modules can be built]) | |
673 | SPL_LINUX_TRY_COMPILE([],[],[ | |
674 | AC_MSG_RESULT([yes]) | |
675 | ],[ | |
676 | AC_MSG_RESULT([no]) | |
677 | if test "x$enable_linux_builtin" != xyes; then | |
678 | AC_MSG_ERROR([*** Unable to build an empty module.]) | |
679 | else | |
680 | AC_MSG_ERROR([ | |
681 | *** Unable to build an empty module. | |
682 | *** Please run 'make scripts' inside the kernel source tree.]) | |
683 | fi | |
684 | ]) | |
62032954 | 685 | |
e0ed96fa KD |
686 | AS_IF([test "x$cross_compiling" != xyes], [ |
687 | AC_RUN_IFELSE([ | |
688 | AC_LANG_PROGRAM([ | |
689 | #include "$LINUX/include/linux/license.h" | |
690 | ], [ | |
691 | return !license_is_gpl_compatible( | |
692 | "$SPL_META_LICENSE"); | |
693 | ]) | |
694 | ], [ | |
695 | AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1], | |
696 | [Define to 1 if GPL-only symbols can be used]) | |
62032954 | 697 | ], [ |
62032954 | 698 | ]) |
62032954 | 699 | ]) |
0408008b ED |
700 | ]) |
701 | ||
57d86234 | 702 | dnl # |
d04c8a56 BB |
703 | dnl # Use the atomic implemenation based on global spinlocks. This |
704 | dnl # should only be needed by 32-bit kernels which do not provide | |
705 | dnl # the atomic64_* API. It may be optionally enabled as a fallback | |
706 | dnl # if problems are observed with the direct mapping to the native | |
707 | dnl # Linux atomic operations. You may not disable atomic spinlocks | |
708 | dnl # if you kernel does not an atomic64_* API. | |
57d86234 | 709 | dnl # |
d04c8a56 BB |
710 | AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [ |
711 | AC_ARG_ENABLE([atomic-spinlocks], | |
712 | [AS_HELP_STRING([--enable-atomic-spinlocks], | |
713 | [Atomic types use spinlocks @<:@default=check@:>@])], | |
714 | [], | |
715 | [enable_atomic_spinlocks=check]) | |
57d86234 | 716 | |
a0f6da3d | 717 | SPL_LINUX_TRY_COMPILE([ |
dd3678fc | 718 | #include <linux/fs.h> |
a0f6da3d | 719 | ],[ |
03318641 | 720 | atomic64_t *ptr __attribute__ ((unused)); |
a0f6da3d | 721 | ],[ |
d04c8a56 | 722 | have_atomic64_t=yes |
a0f6da3d | 723 | AC_DEFINE(HAVE_ATOMIC64_T, 1, |
d04c8a56 | 724 | [kernel defines atomic64_t]) |
a0f6da3d | 725 | ],[ |
d04c8a56 BB |
726 | have_atomic64_t=no |
727 | ]) | |
728 | ||
729 | AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [ | |
730 | AS_IF([test "x$have_atomic64_t" = xyes], [ | |
731 | enable_atomic_spinlocks=no | |
732 | ],[ | |
733 | enable_atomic_spinlocks=yes | |
734 | ]) | |
a0f6da3d | 735 | ]) |
d04c8a56 BB |
736 | |
737 | AS_IF([test "x$enable_atomic_spinlocks" = xyes], [ | |
738 | AC_DEFINE([ATOMIC_SPINLOCK], [1], | |
739 | [Atomic types use spinlocks]) | |
740 | ],[ | |
741 | AS_IF([test "x$have_atomic64_t" = xno], [ | |
742 | AC_MSG_FAILURE( | |
743 | [--disable-atomic-spinlocks given but required atomic64 support is unavailable]) | |
744 | ]) | |
745 | ]) | |
746 | ||
747 | AC_MSG_CHECKING([whether atomic types use spinlocks]) | |
748 | AC_MSG_RESULT([$enable_atomic_spinlocks]) | |
749 | ||
750 | AC_MSG_CHECKING([whether kernel defines atomic64_t]) | |
751 | AC_MSG_RESULT([$have_atomic64_t]) | |
a0f6da3d | 752 | ]) |
753 | ||
c3d9c0df | 754 | AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[ |
23aa63cb BB |
755 | tmp_flags="$EXTRA_KCFLAGS" |
756 | EXTRA_KCFLAGS="-Werror" | |
c3d9c0df RY |
757 | dnl # |
758 | dnl # 2.6.23 to 2.6.34 API change | |
759 | dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask) | |
760 | dnl # | |
761 | AC_MSG_CHECKING([whether old 2-argument shrinker exists]) | |
23aa63cb BB |
762 | SPL_LINUX_TRY_COMPILE([ |
763 | #include <linux/mm.h> | |
764 | ||
c3d9c0df | 765 | int shrinker_cb(int nr_to_scan, gfp_t gfp_mask); |
23aa63cb BB |
766 | ],[ |
767 | struct shrinker cache_shrinker = { | |
768 | .shrink = shrinker_cb, | |
769 | .seeks = DEFAULT_SEEKS, | |
770 | }; | |
771 | register_shrinker(&cache_shrinker); | |
772 | ],[ | |
773 | AC_MSG_RESULT(yes) | |
c3d9c0df RY |
774 | AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1, |
775 | [old shrinker callback wants 2 args]) | |
23aa63cb BB |
776 | ],[ |
777 | AC_MSG_RESULT(no) | |
c3d9c0df RY |
778 | dnl # |
779 | dnl # 2.6.35 - 2.6.39 API change | |
780 | dnl # ->shrink(struct shrinker *, | |
781 | dnl # int nr_to_scan, gfp_t gfp_mask) | |
782 | dnl # | |
783 | AC_MSG_CHECKING([whether old 3-argument shrinker exists]) | |
784 | SPL_LINUX_TRY_COMPILE([ | |
785 | #include <linux/mm.h> | |
786 | ||
787 | int shrinker_cb(struct shrinker *, int nr_to_scan, | |
788 | gfp_t gfp_mask); | |
789 | ],[ | |
790 | struct shrinker cache_shrinker = { | |
791 | .shrink = shrinker_cb, | |
792 | .seeks = DEFAULT_SEEKS, | |
793 | }; | |
794 | register_shrinker(&cache_shrinker); | |
795 | ],[ | |
796 | AC_MSG_RESULT(yes) | |
797 | AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1, | |
798 | [old shrinker callback wants 3 args]) | |
799 | ],[ | |
800 | AC_MSG_RESULT(no) | |
801 | dnl # | |
802 | dnl # 3.0 - 3.11 API change | |
803 | dnl # ->shrink(struct shrinker *, | |
804 | dnl # struct shrink_control *sc) | |
805 | dnl # | |
806 | AC_MSG_CHECKING( | |
807 | [whether new 2-argument shrinker exists]) | |
808 | SPL_LINUX_TRY_COMPILE([ | |
809 | #include <linux/mm.h> | |
810 | ||
811 | int shrinker_cb(struct shrinker *, | |
812 | struct shrink_control *sc); | |
813 | ],[ | |
814 | struct shrinker cache_shrinker = { | |
815 | .shrink = shrinker_cb, | |
816 | .seeks = DEFAULT_SEEKS, | |
817 | }; | |
818 | register_shrinker(&cache_shrinker); | |
819 | ],[ | |
820 | AC_MSG_RESULT(yes) | |
821 | AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1, | |
822 | [new shrinker callback wants 2 args]) | |
823 | ],[ | |
824 | AC_MSG_RESULT(no) | |
825 | dnl # | |
826 | dnl # 3.12 API change, | |
827 | dnl # ->shrink() is logically split in to | |
828 | dnl # ->count_objects() and ->scan_objects() | |
829 | dnl # | |
830 | AC_MSG_CHECKING( | |
831 | [whether ->count_objects callback exists]) | |
832 | SPL_LINUX_TRY_COMPILE([ | |
833 | #include <linux/mm.h> | |
834 | ||
835 | unsigned long shrinker_cb( | |
836 | struct shrinker *, | |
837 | struct shrink_control *sc); | |
838 | ],[ | |
839 | struct shrinker cache_shrinker = { | |
840 | .count_objects = shrinker_cb, | |
841 | .scan_objects = shrinker_cb, | |
842 | .seeks = DEFAULT_SEEKS, | |
843 | }; | |
844 | register_shrinker(&cache_shrinker); | |
845 | ],[ | |
846 | AC_MSG_RESULT(yes) | |
847 | AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, | |
848 | 1, [->count_objects exists]) | |
849 | ],[ | |
850 | AC_MSG_ERROR(error) | |
851 | ]) | |
852 | ]) | |
853 | ]) | |
23aa63cb BB |
854 | ]) |
855 | EXTRA_KCFLAGS="$tmp_flags" | |
856 | ]) | |
857 | ||
79a3bf13 BB |
858 | dnl # |
859 | dnl # 2.6.33 API change, | |
860 | dnl # Removed .ctl_name from struct ctl_table. | |
861 | dnl # | |
862 | AC_DEFUN([SPL_AC_CTL_NAME], [ | |
863 | AC_MSG_CHECKING([whether struct ctl_table has ctl_name]) | |
864 | SPL_LINUX_TRY_COMPILE([ | |
865 | #include <linux/sysctl.h> | |
866 | ],[ | |
03318641 | 867 | struct ctl_table ctl __attribute__ ((unused)); |
79a3bf13 BB |
868 | ctl.ctl_name = 0; |
869 | ],[ | |
870 | AC_MSG_RESULT(yes) | |
871 | AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name]) | |
872 | ],[ | |
873 | AC_MSG_RESULT(no) | |
874 | ]) | |
875 | ]) | |
876 | ||
1ddf9722 YS |
877 | dnl # |
878 | dnl # 3.10 API change, | |
879 | dnl # PDE is replaced by PDE_DATA | |
880 | dnl # | |
881 | AC_DEFUN([SPL_AC_PDE_DATA], [ | |
882 | AC_MSG_CHECKING([whether PDE_DATA() is available]) | |
883 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
884 | #include <linux/proc_fs.h> | |
885 | ], [ | |
886 | PDE_DATA(NULL); | |
887 | ], [PDE_DATA], [], [ | |
888 | AC_MSG_RESULT(yes) | |
889 | AC_DEFINE(HAVE_PDE_DATA, 1, [yes]) | |
890 | ],[ | |
891 | AC_MSG_RESULT(no) | |
892 | ]) | |
893 | ]) | |
894 | ||
a54718cf RY |
895 | dnl # |
896 | dnl # 3.9 API change | |
897 | dnl # set_fs_pwd takes const struct path * | |
898 | dnl # | |
899 | AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST], | |
a54718cf RY |
900 | tmp_flags="$EXTRA_KCFLAGS" |
901 | EXTRA_KCFLAGS="-Werror" | |
902 | [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *]) | |
903 | SPL_LINUX_TRY_COMPILE([ | |
904 | #include <linux/spinlock.h> | |
905 | #include <linux/fs_struct.h> | |
906 | #include <linux/path.h> | |
907 | void (*const set_fs_pwd_func) | |
908 | (struct fs_struct *, const struct path *) | |
909 | = set_fs_pwd; | |
910 | ],[ | |
911 | return 0; | |
912 | ],[ | |
913 | AC_MSG_RESULT(yes) | |
914 | AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1, | |
915 | [set_fs_pwd() needs const path *]) | |
916 | ],[ | |
917 | SPL_LINUX_TRY_COMPILE([ | |
918 | #include <linux/spinlock.h> | |
919 | #include <linux/fs_struct.h> | |
920 | #include <linux/path.h> | |
921 | void (*const set_fs_pwd_func) | |
922 | (struct fs_struct *, struct path *) | |
923 | = set_fs_pwd; | |
924 | ],[ | |
925 | return 0; | |
926 | ],[ | |
927 | AC_MSG_RESULT(no) | |
928 | ],[ | |
929 | AC_MSG_ERROR(unknown) | |
930 | ]) | |
931 | ]) | |
932 | EXTRA_KCFLAGS="$tmp_flags" | |
a54718cf RY |
933 | ]) |
934 | ||
e39174ed BB |
935 | dnl # |
936 | dnl # 3.13 API change | |
937 | dnl # vfs_unlink() updated to take a third delegated_inode argument. | |
938 | dnl # | |
a093c6a4 BB |
939 | AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK], |
940 | [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args]) | |
941 | SPL_LINUX_TRY_COMPILE([ | |
942 | #include <linux/fs.h> | |
943 | ],[ | |
50a0749e | 944 | vfs_unlink((struct inode *) NULL, (struct dentry *) NULL); |
a093c6a4 BB |
945 | ],[ |
946 | AC_MSG_RESULT(yes) | |
947 | AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1, | |
948 | [vfs_unlink() wants 2 args]) | |
949 | ],[ | |
950 | AC_MSG_RESULT(no) | |
50a0749e RY |
951 | dnl # |
952 | dnl # Linux 3.13 API change | |
953 | dnl # Added delegated inode | |
954 | dnl # | |
955 | AC_MSG_CHECKING([whether vfs_unlink() wants 3 args]) | |
956 | SPL_LINUX_TRY_COMPILE([ | |
957 | #include <linux/fs.h> | |
958 | ],[ | |
959 | vfs_unlink((struct inode *) NULL, | |
960 | (struct dentry *) NULL, | |
961 | (struct inode **) NULL); | |
962 | ],[ | |
963 | AC_MSG_RESULT(yes) | |
964 | AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1, | |
965 | [vfs_unlink() wants 3 args]) | |
966 | ],[ | |
967 | AC_MSG_ERROR(no) | |
968 | ]) | |
969 | ||
a093c6a4 BB |
970 | ]) |
971 | ]) | |
972 | ||
e39174ed BB |
973 | dnl # |
974 | dnl # 3.13 and 3.15 API changes | |
975 | dnl # Added delegated inode and flags argument. | |
976 | dnl # | |
a093c6a4 BB |
977 | AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME], |
978 | [AC_MSG_CHECKING([whether vfs_rename() wants 4 args]) | |
979 | SPL_LINUX_TRY_COMPILE([ | |
980 | #include <linux/fs.h> | |
981 | ],[ | |
50a0749e RY |
982 | vfs_rename((struct inode *) NULL, (struct dentry *) NULL, |
983 | (struct inode *) NULL, (struct dentry *) NULL); | |
a093c6a4 BB |
984 | ],[ |
985 | AC_MSG_RESULT(yes) | |
986 | AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1, | |
987 | [vfs_rename() wants 4 args]) | |
988 | ],[ | |
989 | AC_MSG_RESULT(no) | |
50a0749e RY |
990 | dnl # |
991 | dnl # Linux 3.13 API change | |
992 | dnl # Added delegated inode | |
993 | dnl # | |
994 | AC_MSG_CHECKING([whether vfs_rename() wants 5 args]) | |
995 | SPL_LINUX_TRY_COMPILE([ | |
996 | #include <linux/fs.h> | |
997 | ],[ | |
998 | vfs_rename((struct inode *) NULL, | |
999 | (struct dentry *) NULL, | |
1000 | (struct inode *) NULL, | |
1001 | (struct dentry *) NULL, | |
1002 | (struct inode **) NULL); | |
1003 | ],[ | |
1004 | AC_MSG_RESULT(yes) | |
1005 | AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1, | |
1006 | [vfs_rename() wants 5 args]) | |
1007 | ],[ | |
ad3412ef CC |
1008 | AC_MSG_RESULT(no) |
1009 | dnl # | |
1010 | dnl # Linux 3.15 API change | |
1011 | dnl # Added flags | |
1012 | dnl # | |
1013 | AC_MSG_CHECKING([whether vfs_rename() wants 6 args]) | |
1014 | SPL_LINUX_TRY_COMPILE([ | |
1015 | #include <linux/fs.h> | |
1016 | ],[ | |
1017 | vfs_rename((struct inode *) NULL, | |
1018 | (struct dentry *) NULL, | |
1019 | (struct inode *) NULL, | |
1020 | (struct dentry *) NULL, | |
1021 | (struct inode **) NULL, | |
1022 | (unsigned int) 0); | |
1023 | ],[ | |
1024 | AC_MSG_RESULT(yes) | |
1025 | AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1, | |
1026 | [vfs_rename() wants 6 args]) | |
1027 | ],[ | |
1028 | AC_MSG_ERROR(no) | |
1029 | ]) | |
50a0749e | 1030 | ]) |
a093c6a4 BB |
1031 | ]) |
1032 | ]) | |
ec7d53e9 | 1033 | |
9b2048c2 BB |
1034 | dnl # |
1035 | dnl # 2.6.36 API change, | |
1036 | dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to | |
1037 | dnl # a spinlock_t to improve the fastpath performance. | |
1038 | dnl # | |
1039 | AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [ | |
1040 | AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t]) | |
97fd6a07 BB |
1041 | tmp_flags="$EXTRA_KCFLAGS" |
1042 | EXTRA_KCFLAGS="-Werror" | |
9b2048c2 BB |
1043 | SPL_LINUX_TRY_COMPILE([ |
1044 | #include <linux/sched.h> | |
1045 | #include <linux/fs_struct.h> | |
1046 | ],[ | |
abb642b9 | 1047 | static struct fs_struct fs; |
9b2048c2 BB |
1048 | spin_lock_init(&fs.lock); |
1049 | ],[ | |
1050 | AC_MSG_RESULT(yes) | |
1051 | AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1, | |
1052 | [struct fs_struct uses spinlock_t]) | |
1053 | ],[ | |
1054 | AC_MSG_RESULT(no) | |
1055 | ]) | |
97fd6a07 | 1056 | EXTRA_KCFLAGS="$tmp_flags" |
9b2048c2 BB |
1057 | ]) |
1058 | ||
f7fd6ddd RY |
1059 | dnl # |
1060 | dnl # User namespaces, use kuid_t in place of uid_t | |
1061 | dnl # where available. Not strictly a user namespaces thing | |
1062 | dnl # but it should prevent surprises | |
1063 | dnl # | |
1064 | AC_DEFUN([SPL_AC_KUIDGID_T], [ | |
1065 | AC_MSG_CHECKING([whether kuid_t/kgid_t is available]) | |
1066 | SPL_LINUX_TRY_COMPILE([ | |
1067 | #include <linux/uidgid.h> | |
1068 | ], [ | |
1069 | kuid_t userid = KUIDT_INIT(0); | |
1070 | kgid_t groupid = KGIDT_INIT(0); | |
1071 | ],[ | |
1072 | SPL_LINUX_TRY_COMPILE([ | |
1073 | #include <linux/uidgid.h> | |
1074 | ], [ | |
1075 | kuid_t userid = 0; | |
1076 | kgid_t groupid = 0; | |
1077 | ],[ | |
1078 | AC_MSG_RESULT(yes; optional) | |
1079 | ],[ | |
1080 | AC_MSG_RESULT(yes; mandatory) | |
1081 | AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use]) | |
1082 | ]) | |
1083 | ],[ | |
1084 | AC_MSG_RESULT(no) | |
1085 | ]) | |
1086 | ]) | |
1087 | ||
f0ff89fc BB |
1088 | dnl # |
1089 | dnl # 2.6.35 API change, | |
0d0b5237 | 1090 | dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype. |
f0ff89fc | 1091 | dnl # |
0d0b5237 BB |
1092 | AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [ |
1093 | AC_MSG_CHECKING([whether vfs_fsync() wants 2 args]) | |
f0ff89fc | 1094 | SPL_LINUX_TRY_COMPILE([ |
0d0b5237 | 1095 | #include <linux/fs.h> |
f0ff89fc | 1096 | ],[ |
0d0b5237 | 1097 | vfs_fsync(NULL, 0); |
f0ff89fc BB |
1098 | ],[ |
1099 | AC_MSG_RESULT(yes) | |
0d0b5237 | 1100 | AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args]) |
f0ff89fc BB |
1101 | ],[ |
1102 | AC_MSG_RESULT(no) | |
1103 | ]) | |
1104 | ]) | |
46aa7b39 | 1105 | |
bbdc6ae4 ED |
1106 | dnl # |
1107 | dnl # 3.5 API change, | |
1108 | dnl # inode_operations.truncate_range removed | |
bbdc6ae4 ED |
1109 | dnl # |
1110 | AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [ | |
1111 | AC_MSG_CHECKING([whether truncate_range() inode operation is available]) | |
1112 | SPL_LINUX_TRY_COMPILE([ | |
1113 | #include <linux/fs.h> | |
1114 | ],[ | |
1115 | struct inode_operations ops; | |
1116 | ops.truncate_range = NULL; | |
1117 | ],[ | |
1118 | AC_MSG_RESULT(yes) | |
1119 | AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1, | |
1120 | [truncate_range() inode operation is available]) | |
1121 | ],[ | |
1122 | AC_MSG_RESULT(no) | |
1123 | ]) | |
1c7b3eaf BB |
1124 | ]) |
1125 | ||
1126 | dnl # | |
1127 | dnl # Linux 2.6.38 - 3.x API | |
1128 | dnl # | |
1129 | AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [ | |
1130 | AC_MSG_CHECKING([whether fops->fallocate() exists]) | |
1131 | SPL_LINUX_TRY_COMPILE([ | |
1132 | #include <linux/fs.h> | |
1133 | ],[ | |
1134 | long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; | |
1135 | struct file_operations fops __attribute__ ((unused)) = { | |
1136 | .fallocate = fallocate, | |
1137 | }; | |
1138 | ],[ | |
1139 | AC_MSG_RESULT(yes) | |
1140 | AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1141 | ],[ | |
1142 | AC_MSG_RESULT(no) | |
1143 | ]) | |
1144 | ]) | |
1145 | ||
1146 | dnl # | |
1147 | dnl # Linux 2.6.x - 2.6.37 API | |
1148 | dnl # | |
1149 | AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [ | |
1150 | AC_MSG_CHECKING([whether iops->fallocate() exists]) | |
1151 | SPL_LINUX_TRY_COMPILE([ | |
1152 | #include <linux/fs.h> | |
1153 | ],[ | |
1154 | long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL; | |
1155 | struct inode_operations fops __attribute__ ((unused)) = { | |
1156 | .fallocate = fallocate, | |
1157 | }; | |
1158 | ],[ | |
1159 | AC_MSG_RESULT(yes) | |
1160 | AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1161 | ],[ | |
1162 | AC_MSG_RESULT(no) | |
1163 | ]) | |
1164 | ]) | |
1165 | ||
1166 | dnl # | |
1167 | dnl # PaX Linux 2.6.38 - 3.x API | |
1168 | dnl # | |
1169 | AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [ | |
1170 | AC_MSG_CHECKING([whether fops->fallocate() exists]) | |
1171 | SPL_LINUX_TRY_COMPILE([ | |
1172 | #include <linux/fs.h> | |
1173 | ],[ | |
1174 | long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; | |
1175 | struct file_operations_no_const fops __attribute__ ((unused)) = { | |
1176 | .fallocate = fallocate, | |
1177 | }; | |
1178 | ],[ | |
1179 | AC_MSG_RESULT(yes) | |
1180 | AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1181 | ],[ | |
1182 | AC_MSG_RESULT(no) | |
1183 | ]) | |
1184 | ]) | |
1185 | ||
1186 | dnl # | |
1187 | dnl # The fallocate callback was moved from the inode_operations | |
1188 | dnl # structure to the file_operations structure. | |
1189 | dnl # | |
1190 | AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [ | |
1191 | SPL_AC_KERNEL_FILE_FALLOCATE | |
1192 | SPL_AC_KERNEL_INODE_FALLOCATE | |
1193 | SPL_AC_PAX_KERNEL_FILE_FALLOCATE | |
1194 | ]) | |
bbdc6ae4 | 1195 | |
42b3ce62 BB |
1196 | dnl # |
1197 | dnl # zlib inflate compat, | |
1198 | dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled. | |
1199 | dnl # | |
1200 | AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [ | |
1201 | AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined]) | |
1202 | SPL_LINUX_TRY_COMPILE([ | |
1203 | #if !defined(CONFIG_ZLIB_INFLATE) && \ | |
1204 | !defined(CONFIG_ZLIB_INFLATE_MODULE) | |
1205 | #error CONFIG_ZLIB_INFLATE not defined | |
1206 | #endif | |
1207 | ],[ ],[ | |
1208 | AC_MSG_RESULT([yes]) | |
1209 | ],[ | |
1210 | AC_MSG_RESULT([no]) | |
1211 | AC_MSG_ERROR([ | |
1212 | *** This kernel does not include the required zlib inflate support. | |
1213 | *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.]) | |
1214 | ]) | |
1215 | ]) | |
1216 | ||
1217 | dnl # | |
1218 | dnl # zlib deflate compat, | |
1219 | dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled. | |
1220 | dnl # | |
1221 | AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [ | |
1222 | AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined]) | |
1223 | SPL_LINUX_TRY_COMPILE([ | |
1224 | #if !defined(CONFIG_ZLIB_DEFLATE) && \ | |
1225 | !defined(CONFIG_ZLIB_DEFLATE_MODULE) | |
1226 | #error CONFIG_ZLIB_DEFLATE not defined | |
1227 | #endif | |
1228 | ],[ ],[ | |
1229 | AC_MSG_RESULT([yes]) | |
1230 | ],[ | |
1231 | AC_MSG_RESULT([no]) | |
1232 | AC_MSG_ERROR([ | |
1233 | *** This kernel does not include the required zlib deflate support. | |
1234 | *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.]) | |
1235 | ]) | |
1236 | ]) | |
1237 | ||
4b9dddf4 NB |
1238 | dnl # |
1239 | dnl # config trim unused symbols, | |
1240 | dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED. | |
1241 | dnl # | |
1242 | AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [ | |
1243 | AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled]) | |
1244 | SPL_LINUX_TRY_COMPILE([ | |
1245 | #if defined(CONFIG_TRIM_UNUSED_KSYMS) | |
1246 | #error CONFIG_TRIM_UNUSED_KSYMS not defined | |
1247 | #endif | |
1248 | ],[ ],[ | |
1249 | AC_MSG_RESULT([yes]) | |
1250 | ],[ | |
1251 | AC_MSG_RESULT([no]) | |
1252 | AC_MSG_ERROR([ | |
1253 | *** This kernel has unused symbols trimming enabled, please disable. | |
1254 | *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.]) | |
1255 | ]) | |
1256 | ]) | |
1257 | ||
3dfc591a BB |
1258 | dnl # |
1259 | dnl # 2.6.39 API compat, | |
1260 | dnl # The function zlib_deflate_workspacesize() now take 2 arguments. | |
1261 | dnl # This was done to avoid always having to allocate the maximum size | |
1262 | dnl # workspace (268K). The caller can now specific the windowBits and | |
1263 | dnl # memLevel compression parameters to get a smaller workspace. | |
1264 | dnl # | |
1265 | AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE], | |
1266 | [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args]) | |
1267 | SPL_LINUX_TRY_COMPILE([ | |
1268 | #include <linux/zlib.h> | |
1269 | ],[ | |
1270 | return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL); | |
1271 | ],[ | |
1272 | AC_MSG_RESULT(yes) | |
1273 | AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1, | |
1274 | [zlib_deflate_workspacesize() wants 2 args]) | |
1275 | ],[ | |
1276 | AC_MSG_RESULT(no) | |
1277 | ]) | |
1278 | ]) | |
a55bcaad BB |
1279 | |
1280 | dnl # | |
1281 | dnl # 2.6.39 API change, | |
1282 | dnl # Shrinker adjust to use common shrink_control structure. | |
1283 | dnl # | |
1284 | AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [ | |
1285 | AC_MSG_CHECKING([whether struct shrink_control exists]) | |
1286 | SPL_LINUX_TRY_COMPILE([ | |
1287 | #include <linux/mm.h> | |
1288 | ],[ | |
1289 | struct shrink_control sc __attribute__ ((unused)); | |
1290 | ||
1291 | sc.nr_to_scan = 0; | |
1292 | sc.gfp_mask = GFP_KERNEL; | |
1293 | ],[ | |
1294 | AC_MSG_RESULT(yes) | |
1295 | AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1, | |
1296 | [struct shrink_control exists]) | |
1297 | ],[ | |
1298 | AC_MSG_RESULT(no) | |
1299 | ]) | |
1300 | ]) | |
588d9004 DH |
1301 | |
1302 | dnl # | |
1303 | dnl # 3.1 API Change | |
1304 | dnl # | |
1305 | dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to | |
1306 | dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1. | |
1307 | dnl # | |
1308 | AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [ | |
1309 | AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw]) | |
1310 | tmp_flags="$EXTRA_KCFLAGS" | |
1311 | EXTRA_KCFLAGS="-Werror" | |
1312 | SPL_LINUX_TRY_COMPILE([ | |
1313 | #include <linux/rwsem.h> | |
1314 | ],[ | |
1315 | struct rw_semaphore dummy_semaphore __attribute__ ((unused)); | |
7a35f2b4 CC |
1316 | raw_spinlock_t dummy_lock __attribute__ ((unused)) = |
1317 | __RAW_SPIN_LOCK_INITIALIZER(dummy_lock); | |
588d9004 DH |
1318 | dummy_semaphore.wait_lock = dummy_lock; |
1319 | ],[ | |
1320 | AC_MSG_RESULT(yes) | |
1321 | AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1, | |
1322 | [struct rw_semaphore member wait_lock is raw_spinlock_t]) | |
1323 | ],[ | |
1324 | AC_MSG_RESULT(no) | |
1325 | ]) | |
1326 | EXTRA_KCFLAGS="$tmp_flags" | |
1327 | ]) | |
10087fe1 | 1328 | |
f58040c0 CC |
1329 | dnl # |
1330 | dnl # 3.16 API Change | |
1331 | dnl # | |
1332 | dnl # rwsem-spinlock "->activity" changed to "->count" | |
1333 | dnl # | |
1334 | AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [ | |
1335 | AC_MSG_CHECKING([whether struct rw_semaphore has member activity]) | |
1336 | tmp_flags="$EXTRA_KCFLAGS" | |
1337 | EXTRA_KCFLAGS="-Werror" | |
1338 | SPL_LINUX_TRY_COMPILE([ | |
1339 | #include <linux/rwsem.h> | |
1340 | ],[ | |
1341 | struct rw_semaphore dummy_semaphore __attribute__ ((unused)); | |
1342 | dummy_semaphore.activity = 0; | |
1343 | ],[ | |
1344 | AC_MSG_RESULT(yes) | |
1345 | AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1, | |
1346 | [struct rw_semaphore has member activity]) | |
1347 | ],[ | |
1348 | AC_MSG_RESULT(no) | |
1349 | ]) | |
1350 | EXTRA_KCFLAGS="$tmp_flags" | |
1351 | ]) | |
1352 | ||
b7c7008b BB |
1353 | dnl # |
1354 | dnl # 4.8 API Change | |
1355 | dnl # | |
1356 | dnl # rwsem "->count" changed to atomic_long_t type | |
1357 | dnl # | |
1358 | AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [ | |
1359 | AC_MSG_CHECKING( | |
1360 | [whether struct rw_semaphore has atomic_long_t member count]) | |
1361 | tmp_flags="$EXTRA_KCFLAGS" | |
1362 | EXTRA_KCFLAGS="-Werror" | |
1363 | SPL_LINUX_TRY_COMPILE([ | |
1364 | #include <linux/rwsem.h> | |
1365 | ],[ | |
1366 | DECLARE_RWSEM(dummy_semaphore); | |
1367 | (void) atomic_long_read(&dummy_semaphore.count); | |
1368 | ],[ | |
1369 | AC_MSG_RESULT(yes) | |
1370 | AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1, | |
1371 | [struct rw_semaphore has atomic_long_t member count]) | |
1372 | ],[ | |
1373 | AC_MSG_RESULT(no) | |
1374 | ]) | |
1375 | EXTRA_KCFLAGS="$tmp_flags" | |
1376 | ]) | |
1377 | ||
10087fe1 RY |
1378 | dnl # |
1379 | dnl # 3.9 API change, | |
1380 | dnl # Moved things from linux/sched.h to linux/sched/rt.h | |
1381 | dnl # | |
1382 | AC_DEFUN([SPL_AC_SCHED_RT_HEADER], | |
1383 | [AC_MSG_CHECKING([whether header linux/sched/rt.h exists]) | |
1384 | SPL_LINUX_TRY_COMPILE([ | |
1385 | #include <linux/sched.h> | |
1386 | #include <linux/sched/rt.h> | |
1387 | ],[ | |
1388 | return 0; | |
1389 | ],[ | |
1390 | AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists]) | |
1391 | AC_MSG_RESULT(yes) | |
1392 | ],[ | |
1393 | AC_MSG_RESULT(no) | |
1394 | ]) | |
1395 | ]) | |
2a305c34 | 1396 | |
9a054d54 OF |
1397 | dnl # |
1398 | dnl # 4.11 API change, | |
1399 | dnl # Moved things from linux/sched.h to linux/sched/signal.h | |
1400 | dnl # | |
1401 | AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER], | |
1402 | [AC_MSG_CHECKING([whether header linux/sched/signal.h exists]) | |
1403 | SPL_LINUX_TRY_COMPILE([ | |
1404 | #include <linux/sched.h> | |
1405 | #include <linux/sched/signal.h> | |
1406 | ],[ | |
1407 | return 0; | |
1408 | ],[ | |
1409 | AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists]) | |
1410 | AC_MSG_RESULT(yes) | |
1411 | ],[ | |
1412 | AC_MSG_RESULT(no) | |
1413 | ]) | |
1414 | ]) | |
94b1ab2a | 1415 | |
2a305c34 | 1416 | dnl # |
94b1ab2a OF |
1417 | dnl # 4.11 API, a528d35e@torvalds/linux |
1418 | dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f) | |
1419 | dnl # | |
1420 | AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [ | |
1421 | AC_MSG_CHECKING([whether vfs_getattr() wants 4 args]) | |
1422 | SPL_LINUX_TRY_COMPILE([ | |
1423 | #include <linux/fs.h> | |
1424 | ],[ | |
1425 | vfs_getattr((const struct path *)NULL, | |
1426 | (struct kstat *)NULL, | |
1427 | (u32)0, | |
1428 | (unsigned int)0); | |
1429 | ],[ | |
1430 | AC_MSG_RESULT(yes) | |
1431 | AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1, | |
1432 | [vfs_getattr wants 4 args]) | |
1433 | ],[ | |
1434 | AC_MSG_RESULT(no) | |
1435 | ]) | |
1436 | ]) | |
1437 | ||
1438 | dnl # | |
1439 | dnl # 3.9 API | |
1440 | dnl # vfs_getattr(struct path *p, struct kstat *s) | |
2a305c34 RY |
1441 | dnl # |
1442 | AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [ | |
94b1ab2a | 1443 | AC_MSG_CHECKING([whether vfs_getattr() wants 2 args]) |
2a305c34 RY |
1444 | SPL_LINUX_TRY_COMPILE([ |
1445 | #include <linux/fs.h> | |
1446 | ],[ | |
1447 | vfs_getattr((struct path *) NULL, | |
1448 | (struct kstat *)NULL); | |
1449 | ],[ | |
94b1ab2a | 1450 | AC_MSG_RESULT(yes) |
2a305c34 | 1451 | AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1, |
94b1ab2a | 1452 | [vfs_getattr wants 2 args]) |
2a305c34 | 1453 | ],[ |
94b1ab2a OF |
1454 | AC_MSG_RESULT(no) |
1455 | ]) | |
1456 | ]) | |
1457 | ||
1458 | dnl # | |
1459 | dnl # <3.9 API | |
1460 | dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k) | |
1461 | dnl # | |
1462 | AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [ | |
1463 | AC_MSG_CHECKING([whether vfs_getattr() wants 3 args]) | |
1464 | SPL_LINUX_TRY_COMPILE([ | |
1465 | #include <linux/fs.h> | |
1466 | ],[ | |
1467 | vfs_getattr((struct vfsmount *)NULL, | |
1468 | (struct dentry *)NULL, | |
1469 | (struct kstat *)NULL); | |
1470 | ],[ | |
1471 | AC_MSG_RESULT(yes) | |
1472 | AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1, | |
1473 | [vfs_getattr wants 3 args]) | |
1474 | ],[ | |
1475 | AC_MSG_RESULT(no) | |
2a305c34 RY |
1476 | ]) |
1477 | ]) | |
184c6873 NB |
1478 | |
1479 | dnl # | |
1480 | dnl # 2.6.36 API compatibility. | |
1481 | dnl # Added usleep_range timer. | |
1482 | dnl # usleep_range is a finer precision implementation of msleep | |
1483 | dnl # designed to be a drop-in replacement for udelay where a precise | |
1484 | dnl # sleep / busy-wait is unnecessary. | |
1485 | dnl # | |
1486 | AC_DEFUN([SPL_AC_USLEEP_RANGE], [ | |
1487 | AC_MSG_CHECKING([whether usleep_range() is available]) | |
1488 | SPL_LINUX_TRY_COMPILE([ | |
1489 | #include <linux/delay.h> | |
1490 | ],[ | |
1491 | usleep_range(0, 0); | |
1492 | ],[ | |
1493 | AC_MSG_RESULT(yes) | |
1494 | AC_DEFINE(HAVE_USLEEP_RANGE, 1, | |
1495 | [usleep_range is available]) | |
1496 | ],[ | |
1497 | AC_MSG_RESULT(no) | |
1498 | ]) | |
1499 | ]) | |
a073aeb0 BB |
1500 | |
1501 | dnl # | |
1502 | dnl # 2.6.35 API change, | |
1503 | dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are | |
1504 | dnl # private allocation flags which are applied when allocating a new slab | |
1505 | dnl # in kmem_getpages(). Unfortunately there is no public API for setting | |
1506 | dnl # non-default flags. | |
1507 | dnl # | |
1508 | AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [ | |
1509 | AC_MSG_CHECKING([whether struct kmem_cache has allocflags]) | |
1510 | SPL_LINUX_TRY_COMPILE([ | |
1511 | #include <linux/slab.h> | |
1512 | ],[ | |
1513 | struct kmem_cache cachep __attribute__ ((unused)); | |
1514 | cachep.allocflags = GFP_KERNEL; | |
1515 | ],[ | |
1516 | AC_MSG_RESULT(yes) | |
1517 | AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1, | |
1518 | [struct kmem_cache has allocflags]) | |
1519 | ],[ | |
1520 | AC_MSG_RESULT(no) | |
1521 | ||
1522 | AC_MSG_CHECKING([whether struct kmem_cache has gfpflags]) | |
1523 | SPL_LINUX_TRY_COMPILE([ | |
1524 | #include <linux/slab.h> | |
1525 | ],[ | |
1526 | struct kmem_cache cachep __attribute__ ((unused)); | |
1527 | cachep.gfpflags = GFP_KERNEL; | |
1528 | ],[ | |
1529 | AC_MSG_RESULT(yes) | |
1530 | AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1, | |
1531 | [struct kmem_cache has gfpflags]) | |
1532 | ],[ | |
1533 | AC_MSG_RESULT(no) | |
1534 | ]) | |
1535 | ]) | |
1536 | ]) | |
2fc44f66 NB |
1537 | |
1538 | dnl # | |
1539 | dnl # 3.17 API change, | |
1540 | dnl # wait_on_bit() no longer requires an action argument. The former | |
1541 | dnl # "wait_on_bit" interface required an 'action' function to be provided | |
1542 | dnl # which does the actual waiting. There were over 20 such functions in the | |
1543 | dnl # kernel, many of them identical, though most cases can be satisfied by one | |
1544 | dnl # of just two functions: one which uses io_schedule() and one which just | |
1545 | dnl # uses schedule(). This API change was made to consolidate all of those | |
1546 | dnl # redundant wait functions. | |
1547 | dnl # | |
1548 | AC_DEFUN([SPL_AC_WAIT_ON_BIT], [ | |
1549 | AC_MSG_CHECKING([whether wait_on_bit() takes an action]) | |
1550 | SPL_LINUX_TRY_COMPILE([ | |
1551 | #include <linux/wait.h> | |
1552 | ],[ | |
1553 | int (*action)(void *) = NULL; | |
1554 | wait_on_bit(NULL, 0, action, 0); | |
1555 | ],[ | |
1556 | AC_MSG_RESULT(yes) | |
1557 | AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes]) | |
1558 | ],[ | |
1559 | AC_MSG_RESULT(no) | |
1560 | ]) | |
1561 | ]) | |
cdd39dd2 CC |
1562 | |
1563 | dnl # | |
1564 | dnl # Check whether mutex has owner with task_struct type. | |
1565 | dnl # | |
1566 | dnl # Note that before Linux 3.0, mutex owner is of type thread_info. | |
1567 | dnl # | |
1568 | dnl # Note that in Linux 3.18, the condition for owner is changed from | |
1569 | dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) to | |
1570 | dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER) | |
1571 | dnl # | |
1572 | AC_DEFUN([SPL_AC_MUTEX_OWNER], [ | |
1573 | AC_MSG_CHECKING([whether mutex has owner]) | |
1574 | tmp_flags="$EXTRA_KCFLAGS" | |
1575 | EXTRA_KCFLAGS="-Werror" | |
1576 | SPL_LINUX_TRY_COMPILE([ | |
1577 | #include <linux/mutex.h> | |
576865be | 1578 | #include <linux/spinlock.h> |
cdd39dd2 CC |
1579 | ],[ |
1580 | DEFINE_MUTEX(m); | |
1581 | struct task_struct *t __attribute__ ((unused)); | |
1582 | t = m.owner; | |
1583 | ],[ | |
1584 | AC_MSG_RESULT(yes) | |
1585 | AC_DEFINE(HAVE_MUTEX_OWNER, 1, [yes]) | |
1586 | ],[ | |
1587 | AC_MSG_RESULT(no) | |
1588 | ]) | |
1589 | EXTRA_KCFLAGS="$tmp_flags" | |
1590 | ]) | |
fdbc1ba9 CC |
1591 | |
1592 | dnl # | |
1593 | dnl # 4.7 API change | |
1594 | dnl # i_mutex is changed to i_rwsem. Instead of directly using | |
1595 | dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared() | |
1596 | dnl # We test inode_lock_shared because inode_lock is introduced earlier. | |
1597 | dnl # | |
1598 | AC_DEFUN([SPL_AC_INODE_LOCK], [ | |
1599 | AC_MSG_CHECKING([whether inode_lock_shared() exists]) | |
1600 | tmp_flags="$EXTRA_KCFLAGS" | |
1601 | EXTRA_KCFLAGS="-Werror" | |
1602 | SPL_LINUX_TRY_COMPILE([ | |
1603 | #include <linux/fs.h> | |
1604 | ],[ | |
1605 | struct inode *inode = NULL; | |
1606 | inode_lock_shared(inode); | |
1607 | ],[ | |
1608 | AC_MSG_RESULT(yes) | |
1609 | AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes]) | |
1610 | ],[ | |
1611 | AC_MSG_RESULT(no) | |
1612 | ]) | |
1613 | EXTRA_KCFLAGS="$tmp_flags" | |
1614 | ]) | |
ae7eda1d CC |
1615 | |
1616 | dnl # | |
1617 | dnl # 4.9 API change | |
1618 | dnl # group_info changed from 2d array via >blocks to 1d array via ->gid | |
1619 | dnl # | |
1620 | AC_DEFUN([SPL_AC_GROUP_INFO_GID], [ | |
1621 | AC_MSG_CHECKING([whether group_info->gid exists]) | |
1622 | tmp_flags="$EXTRA_KCFLAGS" | |
1623 | EXTRA_KCFLAGS="-Werror" | |
1624 | SPL_LINUX_TRY_COMPILE([ | |
1625 | #include <linux/cred.h> | |
1626 | ],[ | |
1627 | struct group_info *gi = groups_alloc(1); | |
1628 | gi->gid[0] = KGIDT_INIT(0); | |
1629 | ],[ | |
1630 | AC_MSG_RESULT(yes) | |
1631 | AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists]) | |
1632 | ],[ | |
1633 | AC_MSG_RESULT(no) | |
1634 | ]) | |
1635 | EXTRA_KCFLAGS="$tmp_flags" | |
1636 | ]) | |
0194e4a0 KT |
1637 | |
1638 | dnl # | |
1639 | dnl # grsecurity API change, | |
1640 | dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by | |
1641 | dnl # kmem_cache_create_usercopy(). | |
1642 | dnl # | |
1643 | AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [ | |
1644 | AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists]) | |
1645 | tmp_flags="$EXTRA_KCFLAGS" | |
1646 | EXTRA_KCFLAGS="-Werror" | |
1647 | SPL_LINUX_TRY_COMPILE([ | |
1648 | #include <linux/slab.h> | |
1649 | static void ctor(void *foo) | |
1650 | { | |
1651 | // fake ctor | |
1652 | } | |
1653 | ],[ | |
1654 | struct kmem_cache *skc_linux_cache; | |
1655 | const char *name = "test"; | |
1656 | size_t size = 4096; | |
1657 | size_t align = 8; | |
1658 | unsigned long flags = 0; | |
1659 | size_t useroffset = 0; | |
1660 | size_t usersize = size - useroffset; | |
1661 | ||
1662 | skc_linux_cache = kmem_cache_create_usercopy( | |
1663 | name, size, align, flags, useroffset, usersize, ctor); | |
1664 | ],[ | |
1665 | AC_MSG_RESULT(yes) | |
1666 | AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1, | |
1667 | [kmem_cache_create_usercopy() exists]) | |
1668 | ],[ | |
1669 | AC_MSG_RESULT(no) | |
1670 | ]) | |
1671 | EXTRA_KCFLAGS="$tmp_flags" | |
1672 | ]) |