From be5aaf113e59608ab670a8331401cb9d10feb2d2 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Tue, 15 Jan 2013 10:52:07 -0800 Subject: [PATCH] Improve compilability on Linux 3.5. --- config-linuxmodule.h.in | 3 + configure | 144 ++++++++++++++++++++++++---------------- configure.in | 87 ++++++++++++------------ linuxmodule/clickfs.cc | 4 ++ linuxmodule/read-pmc.c | 1 - 5 files changed, 140 insertions(+), 99 deletions(-) diff --git a/config-linuxmodule.h.in b/config-linuxmodule.h.in index 1906885e50..033cfe0ae3 100644 --- a/config-linuxmodule.h.in +++ b/config-linuxmodule.h.in @@ -52,6 +52,9 @@ /* Define if your Linux kernel has files_lglock. */ #undef HAVE_LINUX_FILES_LGLOCK +/* Define if you have the d_make_root function. */ +#undef HAVE_LINUX_D_MAKE_ROOT + /* Define if your Linux kernel has dev_ioctl. */ #undef HAVE_LINUX_DEV_IOCTL diff --git a/configure b/configure index 86526f268f..35af882d3f 100755 --- a/configure +++ b/configure @@ -10861,6 +10861,58 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_aware_system" >&5 $as_echo "$ac_cv_cxx_aware_system" >&6; } + if test $ac_cv_cxx_aware_system = yes; then + DRIVERS="$DRIVERS linuxmodule" + TOOL_TARGETS="$TOOL_TARGETS click-install" + $as_echo "#define HAVE_LINUXMODULE_DRIVER 1" >>confdefs.h + + HAVE_LINUXMODULE_DRIVER=1 + elif test x$enable_linuxmodule_default = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: +========================================= + +Your Linux kernel header files cause errors when included by a C++ program, +so I won't try to compile the linuxmodule driver. + +Click modifies the Linux kernel's header files to make them work with +C++, using the program 'linuxmodule/fixincludes.pl'. It looks like +your kernel header files have features that 'linuxmodule/fixincludes.pl' +doesn't know how to fix. You can report this error to us on the Click +mailing list, or, even better, try to fix the error. See the config.log +file for more information on the error. + +=========================================" >&5 +$as_echo "$as_me: WARNING: +========================================= + +Your Linux kernel header files cause errors when included by a C++ program, +so I won't try to compile the linuxmodule driver. + +Click modifies the Linux kernel's header files to make them work with +C++, using the program 'linuxmodule/fixincludes.pl'. It looks like +your kernel header files have features that 'linuxmodule/fixincludes.pl' +doesn't know how to fix. You can report this error to us on the Click +mailing list, or, even better, try to fix the error. See the config.log +file for more information on the error. + +=========================================" >&2;} + else + as_fn_error $? " +========================================= + +Your Linux kernel header files cause errors when included by a C++ program. + +Click modifies the Linux kernel's header files to make them work with +C++, using the program 'linuxmodule/fixincludes.pl'. It looks like +your kernel header files have features that 'linuxmodule/fixincludes.pl' +doesn't know how to fix. You can report this error to us on the Click +mailing list, or, even better, try to fix the error. See the config.log +file for more information on the error. + +=========================================" "$LINENO" 5 + fi + + if test $ac_cv_cxx_aware_system = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long and int64_t are the same type in the Linux kernel" >&5 $as_echo_n "checking whether long and int64_t are the same type in the Linux kernel... " >&6; } @@ -11954,6 +12006,40 @@ $as_echo "#define HAVE_LINUX_ATOMIC_CMPXCHG 1" >>confdefs.h fi + ac_fn_c_check_decl "$LINENO" "d_make_root" "ac_cv_have_decl_d_make_root" "#if HAVE_LINUXMODULE_2_6 +# define KBUILD_STR(s) #s +# define KBUILD_BASENAME KBUILD_STR(click) +# define KBUILD_MODNAME KBUILD_STR(click) +#endif +#define new linux_new +#define this linux_this +#define delete linux_delete +#define class linux_class +#define virtual linux_virtual +#define typename linux_typename +#define private linux_private +#define protected linux_protected +#define public linux_public +#define namespace linux_namespace +#define false linux_false +#define true linux_true +#define CLICK_CXX_PROTECTED 1 +$linux_autoconf_include +#include +#include +" +if test "x$ac_cv_have_decl_d_make_root" = xyes; then : + ac_cv_linux_d_make_root=yes +else + ac_cv_linux_d_make_root=no +fi + + if test $ac_cv_linux_d_make_root = yes; then + +$as_echo "#define HAVE_LINUX_D_MAKE_ROOT 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for netdev_rx_handler_register kernel symbol" >&5 $as_echo_n "checking for netdev_rx_handler_register kernel symbol... " >&6; } if ${ac_cv_linux_netdev_rx_handler_register+:} false; then : @@ -12002,69 +12088,13 @@ $as_echo "$ac_cv_linux_getboottime" >&6; } fi + fi CC="$save_cc" CXX="$save_cxx" CPPFLAGS="$save_cppflags" CFLAGS="$save_cflags" CXXFLAGS="$save_cxxflags" export CFLAGS CPPFLAGS - - if test $ac_cv_cxx_aware_system = yes; then - DRIVERS="$DRIVERS linuxmodule" - TOOL_TARGETS="$TOOL_TARGETS click-install" - $as_echo "#define HAVE_LINUXMODULE_DRIVER 1" >>confdefs.h - - HAVE_LINUXMODULE_DRIVER=1 - elif test x$enable_linuxmodule_default = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: -========================================= - -Your Linux kernel header files cause errors when included by a C++ program, -so I won't try to compile the linuxmodule driver. - -There are two common reasons for this error: -1. You have not applied the Linux kernel patch that comes with this - distribution. Apply the right patch and try again. See the INSTALL - file for more information. -2. Your Linux configuration enables some functionality that is not yet - covered by our patches. Turn off this functionality and try again, - or fix the error and tell us how you did it. See the config.log file - for more detailed information on the error. - -=========================================" >&5 -$as_echo "$as_me: WARNING: -========================================= - -Your Linux kernel header files cause errors when included by a C++ program, -so I won't try to compile the linuxmodule driver. - -There are two common reasons for this error: -1. You have not applied the Linux kernel patch that comes with this - distribution. Apply the right patch and try again. See the INSTALL - file for more information. -2. Your Linux configuration enables some functionality that is not yet - covered by our patches. Turn off this functionality and try again, - or fix the error and tell us how you did it. See the config.log file - for more detailed information on the error. - -=========================================" >&2;} - else - as_fn_error $? " -========================================= - -Your Linux kernel header files cause errors when included by a C++ program. - -There are two common reasons for this error: -1. You have not applied the Linux kernel patch that comes with this - distribution. Apply the right patch and try again. See the INSTALL - file for more information. -2. Your Linux configuration enables some functionality that is not yet - covered by our patches. Turn off this functionality and try again, - or fix the error and tell us how you did it. See the config.log file - for more detailed information on the error. - -=========================================" "$LINENO" 5 - fi fi diff --git a/configure.in b/configure.in index 2b0db1c870..748094ca0e 100644 --- a/configure.in +++ b/configure.in @@ -1336,6 +1336,44 @@ $linux_autoconf_include #include ]], [[return 0]])], ac_cv_cxx_aware_system=yes, ac_cv_cxx_aware_system=no) ]) + if test $ac_cv_cxx_aware_system = yes; then + DRIVERS="$DRIVERS linuxmodule" + TOOL_TARGETS="$TOOL_TARGETS click-install" + AC_DEFINE(HAVE_LINUXMODULE_DRIVER) + HAVE_LINUXMODULE_DRIVER=1 + elif test x$enable_linuxmodule_default = xyes; then + AC_MSG_WARN([ +========================================= + +Your Linux kernel header files cause errors when included by a C++ program, +so I won't try to compile the linuxmodule driver. + +Click modifies the Linux kernel's header files to make them work with +C++, using the program 'linuxmodule/fixincludes.pl'. It looks like +your kernel header files have features that 'linuxmodule/fixincludes.pl' +doesn't know how to fix. You can report this error to us on the Click +mailing list, or, even better, try to fix the error. See the config.log +file for more information on the error. + +=========================================]) + dnl ' fix syntax highlighting + else + AC_MSG_ERROR([ +========================================= + +Your Linux kernel header files cause errors when included by a C++ program. + +Click modifies the Linux kernel's header files to make them work with +C++, using the program 'linuxmodule/fixincludes.pl'. It looks like +your kernel header files have features that 'linuxmodule/fixincludes.pl' +doesn't know how to fix. You can report this error to us on the Click +mailing list, or, even better, try to fix the error. See the config.log +file for more information on the error. + +=========================================]) + fi + + if test $ac_cv_cxx_aware_system = yes; then AC_CACHE_CHECK([whether long and int64_t are the same type in the Linux kernel], ac_cv_long_64_linuxmodule, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([CLICK_LINUXMODULE_PROLOGUE()[ @@ -1542,6 +1580,12 @@ CFLAGS="$save_cflags" AC_DEFINE([HAVE_LINUX_ATOMIC_CMPXCHG], [1], [Define if you have the atomic_cmpxchg function.]) fi + AC_CHECK_DECL([d_make_root], [ac_cv_linux_d_make_root=yes], [ac_cv_linux_d_make_root=no], [CLICK_LINUXMODULE_PROLOGUE()[ +#include ]]) + if test $ac_cv_linux_d_make_root = yes; then + AC_DEFINE([HAVE_LINUX_D_MAKE_ROOT], [1], [Define if you have the d_make_root function.]) + fi + AC_CACHE_CHECK(for netdev_rx_handler_register kernel symbol, ac_cv_linux_netdev_rx_handler_register, [if grep "__ksymtab_netdev_rx_handler_register" $linux_system_map >/dev/null 2>&1; then ac_cv_linux_netdev_rx_handler_register=yes @@ -1566,53 +1610,14 @@ CFLAGS="$save_cflags" AC_DEFINE(HAVE_LINUX_GETBOOTTIME) fi + fi dnl ac_cv_cxx_aware_system + CC="$save_cc" CXX="$save_cxx" CPPFLAGS="$save_cppflags" CFLAGS="$save_cflags" CXXFLAGS="$save_cxxflags" export CFLAGS CPPFLAGS - - if test $ac_cv_cxx_aware_system = yes; then - DRIVERS="$DRIVERS linuxmodule" - TOOL_TARGETS="$TOOL_TARGETS click-install" - AC_DEFINE(HAVE_LINUXMODULE_DRIVER) - HAVE_LINUXMODULE_DRIVER=1 - elif test x$enable_linuxmodule_default = xyes; then - AC_MSG_WARN([ -========================================= - -Your Linux kernel header files cause errors when included by a C++ program, -so I won't try to compile the linuxmodule driver. - -There are two common reasons for this error: -1. You have not applied the Linux kernel patch that comes with this - distribution. Apply the right patch and try again. See the INSTALL - file for more information. -2. Your Linux configuration enables some functionality that is not yet - covered by our patches. Turn off this functionality and try again, - or fix the error and tell us how you did it. See the config.log file - for more detailed information on the error. - -=========================================]) - dnl ' fix syntax highlighting - else - AC_MSG_ERROR([ -========================================= - -Your Linux kernel header files cause errors when included by a C++ program. - -There are two common reasons for this error: -1. You have not applied the Linux kernel patch that comes with this - distribution. Apply the right patch and try again. See the INSTALL - file for more information. -2. Your Linux configuration enables some functionality that is not yet - covered by our patches. Turn off this functionality and try again, - or fix the error and tell us how you did it. See the config.log file - for more detailed information on the error. - -=========================================]) - fi fi diff --git a/linuxmodule/clickfs.cc b/linuxmodule/clickfs.cc index 7f6cc5706b..d4d83ea62a 100644 --- a/linuxmodule/clickfs.cc +++ b/linuxmodule/clickfs.cc @@ -358,7 +358,11 @@ click_read_super(struct super_block *sb, void * /* data */, int) UNLOCK_CONFIG_READ(); if (!root_inode) goto out_no_root; +#if HAVE_LINUX_D_MAKE_ROOT + sb->s_root = d_make_root(root_inode); +#else sb->s_root = d_alloc_root(root_inode); +#endif MDEBUG("got root inode %p:%p", root_inode, root_inode->i_op); if (!sb->s_root) goto out_no_root; diff --git a/linuxmodule/read-pmc.c b/linuxmodule/read-pmc.c index d7c1a58c7d..dcb8bd72ab 100644 --- a/linuxmodule/read-pmc.c +++ b/linuxmodule/read-pmc.c @@ -18,7 +18,6 @@ #include #include #include -#include #if __i386__ || __x86_64__ # include #endif