Linux: Macroise kernel function autoconf tests
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Mon, 26 Apr 2010 22:54:05 +0000 (23:54 +0100)
committerDerrick Brashear <shadow@dementia.org>
Tue, 27 Apr 2010 19:22:59 +0000 (12:22 -0700)
We spend a lot of time in autoconf checking to see if kernel
functions are available. Rather than copying and pasting the same
code everytime we do so, create a macro to do function tests, and
use that macro. This results in standardised naming, so change all
of the places that use autoconf results to use the same standardised
names.

Change-Id: I36212e6c28c4b8455f859da1bbf3e456a2aabc07
Reviewed-on: http://gerrit.openafs.org/1849
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

15 files changed:
acinclude.m4
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_fetchstore.c
src/afs/LINUX/osi_gcpags.c
src/afs/LINUX/osi_groups.c
src/afs/LINUX/osi_machdep.h
src/afs/LINUX/osi_vfsops.c
src/afs/LINUX/osi_vnodeops.c
src/afs/LINUX24/osi_gcpags.c
src/afs/LINUX24/osi_machdep.h
src/afs/LINUX24/osi_vfsops.c
src/afs/LINUX24/osi_vnodeops.c
src/afs/afs_user.c
src/cf/linux-test1.m4
src/cf/linux-test4.m4

index 6535a91..74e5edd 100644 (file)
@@ -803,11 +803,17 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
 
                  LINUX_KBUILD_USES_EXTRA_CFLAGS
                 LINUX_KERNEL_COMPILE_WORKS
