Linux: Simplify header file checks

Provide an autoconf macro to perform tests for the existence of
Linux kernel header files. Use this to standardise the naming of
header file presence #defines, and to simplify the linux tests.

Change-Id: I49629679db56c5f9a39487bd78fc2e59d5da0269
Reviewed-on: http://gerrit.openafs.org/1844
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Simon Wilkinson 2010-04-26 21:34:17 +01:00 committed by Derrick Brashear
parent a0259edcac
commit ef8bd5a29b
16 changed files with 59 additions and 127 deletions

View File

@ -51,7 +51,6 @@ AH_BOTTOM([
#undef AFS_NAMEI_ENV
#undef BITMAP_LATER
#undef FAST_RESTART
#undef COMPLETION_H_EXISTS
#undef DEFINED_FOR_EACH_PROCESS
#undef DEFINED_PREV_TASK
#undef EXPORTED_KALLSYMS_SYMBOL
@ -823,10 +822,10 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID
LINUX_D_PATH_TAKES_STRUCT_PATH
LINUX_NEW_EXPORT_OPS
LINUX_CONFIG_H_EXISTS
LINUX_COMPLETION_H_EXISTS
LINUX_SEMAPHORE_H_EXISTS
LINUX_EXPORTFS_H_EXISTS
AC_CHECK_LINUX_HEADER([config.h])
AC_CHECK_LINUX_HEADER([completion.h])
AC_CHECK_LINUX_HEADER([semaphore.h])
AC_CHECK_LINUX_HEADER([exportfs.h])
LINUX_DEFINES_FOR_EACH_PROCESS
LINUX_DEFINES_PREV_TASK
LINUX_FS_STRUCT_SUPER_HAS_ALLOC_INODE
@ -848,14 +847,14 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
LINUX_FS_STRUCT_FOP_HAS_FLOCK
LINUX_FS_STRUCT_FOP_HAS_SENDFILE
LINUX_FS_STRUCT_FOP_HAS_SPLICE
LINUX_KERNEL_LINUX_SEQ_FILE_H
AC_CHECK_LINUX_HEADER([seq_file.h])
LINUX_KERNEL_POSIX_LOCK_FILE_WAIT_ARG
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
LINUX_KEY_TYPE_H_EXISTS
AC_CHECK_LINUX_HEADER([key-type.h])
LINUX_EXPORTS_KEY_TYPE_KEYRING
LINUX_KEYS_HAVE_SESSION_TO_PARENT
LINUX_NEED_RHCONFIG
@ -874,11 +873,8 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
LINUX_EXPORTS_TASKLIST_LOCK
LINUX_GET_SB_HAS_STRUCT_VFSMOUNT
LINUX_STATFS_TAKES_DENTRY
LINUX_FREEZER_H_EXISTS
AC_CHECK_LINUX_HEADER([freezer.h])
LINUX_HAVE_SVC_ADDR_IN
if test "x$ac_cv_linux_freezer_h_exists" = "xyes" ; then
AC_DEFINE(FREEZER_H_EXISTS, 1, [define if you have linux/freezer.h])
fi
LINUX_REFRIGERATOR
LINUX_LINUX_KEYRING_SUPPORT
LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK
@ -960,18 +956,6 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
if test "x$ac_cv_linux_exports_kallsyms_address" = "xyes"; then
AC_DEFINE(EXPORTED_KALLSYMS_ADDRESS, 1, [define if your linux kernel exports kallsyms address])
fi
if test "x$ac_cv_linux_completion_h_exists" = "xyes" ; then
AC_DEFINE(COMPLETION_H_EXISTS, 1, [define if completion_h exists])
fi
if test "x$ac_cv_linux_config_h_exists" = "xyes" ; then
AC_DEFINE(CONFIG_H_EXISTS, 1, [define if config.h exists])
fi
if test "x$ac_cv_linux_exportfs_h_exists" = "xyes"; then
AC_DEFINE(EXPORTFS_H_EXISTS, 1, [define if linux/exportfs.h exists])
fi
if test "x$ac_cv_linux_key_type_h_exists" = "xyes" ; then
AC_DEFINE(KEY_TYPE_H_EXISTS, 1, [define if key-type.h exists])
fi
if test "x$ac_cv_linux_defines_for_each_process" = "xyes" ; then
AC_DEFINE(DEFINED_FOR_EACH_PROCESS, 1, [define if for_each_process defined])
fi
@ -1011,9 +995,6 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
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_linux_seq_file" = "xyes" ; then
AC_DEFINE(HAVE_KERNEL_LINUX_SEQ_FILE_H, 1, [define if your linux kernel has linux/seq_file.h])
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
@ -1056,9 +1037,6 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
if test "x$ac_cv_linux_func_a_writepage_takes_writeback_control" = "xyes" ; then
AC_DEFINE(AOP_WRITEPAGE_TAKES_WRITEBACK_CONTROL, 1, [define if your aops.writepage takes a struct writeback_control argument])
fi
if test "x$ac_cv_linux_func_refrigerator_takes_pf_freeze" = "xyes" ; then
AC_DEFINE(LINUX_REFRIGERATOR_TAKES_PF_FREEZE, 1, [define if your refrigerator takes PF_FREEZE])
fi
if test "x$ac_cv_linux_func_i_create_takes_nameidata" = "xyes" ; then
AC_DEFINE(IOP_CREATE_TAKES_NAMEIDATA, 1, [define if your iops.create takes a nameidata argument])
fi

View File

@ -17,7 +17,7 @@
#include <linux/module.h> /* early to avoid printf->printk mapping */
#include <linux/fs.h>
#ifdef EXPORTFS_H_EXISTS
#ifdef HAVE_LINUX_EXPORTFS_H
#include <linux/exportfs.h>
#endif
#include "afs/sysincludes.h"

View File

@ -62,7 +62,7 @@
#endif
#include <linux/version.h>
#include <linux/sched.h>
#ifdef CONFIG_H_EXISTS
#ifdef HAVE_LINUX_CONFIG_H
# include <linux/config.h>
#endif
#include <linux/linkage.h>

View File

@ -16,7 +16,7 @@
#include <linux/module.h> /* early to avoid printf->printk mapping */
#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
#ifdef HAVE_LINUX_SEQ_FILE_H
#include <linux/seq_file.h>
#endif
#include "afs/sysincludes.h"
@ -37,7 +37,7 @@
struct proc_dir_entry *openafs_procfs;
#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
#ifdef HAVE_LINUX_SEQ_FILE_H
static void *c_start(struct seq_file *m, loff_t *pos)
{
struct afs_q *cq, *tq;
@ -245,7 +245,7 @@ static struct file_operations afs_unixuser_fops = {
};
#else /* HAVE_KERNEL_LINUX_SEQ_FILE_H */
#else /* HAVE_LINUX_SEQ_FILE_H */
static int
csdbproc_info(char *buffer, char **start, off_t offset, int
@ -314,7 +314,7 @@ done:
return len;
}
#endif /* HAVE_KERNEL_LINUX_SEQ_FILE_H */
#endif /* HAVE_LINUX_SEQ_FILE_H */
void
osi_proc_init(void)
@ -330,7 +330,7 @@ osi_proc_init(void)
sprintf(path, "fs/%s", PROC_FSDIRNAME);
openafs_procfs = proc_mkdir(path, NULL);
#endif
#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
#ifdef HAVE_LINUX_SEQ_FILE_H
entry = create_proc_entry("unixusers", 0, openafs_procfs);
if (entry) {
entry->proc_fops = &afs_unixuser_fops;
@ -357,7 +357,7 @@ osi_proc_clean(void)
#endif
remove_proc_entry(PROC_CELLSERVDB_NAME, openafs_procfs);
#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
#ifdef HAVE_LINUX_SEQ_FILE_H
remove_proc_entry("unixusers", openafs_procfs);
#endif
#if defined(EXPORTED_PROC_ROOT_FS)

View File

@ -14,8 +14,7 @@
#include "afs/sysincludes.h" /* Standard vendor system headers */
#include "afsincludes.h" /* Afs-based standard headers */
#include "afs/afs_stats.h" /* afs statistics */
#if defined(FREEZER_H_EXISTS)
#if defined(HAVE_LINUX_FREEZER_H)
#include <linux/freezer.h>
#endif

View File

@ -14,7 +14,7 @@
#include "afs/afs_stats.h" /* afs statistics */
#include <linux/sysctl.h>
#ifdef CONFIG_H_EXISTS
#ifdef HAVE_LINUX_CONFIG_H
#include <linux/config.h>
#endif

View File

@ -61,7 +61,7 @@
#endif
#include <linux/version.h>
#include <linux/sched.h>
#ifdef CONFIG_H_EXISTS
#ifdef HAVE_LINUX_CONFIG_H
#include <linux/config.h>
#endif
#include <linux/linkage.h>

View File

@ -16,7 +16,7 @@
#include <linux/module.h> /* early to avoid printf->printk mapping */
#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
#ifdef HAVE_LINUX_SEQ_FILE_H
#include <linux/seq_file.h>
#endif
#include "afs/sysincludes.h"
@ -37,7 +37,7 @@
struct proc_dir_entry *openafs_procfs;
#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
#ifdef HAVE_LINUX_SEQ_FILE_H
static void *c_start(struct seq_file *m, loff_t *pos)
{
struct afs_q *cq, *tq;
@ -245,7 +245,7 @@ static struct file_operations afs_unixuser_fops = {
};
#else /* HAVE_KERNEL_LINUX_SEQ_FILE_H */
#else /* HAVE_LINUX_SEQ_FILE_H */
static int
csdbproc_info(char *buffer, char **start, off_t offset, int
@ -314,7 +314,7 @@ done:
return len;
}
#endif /* HAVE_KERNEL_LINUX_SEQ_FILE_H */
#endif /* HAVE_LINUX_SEQ_FILE_H */
void
osi_proc_init(void)
@ -330,7 +330,7 @@ osi_proc_init(void)
sprintf(path, "fs/%s", PROC_FSDIRNAME);
openafs_procfs = proc_mkdir(path, NULL);
#endif
#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
#ifdef HAVE_LINUX_SEQ_FILE_H
entry = create_proc_entry("unixusers", 0, openafs_procfs);
if (entry) {
entry->proc_fops = &afs_unixuser_fops;
@ -357,7 +357,7 @@ osi_proc_clean(void)
#endif
remove_proc_entry(PROC_CELLSERVDB_NAME, openafs_procfs);
#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
#ifdef HAVE_LINUX_SEQ_FILE_H
remove_proc_entry("unixusers", openafs_procfs);
#endif
#if defined(EXPORTED_PROC_ROOT_FS)

View File

@ -15,7 +15,7 @@
#include "afsincludes.h" /* Afs-based standard headers */
#include "afs/afs_stats.h" /* afs statistics */
#if defined(FREEZER_H_EXISTS)
#if defined(HAVE_LINUX_FREEZER_H)
#include <linux/freezer.h>
#endif

View File

@ -14,7 +14,7 @@
#include "afs/afs_stats.h" /* afs statistics */
#include <linux/sysctl.h>
#ifdef CONFIG_H_EXISTS
#ifdef HAVE_LINUX_CONFIG_H
#include <linux/config.h>
#endif

View File

@ -246,7 +246,7 @@ afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5,
#endif
#if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS)
#if defined(AFS_LINUX24_ENV) && defined(HAVE_LINUX_COMPLETION_H)
struct afsd_thread_info {
#if defined(AFS_LINUX26_ENV) && !defined(INIT_WORK_HAS_DATA)
struct work_struct tq;
@ -523,7 +523,7 @@ afs_syscall_call(long parm, long parm2, long parm3,
#ifdef AFS_DARWIN80_ENV
put_vfs_context();
#endif
#if ((defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS)) || defined(AFS_DARWIN80_ENV)) && !defined(UKERNEL)
#if ((defined(AFS_LINUX24_ENV) && defined(HAVE_LINUX_COMPLETION_H)) || defined(AFS_DARWIN80_ENV)) && !defined(UKERNEL)
#if defined(AFS_DARWIN80_ENV)
if (parm == AFSOP_BKG_HANDLER) {
/* if afs_uspc_param grows this should be checked */

View File

@ -53,7 +53,7 @@
#elif defined(AFS_LINUX22_ENV)
# include <linux/version.h>
# ifdef CONFIG_H_EXISTS
# ifdef HAVE_LINUX_CONFIG_H
# include <linux/config.h>
# endif
# include <linux/linkage.h>
@ -75,7 +75,7 @@
# if defined(LINUX_KEYRING_SUPPORT)
# include <linux/rwsem.h>
# include <linux/key.h>
# if defined(KEY_TYPE_H_EXISTS)
# if defined(HAVE_LINUX_KEY_TYPE_H)
# include <linux/key-type.h>
# endif
# ifndef KEY_ALLOC_IN_QUOTA
@ -108,7 +108,7 @@ struct xfs_inode_info {
# include <linux/mm.h>
# include <linux/slab.h>
# include <linux/string.h>
# if defined(LINUX_SEMAPHORE_H)
# if defined(HAVE_LINUX_SEMAPHORE_H)
# include <linux/semaphore.h>
# else
# include <asm/semaphore.h>
@ -117,7 +117,7 @@ struct xfs_inode_info {
# include <linux/mutex.h>
# endif
# include <linux/errno.h>
# ifdef COMPLETION_H_EXISTS
# ifdef HAVE_LINUX_COMPLETION_H
# include <linux/completion.h>
# endif
# if defined(LINUX_USE_FH)

View File

@ -84,3 +84,19 @@ AC_DEFUN([LINUX_KBUILD_USES_EXTRA_CFLAGS], [
ac_linux_kbuild_requires_extra_cflags=yes)
CPPFLAGS="$save_CPPFLAGS"
AC_MSG_RESULT($ac_linux_kbuild_requires_extra_cflags)])
dnl AC_CHECK_LINUX_HEADER(header)
AC_DEFUN([AC_CHECK_LINUX_HEADER],
[AS_VAR_PUSHDEF([ac_linux_header], [ac_cv_linux_header_$1])dnl
AC_CACHE_CHECK([for linux/$1], [ac_linux_header],
[AC_TRY_KBUILD([#include <linux/$1>],
[return;],
AS_VAR_SET([ac_linux_header], [yes]),
AS_VAR_SET([ac_linux_header], [no]))
])
AS_IF([test AS_VAR_GET([ac_linux_header]) = yes],
[AC_DEFINE(AS_TR_CPP(HAVE_LINUX_$1),
1,
[Define if your kernel has linux/$1])])
])

View File

@ -31,7 +31,7 @@ else
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $RHCONFIG_SP $CPPFLAGS"
AC_MSG_CHECKING(which kernel modules to build)
if test "x$ac_cv_linux_config_h_exists" = "xyes"; then
if test "x$ac_cv_linux_header_config_h" = "xyes"; then
CPPFLAGS="-DCONFIG_H_EXISTS $CPPFLAGS"
fi
if test "x$ac_linux_rhconfig" = "xyes"; then

View File

@ -13,24 +13,9 @@ read_lock(&tasklist_lock);
AC_MSG_RESULT($ac_cv_linux_exports_tasklist_lock)])
AC_DEFUN([LINUX_CONFIG_H_EXISTS], [
AC_MSG_CHECKING([for linux/config.h existance])
AC_CACHE_VAL([ac_cv_linux_config_h_exists], [
AC_TRY_KBUILD(
[#include <linux/config.h>],
[return;],
ac_cv_linux_config_h_exists=yes,
ac_cv_linux_config_h_exists=no)])
AC_MSG_RESULT($ac_cv_linux_config_h_exists)
if test "x$ac_cv_linux_config_h_exists" = "xyes"; then
AC_DEFINE([CONFIG_H_EXISTS], 1, [define if linux/config.h exists])
fi])
AC_DEFUN([LINUX_COMPLETION_H_EXISTS], [
AC_MSG_CHECKING([for linux/completion.h existance])
AC_CACHE_VAL([ac_cv_linux_completion_h_exists], [
AC_TRY_KBUILD(
AC_CACHE_CHECK([for linux/completion.h], [ac_cv_linux_completion_h_exists],
[AC_TRY_KBUILD(
[#include <linux/version.h>
#include <linux/completion.h>],
[struct completion _c;
@ -39,17 +24,10 @@ lose
#endif],
ac_cv_linux_completion_h_exists=yes,
ac_cv_linux_completion_h_exists=no)])
AC_MSG_RESULT($ac_cv_linux_completion_h_exists)])
AC_DEFUN([LINUX_EXPORTFS_H_EXISTS], [
AC_MSG_CHECKING([for linux/exportfs.h existence])
AC_CACHE_VAL([ac_cv_linux_exportfs_h_exists], [
AC_TRY_KBUILD(
[#include <linux/exportfs.h>],
[return;],
ac_cv_linux_exportfs_h_exists=yes,
ac_cv_linux_exportfs_h_exists=no)])
AC_MSG_RESULT($ac_cv_linux_exportfs_h_exists)])
AS_IF([test "x$ac_linux_completion_h_exists" = xyes],
[AC_DEFINE(HAVE_LINUX_COMPLETION_H, 1,
[Define if your kernel has a usable linux/completion.h])])
])
AC_DEFUN([LINUX_DEFINES_FOR_EACH_PROCESS], [
AC_MSG_CHECKING([for defined for_each_process])
@ -499,7 +477,7 @@ AC_DEFUN([LINUX_REFRIGERATOR], [
AC_CACHE_VAL([ac_cv_linux_func_refrigerator_takes_pf_freeze], [
AC_TRY_KBUILD(
[#include <linux/sched.h>
#ifdef FREEZER_H_EXISTS
#ifdef HAVE_LINUX_FREEZER_H
#include <linux/freezer.h>
#endif],
[refrigerator(PF_FREEZE);],
@ -606,25 +584,12 @@ extern int vfs_statfs(struct dentry *, struct kstatfs *);
AC_MSG_RESULT($ac_cv_linux_statfs_takes_dentry)])
AC_DEFUN([LINUX_KEY_TYPE_H_EXISTS], [
AC_MSG_CHECKING([for linux/key-type.h existance])
AC_CACHE_VAL([ac_cv_linux_key_type_h_exists], [
AC_TRY_KBUILD(
[#include <linux/key-type.h>],
[return;],
ac_cv_linux_key_type_h_exists=yes,
ac_cv_linux_key_type_h_exists=no)])
AC_MSG_RESULT($ac_cv_linux_key_type_h_exists)
if test "x$ac_cv_linux_key_type_h_exists" = "xyes"; then
AC_DEFINE([KEY_TYPE_H_EXISTS], 1, [define if linux/key-type.h exists])
fi])
AC_DEFUN([LINUX_LINUX_KEYRING_SUPPORT], [
AC_MSG_CHECKING([for linux kernel keyring support])
AC_CACHE_VAL([ac_cv_linux_keyring_support], [
AC_TRY_KBUILD(
[#include <linux/rwsem.h>
#ifdef KEY_TYPE_H_EXISTS
#ifdef HAVE_LINUX_KEY_TYPE_H
#include <linux/key-type.h>
#endif
#include <linux/key.h>
@ -746,19 +711,6 @@ AC_DEFUN([LINUX_HAVE_D_ALLOC_ANON], [
AC_DEFINE([HAVE_LINUX_D_ALLOC_ANON], 1, [define if your kernel has d_alloc_anon()])
fi])
AC_DEFUN([LINUX_FREEZER_H_EXISTS], [
AC_MSG_CHECKING([for linux/freezer.h existance])
AC_CACHE_VAL([ac_cv_linux_freezer_h_exists], [
AC_TRY_KBUILD(
[#include <linux/freezer.h>],
[return;],
ac_cv_linux_freezer_h_exists=yes,
ac_cv_linux_freezer_h_exists=no)])
AC_MSG_RESULT($ac_cv_linux_freezer_h_exists)
if test "x$ac_cv_linux_freezer_h_exists" = "xyes"; then
AC_DEFINE([FREEZER_H_EXISTS], 1, [define if linux/freezer.h exists])
fi])
AC_DEFUN([LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_TODO], [
AC_MSG_CHECKING([for todo in struct task_struct])
AC_CACHE_VAL([ac_cv_linux_sched_struct_task_struct_has_todo], [
@ -1018,19 +970,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_SEMAPHORE_H_EXISTS], [
AC_MSG_CHECKING([for linux/semaphore.h existance])
AC_CACHE_VAL([ac_cv_linux_semaphore_h_exists], [
AC_TRY_KBUILD(
[#include <linux/semaphore.h>],
[return;],
ac_cv_linux_semaphore_h_exists=yes,
ac_cv_linux_semaphore_h_exists=no)])
AC_MSG_RESULT($ac_cv_linux_semaphore_h_exists)
if test "x$ac_cv_linux_semaphore_h_exists" = "xyes"; then
AC_DEFINE([LINUX_SEMAPHORE_H], 1, [define if linux/semaphore.h exists])
fi])
AC_DEFUN([LINUX_HAVE_BDI_INIT], [
AC_MSG_CHECKING([for linux bdi_init()])
AC_CACHE_VAL([ac_cv_linux_bdi_init], [
@ -1162,7 +1101,7 @@ AC_DEFUN([LINUX_EXPORTS_KEY_TYPE_KEYRING], [
AC_CACHE_VAL([ac_cv_linux_exports_key_type_keyring], [
AC_TRY_KBUILD(
[
#ifdef KEY_TYPE_H_EXISTS
#ifdef HAVE_LINUX_KEY_TYPE_H
#include <linux/key-type.h>
#endif
#include <linux/key.h>],

View File

@ -112,7 +112,7 @@ typedef unsigned short etap_event_t;
#endif
#ifdef AFS_LINUX22_ENV
#include "h/sched.h"
#if defined(FREEZER_H_EXISTS)
#if defined(HAVE_LINUX_FREEZER_H)
#include "h/freezer.h"
#endif
#include "h/netdevice.h"