Skip to content

Commit

Permalink
Include <linux/version.h> by default, and autoconf.h when necessary.
Browse files Browse the repository at this point in the history
Also autodetect the Linux kernel's possible uintptr_t typedef.

Based on awesome work by Adam Greenhalgh and Joonwoo Park.
  • Loading branch information
Eddie Kohler committed Sep 10, 2008
1 parent b8de4c8 commit 398adb8
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 5 deletions.
1 change: 0 additions & 1 deletion click-buildtool.in
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,6 @@ EOF

cat <<EOF
#include <click/config.h>
#include <linux/version.h>
#include <linux/module.h>
/* a new version of EXPORT_NO_SYMBOLS that works */
Expand Down
14 changes: 11 additions & 3 deletions config-linuxmodule.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,24 @@
/* Define if you have the netif_tx_lock function. */
#undef HAVE_NETIF_TX_LOCK

/* Define to 1 if Linux defines the type 'uintptr_t'. */
#undef HAVE_UINTPTR_T_LINUXMODULE

/* Define if fast checksum functions require correct alignment. */
#ifndef __i386__
# define FAST_CHECKSUM_ALIGNED 1
#endif

/* Include integer type definitions. */
#include <linux/autoconf.h>
/* Include Linux configuration and type definitions. */
#ifndef AUTOCONF_INCLUDED
# include <linux/autoconf.h>
#endif
#include <linux/version.h>
#include <linux/types.h>
typedef ptrdiff_t intptr_t;
typedef unsigned long uintptr_t; /* XXX? */
#if !HAVE_UINTPTR_T_LINUXMODULE
typedef unsigned long uintptr_t;
#endif

/* Define HAVE_INT64_IS_LONG based on HAVE_INT64_IS_LONG_LINUXMODULE. */
#ifdef HAVE_INT64_IS_LONG_LINUXMODULE
Expand Down
75 changes: 75 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -16514,6 +16514,81 @@ _ACEOF
fi


{ echo "$as_me:$LINENO: checking whether uintptr_t is defined in the Linux kernel" >&5
echo $ECHO_N "checking whether uintptr_t is defined in the Linux kernel... $ECHO_C" >&6; }
if test "${ac_cv_uintptr_t_linuxmodule+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#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 xxx_new
#define this xxx_this
#define delete xxx_delete
#define class xxx_class
#define virtual xxx_virtual
#define typename xxx_typename
#define private xxx_private
#define protected xxx_protected
#define public xxx_public
#define namespace xxx_namespace
#include <linux/autoconf.h>
#include <linux/types.h>

int
main ()
{
uintptr_t i = 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_cxx_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_uintptr_t_linuxmodule=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

ac_cv_uintptr_t_linuxmodule=no
fi

rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_uintptr_t_linuxmodule" >&5
echo "${ECHO_T}$ac_cv_uintptr_t_linuxmodule" >&6; }
if test $ac_cv_uintptr_t_linuxmodule = yes; then

cat >>confdefs.h <<\_ACEOF
#define HAVE_UINTPTR_T_LINUXMODULE 1
_ACEOF

fi


{ echo "$as_me:$LINENO: checking whether struct sk_buff has a security member" >&5
echo $ECHO_N "checking whether struct sk_buff has a security member... $ECHO_C" >&6; }
if test "${ac_cv_linuxmodule_skbuff_security+set}" = set; then
Expand Down
9 changes: 9 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,15 @@ void f1(int64_t) { // will fail if long long and int64_t are the same type
fi


AC_CACHE_CHECK([whether uintptr_t is defined in the Linux kernel],
ac_cv_uintptr_t_linuxmodule, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([CLICK_LINUXMODULE_PROLOGUE()[
#include <linux/types.h>
]], [[uintptr_t i = 0;]])], ac_cv_uintptr_t_linuxmodule=yes, ac_cv_uintptr_t_linuxmodule=no)])
if test $ac_cv_uintptr_t_linuxmodule = yes; then
AC_DEFINE([HAVE_UINTPTR_T_LINUXMODULE], [1], [Define to 1 if Linux defines the type 'uintptr_t'.])
fi


AC_CACHE_CHECK([whether struct sk_buff has a security member], [ac_cv_linuxmodule_skbuff_security],
[AC_LANG_C
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([CLICK_LINUXMODULE_PROLOGUE()[
Expand Down
1 change: 0 additions & 1 deletion include/click/glue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ CLICK_CXX_PROTECT
# define HAVE_MOD_USE_COUNT 1
# endif
# include <linux/kernel.h>
# include <linux/version.h>
# include <linux/string.h>
# include <linux/skbuff.h>
# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
Expand Down

0 comments on commit 398adb8

Please sign in to comment.