-                LINUX_EXPORTS_FIND_TASK_BY_PID
+                AC_CHECK_LINUX_FUNC([find_task_by_pid],
+                                    [#include <linux/sched.h>],
+                                    [pid_t p; find_task_by_pid(p);])
                 LINUX_EXPORTS_PROC_ROOT_FS
-                 LINUX_HAVE_CURRENT_KERNEL_TIME
+                AC_CHECK_LINUX_FUNC([current_kernel_time],
+                                    [#include <linux/time.h>],
+                                  [struct timespec s = current_kernel_time();])
                 LINUX_HAVE_WRITE_BEGIN_AOP
-                 LINUX_HAVE_BDI_INIT
+                 AC_CHECK_LINUX_FUNC([bdi_init],
+                                    [#include <linux/backing-dev.h>],
+                                    [bdi_init(NULL);])
                  LINUX_KMEM_CACHE_INIT
                  LINUX_HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN
                 LINUX_HAVE_PAGEVEC_LRU_ADD_FILE
@@ -816,6 +822,28 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 LINUX_HAVE_ZERO_USER_SEGMENTS
                 LINUX_HAVE_VFS_LLSEEK
                 LINUX_HAVE_KERNEL_SETSOCKOPT
+                AC_CHECK_LINUX_FUNC([grap_cache_page_write_begin],
+                                    [#include <linux/pagemap.h>],
+                                   [grab_cache_page_write_begin(NULL, 0, 0);])
+                AC_CHECK_LINUX_FUNC([pagevec_lru_add_file],
+                                    [#include <linux/pagevec.h>],
+                                    [__pagevec_lru_add_file(NULL);])
+                AC_CHECK_LINUX_FUNC([splice_direct_to_actor],
+                                    [#include <linux/splice.h>],
+                                   [splice_direct_to_actor(NULL, NULL, NULL);])
+                AC_CHECK_LINUX_FUNC([page_offset],
+                                    [#include <linux/pagemap.h>],
+                                    [page_offset(NULL);])
+                AC_CHECK_LINUX_FUNC([zero_user_segments],
+                                    [#include <linux/highmem.h>],
+                                    [zero_user_segments(NULL, 0, 0, 0, 0);])
+                AC_CHECK_LINUX_FUNC([vfs_llseek],
+                                    [#include <linux/fs.h>],
+                                    [vfs_llseek(NULL, 0, 0);])
+                AC_CHECK_LINUX_FUNC([kernel_setsockopt],
+                                    [#include <linux/net.h>],
+                                    [kernel_setsockopt(NULL, 0, 0, NULL, 0);])
+
                  LINUX_STRUCT_TASK_HAS_CRED
                 LINUX_STRUCT_PROC_DIR_ENTRY_HAS_OWNER
                 LINUX_HAVE_KMEM_CACHE_T
@@ -852,8 +880,12 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 LINUX_POSIX_TEST_LOCK_RETURNS_CONFLICT
                 LINUX_POSIX_TEST_LOCK_CONFLICT_ARG
                 LINUX_KERNEL_SOCK_CREATE
-                LINUX_KERNEL_PAGE_FOLLOW_LINK
-                LINUX_KERNEL_HLIST_UNHASHED
+                AC_CHECK_LINUX_FUNC([page_follow_link],
+                                    [#include <linux/fs.h>],
+                                    [page_follow_link(0,0);])
+                AC_CHECK_LINUX_FUNC([hlist_unhashed],
+                                    [#include <linux/list.h>],
+                                    [hlist_unhashed(0);])
                 AC_CHECK_LINUX_HEADER([key-type.h])
                 LINUX_EXPORTS_KEY_TYPE_KEYRING
                 LINUX_KEYS_HAVE_SESSION_TO_PARENT
@@ -879,26 +911,38 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 LINUX_LINUX_KEYRING_SUPPORT
                 LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK
                 LINUX_KEY_ALLOC_NEEDS_CRED
-                LINUX_DO_SYNC_READ
-                LINUX_GENERIC_FILE_AIO_READ
+                AC_CHECK_LINUX_FUNC([do_sync_read],
+                                    [#include <linux/fs.h>],
+                                    [do_sync_read(NULL, NULL, 0, NULL);])
+                AC_CHECK_LINUX_FUNC([generic_file_aio_read],
+                                    [#include <linux/fs.h>],
+                                  [generic_file_aio_read(NULL, NULL, 0, 0);])
                 LINUX_INIT_WORK_HAS_DATA
                 LINUX_REGISTER_SYSCTL_TABLE_NOFLAG
                 LINUX_SYSCTL_TABLE_CHECKING
                 LINUX_STRUCT_CTL_TABLE_HAS_CTL_NAME
-                LINUX_HAVE_IGET
-                if test "x$ac_cv_linux_have_iget" = "xno"; then
-                  AC_DEFINE([LINUX_USE_FH], 1, [define to use linux file handles for cache files])
-                fi
-                LINUX_HAVE_I_SIZE_READ
-                LINUX_HAVE_D_ALLOC_ANON
-                if test "x$ac_cv_linux_d_alloc_anon" = "xno"; then
-                  AC_DEFINE([AFS_NONFSTRANS], 1, [define to disable the nfs translator])
-                fi
+                AC_CHECK_LINUX_FUNC([iget],
+                                    [#include <linux/fs.h>],
+                                    [iget(NULL, NULL);])
+                AS_IF([test "x$ac_cv_linux_func_iget" = "xno"],
+                      [AC_DEFINE([LINUX_USE_FH], 1,
+                         [define to use linux file handles for cache files])])
+                AC_CHECK_LINUX_FUNC([i_size_read],
+                                    [#include <linux/fs.h>],
+                                    [i_size_read(NULL);])
+                AC_CHECK_LINUX_FUNC([d_alloc_anon],
+                                    [#include <linux/dcache.h>],
+                                    [d_alloc_anon(NULL);])
+                AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"],
+                      [AC_DEFINE([AFS_NONFSTRANS], 1,
+                                 [define to disable the nfs translator])])
                 LINUX_FS_STRUCT_NAMEIDATA_HAS_PATH
                 LINUX_EXPORTS_INIT_MM
                  LINUX_EXPORTS_SYS_CHDIR
                  LINUX_EXPORTS_SYS_OPEN
-                LINUX_EXPORTS_RCU_READ_LOCK
+                AC_CHECK_LINUX_FUNC([rcu_read_lock],
+                                    [#include <linux/rcupdate.h>],
+                                    [rcu_read_lock();])
                 if test "x$with_linux_kernel_packaging" = "xno" ; then
                   LINUX_WHICH_MODULES
                 else
@@ -989,12 +1033,6 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 if test "x$ac_cv_linux_kernel_sock_create_v" = "xyes" ; then
                  AC_DEFINE(LINUX_KERNEL_SOCK_CREATE_V, 1, [define if your linux kernel uses 5 arguments for sock_create])
                 fi
-                if test "x$ac_cv_linux_kernel_page_follow_link" = "xyes" ; then
-                 AC_DEFINE(HAVE_KERNEL_PAGE_FOLLOW_LINK, 1, [define if your linux kernel provides page_follow_link])
-                fi
-                if test "x$ac_cv_linux_kernel_hlist_unhashed" = "xyes" ; then
-                 AC_DEFINE(HAVE_KERNEL_HLIST_UNHASHED, 1, [define if your linux kernel provides hlist_unhashed])
-                fi
                 if test "x$ac_cv_linux_sched_struct_task_struct_has_parent" = "xyes"; then 
                  AC_DEFINE(STRUCT_TASK_STRUCT_HAS_PARENT, 1, [define if your struct task_struct has parent])
                 fi
index 53d486f..665a708 100644 (file)
@@ -13,7 +13,7 @@
 # include <linux/freezer.h>
 #endif
 
-#ifndef DO_SYNC_READ
+#ifndef HAVE_LINUX_DO_SYNC_READ
 static inline int
 do_sync_read(struct file *fp, char *buf, size_t count, loff_t *offp) {
     return generic_file_read(fp, buf, count, offp);
@@ -80,7 +80,7 @@ static inline void afs_linux_clear_nfsfs_renamed(void) { return; }
 static inline void afs_linux_set_nfsfs_renamed(void) { return; }
 #endif
 
-#ifndef HAVE_KERNEL_HLIST_UNHASHED
+#ifndef HAVE_LINUX_HLIST_UNHASHED
 static void
 hlist_unhashed(const struct hlist_node *h) {
     return (!h->pprev == NULL);
@@ -91,7 +91,7 @@ hlist_unhashed(const struct hlist_node *h) {
 #define AOP_WRITEPAGE_ACTIVATE WRITEPAGE_ACTIVATE
 #endif
 
-#if defined(HAVE_WRITE_BEGIN) && !defined(HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN)
+#if defined(HAVE_WRITE_BEGIN) && !defined(HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN)
 static inline struct page *
 grab_cache_page_write_begin(struct address_space *mapping, pgoff_t index,
                            unsigned int flags) {
@@ -208,7 +208,7 @@ afs_linux_cred_is_current(afs_ucred_t *cred)
 #endif
 #endif
 
-#ifndef HAVE_PAGE_OFFSET
+#ifndef HAVE_LINUX_PAGE_OFFSET
 static inline loff_t
 page_offset(struct page *pp)
 {
@@ -216,7 +216,7 @@ page_offset(struct page *pp)
 }
 #endif
 
-#ifndef HAVE_ZERO_USER_SEGMENTS
+#ifndef HAVE_LINUX_ZERO_USER_SEGMENTS
 static inline void
 zero_user_segments(struct page *pp, unsigned int from1, unsigned int to1,
                   unsigned int from2, unsigned int to2)
@@ -234,7 +234,7 @@ zero_user_segments(struct page *pp, unsigned int from1, unsigned int to1,
 }
 #endif
 
-#ifndef HAVE_VFS_LLSEEK
+#ifndef HAVE_LINUX_VFS_LLSEEK
 static inline loff_t
 vfs_llseek(struct file *filp, loff_t offset, int origin) {
     if (filp->f_op->llseek)
@@ -243,7 +243,7 @@ vfs_llseek(struct file *filp, loff_t offset, int origin) {
 }
 #endif
 
-#ifndef HAVE_KERNEL_SETSOCKOPT
+#ifndef HAVE_LINUX_KERNEL_SETSOCKOPT
 /* Available from 2.6.19 */
 
 static inline int
index 8fb12f1..4989a01 100644 (file)
@@ -38,7 +38,7 @@
 #include "afs/param.h"
 
 #include <linux/fs.h>
-#if defined(HAVE_SPLICE_DIRECT_TO_ACTOR)
+#if defined(HAVE_LINUX_SPLICE_DIRECT_TO_ACTOR)
 # include <linux/splice.h>
 #else
 # include <linux/pipe_fs_i.h>
@@ -47,7 +47,7 @@
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
 
-#if defined(HAVE_SPLICE_DIRECT_TO_ACTOR)
+#if defined(HAVE_LINUX_SPLICE_DIRECT_TO_ACTOR)
 static int
 afs_linux_splice_actor(struct pipe_inode_info *pipe,
                       struct pipe_buffer *buf,
index ada11e5..34e1a23 100644 (file)
@@ -28,7 +28,7 @@ extern rwlock_t tasklist_lock __attribute__((weak));
 void
 afs_osi_TraverseProcTable(void)
 {
-#if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_HAS_CRED) || defined(EXPORTED_RCU_READ_LOCK))
+#if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK))
     struct task_struct *p;
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK)
index 3e73072..1c25d30 100644 (file)
@@ -516,19 +516,19 @@ void osi_keyring_init(void)
      * If that's not available, then keyring based PAGs won't work.
      */
     
-#if defined(EXPORTED_TASKLIST_LOCK) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(EXPORTED_RCU_READ_LOCK))
+#if defined(EXPORTED_TASKLIST_LOCK) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(HAVE_LINUX_RCU_READ_LOCK))
     if (__key_type_keyring == NULL) {
 # ifdef EXPORTED_TASKLIST_LOCK
        if (&tasklist_lock)
            read_lock(&tasklist_lock);
 # endif
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(EXPORTED_RCU_READ_LOCK))
+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(HAVE_LINUX_RCU_READ_LOCK))
 #  ifdef EXPORTED_TASKLIST_LOCK
        else
 #  endif
            rcu_read_lock();
 # endif
-#if defined(EXPORTED_FIND_TASK_BY_PID)
+#if defined(HAVE_LINUX_FIND_TASK_BY_PID)
        p = find_task_by_pid(1);
 #else
        p = find_task_by_vpid(1);
@@ -539,7 +539,7 @@ void osi_keyring_init(void)
        if (&tasklist_lock)
            read_unlock(&tasklist_lock);
 # endif
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(EXPORTED_RCU_READ_LOCK))
+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && defined(HAVE_LINUX_RCU_READ_LOCK))
 #  ifdef EXPORTED_TASKLIST_LOCK
        else
 #  endif
index 528e862..5697fb1 100644 (file)
@@ -76,7 +76,7 @@
 
 #define afs_hz HZ
 #include "h/sched.h"
-#if defined(HAVE_CURRENT_KERNEL_TIME)
+#if defined(HAVE_LINUX_CURRENT_KERNEL_TIME)
 static inline time_t osi_Time(void) { 
     struct timespec xtime;
     xtime = current_kernel_time();
index a7cd802..0b50b3d 100644 (file)
@@ -107,7 +107,7 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
     sb->s_op = &afs_sops;      /* Super block (vfs) ops */
     /* used for inodes backing_dev_info field, also */
     afs_backing_dev_info = osi_Alloc(sizeof(struct backing_dev_info));
-#if defined(HAVE_BDI_INIT)
+#if defined(HAVE_LINUX_BDI_INIT)
     bdi_init(afs_backing_dev_info);
 #endif
 #if defined(STRUCT_BDI_HAS_NAME)
@@ -319,7 +319,7 @@ afs_put_super(struct super_block *sbp)
     mntput(afs_cacheMnt);
 
     osi_linux_verify_alloced_memory();
-#if defined(HAVE_BDI_INIT)
+#if defined(HAVE_LINUX_BDI_INIT)
     bdi_destroy(afs_backing_dev_info);
 #endif
     osi_Free(afs_backing_dev_info, sizeof(struct backing_dev_info));
index 9ebbfe1..b81af85 100644 (file)
@@ -41,7 +41,7 @@
 #include "osi_compat.h"
 #include "osi_pagecopy.h"
 
-#ifndef HAVE_PAGEVEC_LRU_ADD_FILE
+#ifndef HAVE_LINUX_PAGEVEC_LRU_ADD_FILE
 #define __pagevec_lru_add_file __pagevec_lru_add
 #endif
 
@@ -680,7 +680,7 @@ struct file_operations afs_dir_fops = {
 struct file_operations afs_file_fops = {
   .read =      afs_linux_read,
   .write =     afs_linux_write,
-#ifdef GENERIC_FILE_AIO_READ
+#ifdef HAVE_LINUX_GENERIC_FILE_AIO_READ
   .aio_read =  generic_file_aio_read,
   .aio_write = generic_file_aio_write,
 #endif
@@ -2455,7 +2455,7 @@ static struct address_space_operations afs_symlink_aops = {
 static struct inode_operations afs_symlink_iops = {
 #if defined(USABLE_KERNEL_PAGE_SYMLINK_CACHE)
   .readlink =          page_readlink,
-# if defined(HAVE_KERNEL_PAGE_FOLLOW_LINK)
+# if defined(HAVE_LINUX_PAGE_FOLLOW_LINK)
   .follow_link =       page_follow_link,
 # else
   .follow_link =       page_follow_link_light,
index ff04176..f73e1d0 100644 (file)
@@ -26,7 +26,7 @@ extern rwlock_t tasklist_lock __attribute__((weak));
 void
 afs_osi_TraverseProcTable(void)
 {
-#if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_HAS_CRED) || defined(EXPORTED_RCU_READ_LOCK))
+#if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK))
     struct task_struct *p;
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) && defined(EXPORTED_TASKLIST_LOCK)
index b448050..06c89b9 100644 (file)
@@ -73,7 +73,7 @@
 
 #define afs_hz HZ
 #include "h/sched.h"
-#if defined(HAVE_CURRENT_KERNEL_TIME)
+#if defined(HAVE_LINUX_CURRENT_KERNEL_TIME)
 static inline time_t osi_Time(void) { 
     struct timespec xtime;
     xtime = current_kernel_time();
index ea4a7be..52350d1 100644 (file)
@@ -97,7 +97,7 @@ afs_read_super(struct super_block *sb, void *data, int silent)
     sb->s_blocksize_bits = 10;
     sb->s_magic = AFS_VFSMAGIC;
     sb->s_op = &afs_sops;      /* Super block (vfs) ops */
-#if defined(HAVE_BDI_INIT)
+#if defined(HAVE_LINUX_BDI_INIT)
     bdi_init(&afs_backing_dev_info);
 #endif
 #if defined(MAX_NON_LFS)
@@ -335,7 +335,7 @@ afs_put_super(struct super_block *sbp)
 #endif
 
     osi_linux_verify_alloced_memory();
-#if defined(HAVE_BDI_INIT)
+#if defined(HAVE_LINUX_BDI_INIT)
     bdi_destroy(&afs_backing_dev_info);
 #endif
     AFS_GUNLOCK();
index 6653340..6edb4a2 100644 (file)
@@ -46,7 +46,7 @@
 #define pageoff(pp) pp->offset
 #endif
 
-#ifndef HAVE_PAGEVEC_LRU_ADD_FILE
+#ifndef HAVE_LINUX_PAGEVEC_LRU_ADD_FILE
 #define __pagevec_lru_add_file __pagevec_lru_add
 #endif
 
@@ -147,7 +147,7 @@ afs_linux_read(struct file *fp, char *buf, size_t count, loff_t * offp)
         * so we optimise by not using it */
        osi_FlushPages(vcp, NULL);      /* ensure stale pages are gone */
        AFS_GUNLOCK();
-#ifdef DO_SYNC_READ
+#ifdef HAVE_LINUX_DO_SYNC_READ
        code = do_sync_read(fp, buf, count, offp);
 #else
        code = generic_file_read(fp, buf, count, offp);
@@ -770,7 +770,7 @@ struct file_operations afs_dir_fops = {
 struct file_operations afs_file_fops = {
   .read =      afs_linux_read,
   .write =     afs_linux_write,
-#ifdef GENERIC_FILE_AIO_READ
+#ifdef HAVE_LINUX_GENERIC_FILE_AIO_READ
   .aio_read =  generic_file_aio_read,
   .aio_write = generic_file_aio_write,
 #endif
@@ -1157,7 +1157,7 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp)
        afs_getattr(vcp, &vattr, credp);
        afs_fill_inode(ip, &vattr);
        if (
-#ifdef HAVE_KERNEL_HLIST_UNHASHED
+#ifdef HAVE_LINUX_HLIST_UNHASHED
            hlist_unhashed(&ip->i_hash)
 #else
            ip->i_hash.prev == NULL
@@ -2357,7 +2357,7 @@ afs_linux_write_begin(struct file *file, struct address_space *mapping,
 {
     struct page *page;
     pgoff_t index = pos >> PAGE_CACHE_SHIFT;
-#if defined(HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN)
+#if defined(HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN)
     page = grab_cache_page_write_begin(mapping, index, flags);
 #else
     page = __grab_cache_page(mapping, index);
index 6789786..e3cf687 100644 (file)
@@ -623,7 +623,7 @@ static size_t afs_GCPAGs_cred_count = 0;
 /*
  * LOCKS: afs_GCPAGs_perproc_func requires write lock on afs_xuser
  */
-#if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_HAS_CRED) || defined(EXPORTED_RCU_READ_LOCK))
+#if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK))
 void
 afs_GCPAGs_perproc_func(afs_proc_t * pproc)
 {
index c52a1f8..496caa8 100644 (file)
@@ -100,3 +100,19 @@ AC_DEFUN([AC_CHECK_LINUX_HEADER],
                  [Define if your kernel has linux/$1])])
  ])
 
+dnl AC_CHECK_LINUX_FUNC([function], [includes], [code])
+AC_DEFUN([AC_CHECK_LINUX_FUNC],
+ [AS_VAR_PUSHDEF([ac_linux_func], [ac_cv_linux_func_$1])dnl
+  AC_CACHE_CHECK([for $1], [ac_linux_func],
+    [save_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
+     AC_TRY_KBUILD([$2], [$3],
+                  AS_VAR_SET([ac_linux_func], [yes]),
+                  AS_VAR_SET([ac_linux_func], [no]))
+     CPPFLAGS="$save_CPPFLAGS"
+    ])
+  AS_IF([test AS_VAR_GET([ac_linux_func]) = yes],
+       [AC_DEFINE(AS_TR_CPP(HAVE_LINUX_$1), 1,
+                  [Define if your kernel has the $1 function])])
+ ])
+
index a4d5b71..43497b7 100644 (file)
@@ -391,33 +391,6 @@ AC_DEFUN([LINUX_KERNEL_SOCK_CREATE], [
   AC_MSG_RESULT($ac_cv_linux_kernel_sock_create_v)])
 
 
-AC_DEFUN([LINUX_KERNEL_PAGE_FOLLOW_LINK], [
-  AC_MSG_CHECKING([for page_follow_link_light vs page_follow_link])
-  AC_CACHE_VAL([ac_cv_linux_kernel_page_follow_link], [
-    save_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
-    AC_TRY_KBUILD(
-[#include <linux/fs.h>],
-[page_follow_link(0,0);],
-      ac_cv_linux_kernel_page_follow_link=yes,
-      ac_cv_linux_kernel_page_follow_link=no)
-    CPPFLAGS="$save_CPPFLAGS"])
-  AC_MSG_RESULT($ac_cv_linux_kernel_page_follow_link)])
-
-AC_DEFUN([LINUX_KERNEL_HLIST_UNHASHED], [
-  AC_MSG_CHECKING([for hlist_unhashed])
-  AC_CACHE_VAL([ac_cv_linux_kernel_hlist_unhashed], [
-    save_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
-    AC_TRY_KBUILD(
-[#include <linux/list.h>],
-[hlist_unhashed(0);],
-      ac_cv_linux_kernel_hlist_unhashed=yes,
-      ac_cv_linux_kernel_hlist_unhashed=no)
-    CPPFLAGS="$save_CPPFLAGS"])
-  AC_MSG_RESULT($ac_cv_linux_kernel_hlist_unhashed)])
-
-
 AC_DEFUN([LINUX_FS_STRUCT_INODE_HAS_I_BYTES], [
   AC_MSG_CHECKING([for i_bytes in struct inode])
   AC_CACHE_VAL([ac_cv_linux_fs_struct_inode_has_i_bytes], [
@@ -649,70 +622,6 @@ AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_CRED], [
     AC_DEFINE([KEY_ALLOC_NEEDS_CRED], 1, [define if key_alloc takes credentials])
   fi])
 
-AC_DEFUN([LINUX_DO_SYNC_READ], [
-  AC_MSG_CHECKING([for linux do_sync_read()])
-  AC_CACHE_VAL([ac_cv_linux_do_sync_read], [
-    save_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
-    AC_TRY_KBUILD(
-[#include <linux/fs.h>],
-[do_sync_read(NULL, NULL, 0, NULL);],
-      ac_cv_linux_do_sync_read=yes,
-      ac_cv_linux_do_sync_read=no)
-    CPPFLAGS="$save_CPPFLAGS"])
-  AC_MSG_RESULT($ac_cv_linux_do_sync_read)
-  if test "x$ac_cv_linux_do_sync_read" = "xyes"; then
-    AC_DEFINE([DO_SYNC_READ], 1, [define if your kernel has do_sync_read()])
-  fi])
-
-AC_DEFUN([LINUX_GENERIC_FILE_AIO_READ], [
-  AC_MSG_CHECKING([for linux generic_file_aio_read()])
-  AC_CACHE_VAL([ac_cv_linux_generic_file_aio_read], [
-    save_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
-    AC_TRY_KBUILD(
-[#include <linux/fs.h>],
-[generic_file_aio_read(NULL, NULL, 0, 0);],
-      ac_cv_linux_generic_file_aio_read=yes,
-      ac_cv_linux_generic_file_aio_read=no)
-    CPPFLAGS="$save_CPPFLAGS"])
-  AC_MSG_RESULT($ac_cv_linux_generic_file_aio_read)
-  if test "x$ac_cv_linux_generic_file_aio_read" = "xyes"; then
-    AC_DEFINE([GENERIC_FILE_AIO_READ], 1, [define if your kernel has generic_file_aio_read()])
-  fi])
-
-AC_DEFUN([LINUX_HAVE_I_SIZE_READ], [
-  AC_MSG_CHECKING([for linux i_size_read()])
-  AC_CACHE_VAL([ac_cv_linux_i_size_read], [
-    save_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
-    AC_TRY_KBUILD(
-[#include <linux/fs.h>],
-[i_size_read(NULL);],
-      ac_cv_linux_i_size_read=yes,
-      ac_cv_linux_i_size_read=no)
-    CPPFLAGS="$save_CPPFLAGS"])
-  AC_MSG_RESULT($ac_cv_linux_i_size_read)
-  if test "x$ac_cv_linux_i_size_read" = "xyes"; then
-    AC_DEFINE([HAVE_LINUX_I_SIZE_READ], 1, [define if your kernel has i_size_read()])
-  fi])
-
-AC_DEFUN([LINUX_HAVE_D_ALLOC_ANON], [
-  AC_MSG_CHECKING([for linux d_alloc_anon()])
-  AC_CACHE_VAL([ac_cv_linux_d_alloc_anon], [
-    save_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
-    AC_TRY_KBUILD(
-[#include <linux/dcache.h>],
-[d_alloc_anon(NULL);],
-      ac_cv_linux_d_alloc_anon=yes,
-      ac_cv_linux_d_alloc_anon=no)
-    CPPFLAGS="$save_CPPFLAGS"])
-  AC_MSG_RESULT($ac_cv_linux_d_alloc_anon)
-  if test "x$ac_cv_linux_d_alloc_anon" = "xyes"; then
-    AC_DEFINE([HAVE_LINUX_D_ALLOC_ANON], 1, [define if your kernel has d_alloc_anon()])
-  fi])
-
 AC_DEFUN([LINUX_INIT_WORK_HAS_DATA], [
   AC_MSG_CHECKING([whether INIT_WORK has a _data argument])
   AC_CACHE_VAL([ac_cv_linux_init_work_has_data], [
@@ -835,16 +744,6 @@ _fop.splice_read(NULL, NULL, NULL, 0, 0);],
       ac_cv_linux_fs_struct_fop_has_splice=no)])
   AC_MSG_RESULT($ac_cv_linux_fs_struct_fop_has_splice)])
 
-AC_DEFUN([LINUX_HAVE_CURRENT_KERNEL_TIME], [
-  AC_MSG_CHECKING([for current_kernel_time()])
-  AC_CACHE_VAL([ac_cv_linux_have_current_kernel_time], [
-    AC_TRY_KBUILD(
-[#include <linux/time.h>],
-[struct timespec s = current_kernel_time();],
-      ac_cv_linux_have_current_kernel_time=yes,
-      ac_cv_linux_have_current_kernel_time=no)])
-  AC_MSG_RESULT($ac_cv_linux_have_current_kernel_time)])
-
 AC_DEFUN([LINUX_KMEM_CACHE_INIT], [
   AC_MSG_CHECKING([for new kmem_cache init function parameters])
   AC_CACHE_VAL([ac_cv_linux_kmem_cache_init], [
@@ -869,19 +768,6 @@ sysctl_check_table(NULL);],
  ac_cv_linux_sysctl_table_checking=yes)])
 AC_MSG_RESULT($ac_cv_linux_sysctl_table_checking)])
 
-AC_DEFUN([LINUX_HAVE_IGET], [
-  AC_MSG_CHECKING([for linux iget()])
-  AC_CACHE_VAL([ac_cv_linux_have_iget], [
-    save_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
-    AC_TRY_KBUILD(
-[#include <linux/fs.h>],
-[iget(NULL, NULL);],
-      ac_cv_linux_have_iget=yes,
-      ac_cv_linux_have_iget=no)
-    CPPFLAGS="$save_CPPFLAGS"])
-  AC_MSG_RESULT($ac_cv_linux_have_iget)])
-
 AC_DEFUN([LINUX_FS_STRUCT_NAMEIDATA_HAS_PATH], [
   AC_MSG_CHECKING([for path in struct nameidata])
   AC_CACHE_VAL([ac_cv_linux_struct_nameidata_has_path], [
@@ -893,33 +779,6 @@ printk("%x\n", _nd.path);],
       ac_cv_linux_struct_nameidata_has_path=no)])
   AC_MSG_RESULT($ac_cv_linux_struct_nameidata_has_path)])
 
-AC_DEFUN([LINUX_EXPORTS_RCU_READ_LOCK], [
-  AC_MSG_CHECKING([if rcu_read_lock is usable])
-  AC_CACHE_VAL([ac_cv_linux_exports_rcu_read_lock], [
-    AC_TRY_KBUILD(
-[#include <linux/rcupdate.h>],
-[rcu_read_lock();],
-      ac_cv_linux_exports_rcu_read_lock=yes,
-      ac_cv_linux_exports_rcu_read_lock=no)])
-  AC_MSG_RESULT($ac_cv_linux_exports_rcu_read_lock)
-  if test "x$ac_cv_linux_exports_rcu_read_lock" = "xyes"; then
-    AC_DEFINE([EXPORTED_RCU_READ_LOCK], 1, [define if rcu_read_lock() is usable])
-  fi])
-AC_DEFUN([LINUX_EXPORTS_FIND_TASK_BY_PID], [
-  AC_MSG_CHECKING([if find_task_by_pid is usable])
-  AC_CACHE_VAL([ac_cv_linux_exports_find_task_by_pid], [
-    AC_TRY_KBUILD(
-[#include <linux/sched.h>],
-[pid_t p;
-find_task_by_pid(p);],
-      ac_cv_linux_exports_find_task_by_pid=yes,
-      ac_cv_linux_exports_find_task_by_pid=no)])
-  AC_MSG_RESULT($ac_cv_linux_exports_find_task_by_pid)
-  if test "x$ac_cv_linux_exports_find_task_by_pid" = "xyes"; then
-    AC_DEFINE([EXPORTED_FIND_TASK_BY_PID], 1, [define if find_task_by_pid() is usable])
-  fi])
 AC_DEFUN([LINUX_EXPORTS_PROC_ROOT_FS], [
   AC_MSG_CHECKING([if proc_root_fs is defined and exported])
   AC_CACHE_VAL([ac_cv_linux_exports_proc_root_fs], [
@@ -961,18 +820,6 @@ _eops.fh_to_parent(NULL, NULL, 0, 0);],
     AC_DEFINE([NEW_EXPORT_OPS], 1, [define if kernel uses new export ops])
   fi])
  
-AC_DEFUN([LINUX_HAVE_BDI_INIT], [
-  AC_MSG_CHECKING([for linux bdi_init()])
-  AC_CACHE_VAL([ac_cv_linux_bdi_init], [
-    AC_TRY_KBUILD(
-[#include <linux/backing-dev.h>],
-[bdi_init(NULL);],
-      ac_cv_linux_bdi_init=yes,
-      ac_cv_linux_bdi_init=no)])
-  AC_MSG_RESULT($ac_cv_linux_bdi_init)
-  if test "x$ac_cv_linux_bdi_init" = "xyes"; then
-    AC_DEFINE([HAVE_BDI_INIT], 1, [define if your kernel has a bdi_init()])
-  fi])
 
 AC_DEFUN([LINUX_HAVE_WRITE_BEGIN_AOP], [
   AC_MSG_CHECKING([for linux write_begin() address space op])
@@ -988,44 +835,6 @@ _aop.write_begin = NULL;],
     AC_DEFINE([HAVE_WRITE_BEGIN], 1, [define if your kernel has a write_begin() address space op])
   fi])
 
-AC_DEFUN([LINUX_HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN], [
-  AC_MSG_CHECKING([for linux grab_cache_page_write_begin()])
-  AC_CACHE_VAL([ac_cv_linux_grab_cache_page_write_begin], [
-    AC_TRY_KBUILD(
-[#include <linux/pagemap.h>],
-[grab_cache_page_write_begin(NULL, 0, 0);],
-      ac_cv_linux_grab_cache_page_write_begin=yes,
-      ac_cv_linux_grab_cache_page_write_begin=no)])
-  AC_MSG_RESULT($ac_cv_linux_grab_cache_page_write_begin)
-  if test "x$ac_cv_linux_grab_cache_page_write_begin" = "xyes"; then
-    AC_DEFINE([HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN], 1, [define if your kernel has grab_cache_page_write_begin()])
-  fi])
-
-AC_DEFUN([LINUX_HAVE_PAGEVEC_LRU_ADD_FILE], [
-  AC_MSG_CHECKING([for linux __pagevec_lru_add_file()])
-  AC_CACHE_VAL([ac_cv_linux_pagevec_add_file], [
-    AC_TRY_KBUILD(
-[#include <linux/pagevec.h>],
-[__pagevec_lru_add_file(NULL);],
-      ac_cv_linux_pagevec_add_file=yes,
-      ac_cv_linux_pagevec_add_file=no)])
-  AC_MSG_RESULT($ac_cv_linux_pagevec_add_file)
-  if test "x$ac_cv_linux_pagevec_add_file" = "xyes"; then
-    AC_DEFINE([HAVE_PAGEVEC_LRU_ADD_FILE], 1, [define if your kernel has __pagevec_lru_add_file()])
-  fi])
-
-AC_DEFUN([LINUX_HAVE_SPLICE_DIRECT_TO_ACTOR], [
-  AC_MSG_CHECKING([for linux splice_direct_to_actor()])
-  AC_CACHE_VAL([ac_cv_linux_splice_direct_to_actor], [
-    AC_TRY_KBUILD(
-[#include <linux/splice.h>],
-[splice_direct_to_actor(NULL,NULL,NULL);],
-      ac_cv_linux_splice_direct_to_actor=yes,
-      ac_cv_linux_splice_direct_to_actor=no)])
-  AC_MSG_RESULT($ac_cv_linux_splice_direct_to_actor)
-  if test "x$ac_cv_linux_splice_direct_to_actor" = "xyes"; then
-    AC_DEFINE([HAVE_SPLICE_DIRECT_TO_ACTOR], 1, [define if your kernel has splice_direct_to_actor()])
-  fi])
 
 AC_DEFUN([LINUX_STRUCT_TASK_HAS_CRED], [
   AC_MSG_CHECKING([if struct task has cred])
@@ -1161,63 +970,13 @@ _bdi.name = NULL;],
     AC_DEFINE([STRUCT_BDI_HAS_NAME], 1, [define if struct backing_dev_info has a name member])
   fi])
 
-AC_DEFUN([LINUX_HAVE_ZERO_USER_SEGMENTS], [
-  AC_MSG_CHECKING([for zero_user_segments])
-  AC_CACHE_VAL([ac_cv_linux_have_zero_user_segments], [
-    AC_TRY_KBUILD(
-[#include <linux/highmem.h>],
-[zero_user_segments(NULL, 0, 0, 0, 0);],
-      ac_cv_linux_have_zero_user_segments=yes,
-      ac_cv_linux_have_zero_user_segments=no)])
-  AC_MSG_RESULT($ac_cv_linux_have_zero_user_segments)
-  if test "x$ac_cv_linux_have_zero_user_segments" = "xyes"; then
-    AC_DEFINE([HAVE_ZERO_USER_SEGMENTS], 1, [define if your kernel has the zero_user_segments function])
-  fi])
-
-AC_DEFUN([LINUX_HAVE_PAGE_OFFSET], [
-  AC_MSG_CHECKING([for page_offset])
-  AC_CACHE_VAL([ac_cv_linux_have_page_offset], [
-    AC_TRY_KBUILD(
-[#include <linux/pagemap.h>],
-[page_offset(NULL);],
-      ac_cv_linux_have_page_offset=yes,
-      ac_cv_linux_have_page_offset=no)])
-  AC_MSG_RESULT($ac_cv_linux_have_page_offset)
-  if test "x$ac_cv_linux_have_page_offset" = "xyes"; then
-    AC_DEFINE([HAVE_PAGE_OFFSET], 1, [define if your kernel has the page_offset function])
-  fi])
-
-AC_DEFUN([LINUX_HAVE_VFS_LLSEEK], [
-  AC_MSG_CHECKING([for vfs_llseek])
-  AC_CACHE_VAL([ac_cv_linux_have_vfs_llseek], [
-    AC_TRY_KBUILD(
-[#include <linux/fs.h>],
-[vfs_llseek(NULL, 0, 0);],
-      ac_cv_linux_have_vfs_llseek=yes,
-      ac_cv_linux_have_vfs_llseek=no)])
-  AC_MSG_RESULT($ac_cv_linux_have_vfs_llseek)
-  if test "x$ac_cv_linux_have_vfs_llseek" = "xyes"; then
-    AC_DEFINE([HAVE_VFS_LLSEEK], 1, [define if your kernel has the vfs_llseek function])
-  fi])
-
-AC_DEFUN([LINUX_HAVE_KERNEL_SETSOCKOPT], [
-  AC_MSG_CHECKING([for kernel_setsockopt])
-  AC_CACHE_VAL([ac_cv_linux_have_kernel_setsockopt], [
-    AC_TRY_KBUILD(
-[#include <linux/net.h>],
-[kernel_setsockopt(NULL, 0, 0, NULL, 0);],
-      ac_cv_linux_have_kernel_setsockopt=yes,
-      ac_cv_linux_have_kernel_setsockopt=no)])
-  AC_MSG_RESULT($ac_cv_linux_have_kernel_setsockopt)
-  if test "x$ac_cv_linux_have_kernel_setsockopt" = "xyes"; then
-    AC_DEFINE([HAVE_KERNEL_SETSOCKOPT], 1, [define if your kernel has the kernel_setsockopt function])
 
 AC_DEFUN([LINUX_HAVE_TRY_TO_FREEZE], [
   AC_MSG_CHECKING([for try_to_freeze])
-  AC_CACHE_VAL([ac_cv_linux_have_try_to_freeze], [
-    AC_TRY_KBUILD(
+  AC_CACHE_CHECK([for try_to_freeze], [ac_cv_linux_have_try_to_freeze],
+    [AC_TRY_KBUILD(
 [#include <linux/sched.h>
-#ifdef FREEZER_H_EXISTS
+#ifdef HAVE_LINUX_FREEZER_H
 #include <linux/freezer.h>
 #endif],
 [#ifdef LINUX_REFRIGERATOR_TAKES_PF_FREEZE
@@ -1228,8 +987,8 @@ AC_DEFUN([LINUX_HAVE_TRY_TO_FREEZE], [
 ],
       ac_cv_linux_have_try_to_freeze=yes,
       ac_cv_linux_have_try_to_freeze=no)])
-  AC_MSG_RESULT($ac_cv_linux_have_try_to_freeze)
-  if test "x$ac_cv_linux_have_try_to_freeze" = "xyes"; then
-    AC_DEFINE([HAVE_TRY_TO_FREEZE], 1, [define if your kernel has the try_to_freeze function])
-  fi])
+  AS_IF([test "x$ac_cv_linux_have_try_to_freeze" = "xyes"],
+        [AC_DEFINE([HAVE_TRY_TO_FREEZE], 1,
+                   [define if your kernel has the try_to_freeze function])])
+ ])