Linux 3.4 compat, __clear_close_on_exec replaces FD_CLR

torvalds/linux@1dce27c5aa introduced
__clear_close_on_exec() as a replacement for FD_CLR. Further commits
appear to have removed FD_CLR from the Linux source tree.  This
causes the following failure:

  error: implicit declaration of function '__FD_CLR'
  [-Werror=implicit-function-declaration]

To correct this we update the code to use the current
__clear_close_on_exec() interface for readability.  Then we introduce
an autotools check to determine if __clear_close_on_exec() is available.
If it isn't then we define some compatibility logic which used the older
FD_CLR() interface.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #124
This commit is contained in:
Richard Yao
2012-06-06 16:51:53 +00:00
committed by Brian Behlendorf
parent eaac9ba510
commit e0093fea58
5 changed files with 167 additions and 1 deletions
+23
View File
@@ -44,6 +44,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
SPL_AC_INIT_UTSNAME
SPL_AC_FDTABLE_HEADER
SPL_AC_FILES_FDTABLE
SPL_AC_CLEAR_CLOSE_ON_EXEC
SPL_AC_UACCESS_HEADER
SPL_AC_KMALLOC_NODE
SPL_AC_MONOTONIC_CLOCK
@@ -1176,6 +1177,28 @@ AC_DEFUN([SPL_AC_FILES_FDTABLE], [
])
])
dnl #
dnl # 3.4.0 API change,
dnl # check whether '__clear_close_on_exec()' exists
dnl #
AC_DEFUN([SPL_AC_CLEAR_CLOSE_ON_EXEC], [
AC_MSG_CHECKING([whether __clear_close_on_exec() is available])
SPL_LINUX_TRY_COMPILE([
#include <linux/fdtable.h>
],[
struct fdtable *fdt = NULL;
int fd = 0;
__clear_close_on_exec(fd, fdt);
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_CLEAR_CLOSE_ON_EXEC, 1,
[__clear_close_on_exec() is available])
],[
AC_MSG_RESULT(no)
])
])
dnl #
dnl # 2.6.18 API change,
dnl # added linux/uaccess.h