mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
Add autoconf checks for atomic64_cmpxchg + atomic64_xchg
These functions didn't exist for all archs prior to 2.6.24. This patch addes an autoconf test to detect this and add them when needed. The autoconf check is needed instead of just an #ifndef because in the most modern kernels atomic64_{cmp}xchg are implemented as in inline function and not a #define.
This commit is contained in:
parent
5e9b5d832b
commit
302b88e6ab
@ -28,6 +28,8 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
|
||||
SPL_AC_ATOMIC_SPINLOCK
|
||||
SPL_AC_TYPE_UINTPTR_T
|
||||
SPL_AC_TYPE_ATOMIC64_T
|
||||
SPL_AC_TYPE_ATOMIC64_CMPXCHG
|
||||
SPL_AC_TYPE_ATOMIC64_XCHG
|
||||
SPL_AC_3ARGS_INIT_WORK
|
||||
SPL_AC_2ARGS_REGISTER_SYSCTL
|
||||
SPL_AC_SET_SHRINKER
|
||||
@ -488,6 +490,44 @@ AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
|
||||
])
|
||||
])
|
||||
|
||||
dnl #
|
||||
dnl # 2.6.24 API change,
|
||||
dnl # check if atomic64_cmpxchg is defined
|
||||
dnl #
|
||||
AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
|
||||
[AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
|
||||
SPL_LINUX_TRY_COMPILE([
|
||||
#include <asm/atomic.h>
|
||||
],[
|
||||
atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
|
||||
[kernel defines atomic64_cmpxchg])
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
])
|
||||
|
||||
dnl #
|
||||
dnl # 2.6.24 API change,
|
||||
dnl # check if atomic64_xchg is defined
|
||||
dnl #
|
||||
AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
|
||||
[AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
|
||||
SPL_LINUX_TRY_COMPILE([
|
||||
#include <asm/atomic.h>
|
||||
],[
|
||||
atomic64_xchg((atomic64_t *)NULL, 0);
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
|
||||
[kernel defines atomic64_xchg])
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
])
|
||||
|
||||
dnl #
|
||||
dnl # 2.6.20 API change,
|
||||
dnl # INIT_WORK use 2 args and not store data inside
|
||||
|
256
configure
vendored
256
configure
vendored
@ -19350,6 +19350,134 @@ echo "${ECHO_T}no" >&6
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -Rf build
|
||||
|
||||
|
||||
|
||||
echo "$as_me:$LINENO: checking whether kernel defines atomic64_cmpxchg" >&5
|
||||
echo $ECHO_N "checking whether kernel defines atomic64_cmpxchg... $ECHO_C" >&6
|
||||
|
||||
|
||||
cat >conftest.c <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
|
||||
#include <asm/atomic.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
|
||||
|
||||
rm -Rf build && mkdir -p build
|
||||
echo "obj-m := conftest.o" >build/Makefile
|
||||
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
|
||||
echo "$as_me:$LINENO: result: yes" >&5
|
||||
echo "${ECHO_T}yes" >&6
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_ATOMIC64_CMPXCHG 1
|
||||
_ACEOF
|
||||
|
||||
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -Rf build
|
||||
|
||||
|
||||
|
||||
echo "$as_me:$LINENO: checking whether kernel defines atomic64_xchg" >&5
|
||||
echo $ECHO_N "checking whether kernel defines atomic64_xchg... $ECHO_C" >&6
|
||||
|
||||
|
||||
cat >conftest.c <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
|
||||
#include <asm/atomic.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
atomic64_xchg((atomic64_t *)NULL, 0);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
|
||||
|
||||
rm -Rf build && mkdir -p build
|
||||
echo "obj-m := conftest.o" >build/Makefile
|
||||
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
|
||||
echo "$as_me:$LINENO: result: yes" >&5
|
||||
echo "${ECHO_T}yes" >&6
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_ATOMIC64_XCHG 1
|
||||
_ACEOF
|
||||
|
||||
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -Rf build
|
||||
@ -22521,6 +22649,134 @@ echo "${ECHO_T}no" >&6
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -Rf build
|
||||
|
||||
|
||||
|
||||
echo "$as_me:$LINENO: checking whether kernel defines atomic64_cmpxchg" >&5
|
||||
echo $ECHO_N "checking whether kernel defines atomic64_cmpxchg... $ECHO_C" >&6
|
||||
|
||||
|
||||
cat >conftest.c <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
|
||||
#include <asm/atomic.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
|
||||
|
||||
rm -Rf build && mkdir -p build
|
||||
echo "obj-m := conftest.o" >build/Makefile
|
||||
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
|
||||
echo "$as_me:$LINENO: result: yes" >&5
|
||||
echo "${ECHO_T}yes" >&6
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_ATOMIC64_CMPXCHG 1
|
||||
_ACEOF
|
||||
|
||||
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -Rf build
|
||||
|
||||
|
||||
|
||||
echo "$as_me:$LINENO: checking whether kernel defines atomic64_xchg" >&5
|
||||
echo $ECHO_N "checking whether kernel defines atomic64_xchg... $ECHO_C" >&6
|
||||
|
||||
|
||||
cat >conftest.c <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
|
||||
#include <asm/atomic.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
atomic64_xchg((atomic64_t *)NULL, 0);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
|
||||
|
||||
rm -Rf build && mkdir -p build
|
||||
echo "obj-m := conftest.o" >build/Makefile
|
||||
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
|
||||
echo "$as_me:$LINENO: result: yes" >&5
|
||||
echo "${ECHO_T}yes" >&6
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_ATOMIC64_XCHG 1
|
||||
_ACEOF
|
||||
|
||||
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -Rf build
|
||||
|
@ -55,5 +55,13 @@ static inline void atomic64_set(atomic64_t *v, __s64 i)
|
||||
|
||||
#endif /* HAVE_ATOMIC64_T */
|
||||
|
||||
#ifndef HAVE_ATOMIC64_CMPXCHG
|
||||
#define atomic64_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ATOMIC64_XCHG
|
||||
#define atomic64_xchg(v, n) (xchg(&((v)->counter), n))
|
||||
#endif
|
||||
|
||||
#endif /* _SPL_ATOMIC_COMPAT_H */
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <sys/types.h>
|
||||
#include <asm/atomic_compat.h>
|
||||
|
||||
/*
|
||||
* Two approaches to atomic operations are implemented each with its
|
||||
|
@ -33,9 +33,15 @@
|
||||
/* device_create wants 5 args */
|
||||
#undef HAVE_5ARGS_DEVICE_CREATE
|
||||
|
||||
/* kernel defines atomic64_cmpxchg */
|
||||
#undef HAVE_ATOMIC64_CMPXCHG
|
||||
|
||||
/* kernel defines atomic64_t */
|
||||
#undef HAVE_ATOMIC64_T
|
||||
|
||||
/* kernel defines atomic64_xchg */
|
||||
#undef HAVE_ATOMIC64_XCHG
|
||||
|
||||
/* class_device_create() is available */
|
||||
#undef HAVE_CLASS_DEVICE_CREATE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user