From 63cb02bd3cd217700d094c1f1c4611295e45b9c5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 5 Sep 2011 13:17:20 +0100 Subject: [PATCH] Deal with backported bool type for RHEL5's 2.6.18 kernel RHEL5's 2.6.18 kernel includes a change backported from 2.6.19 that declares a generic 'bool' type in and declares the 'false' and 'true' enum values in . Comedi's compatibility header for declared the 'false' and 'true' enum values for any kernel version below 2.6.19. This resulted in comedi failing to build due to redeclaration errors. Add an autoconf test to see if the generic 'bool' type is defined in and if so define the macro CONFIG_COMEDI_HAVE_GENERIC_BOOL_TYPE in . Conditionally declare the 'bool' type in the compatibility header and change the condition for declaring the 'false' and 'true' enum values in the compatibility header so they are only declared if the CONFIG_COMEDI_HAVE_GENERIC_BOOL_TYPE macro is undefined. Signed-off-by: Ian Abbott --- configure.ac | 6 ++++++ include/linux/stddef.h | 2 +- include/linux/types.h | 4 ++++ m4/as-linux.m4 | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fce7325c..85a9f770 100644 --- a/configure.ac +++ b/configure.ac @@ -158,6 +158,12 @@ if test "$HAVE_CS_TYPES_H" = "yes" ; then AC_DEFINE([CONFIG_COMEDI_HAVE_CS_H],[true],[Define if Linux kernel source has pcmcia/cs.h (removed in 2.6.37)]) fi +COMEDI_CHECK_HAVE_GENERIC_BOOL_TYPE([$LINUX_SRC_DIR], + [HAVE_GENERIC_BOOL_TYPE="yes"], [HAVE_GENERIC_BOOL_TYPE="no"]) +if test "$HAVE_GENERIC_BOOL_TYPE" = "yes" ; then + AC_DEFINE([CONFIG_COMEDI_HAVE_GENERIC_BOOL_TYPE],[true],[Define if Linux kernel source has generic 'bool' type in linux/types.h]) +fi + AS_CHECK_LINUX_CONFIG_OPTION([CONFIG_USB],[HAVE_USB="yes"],[HAVE_USB="yes"],[HAVE_USB="no"]) AM_CONDITIONAL([CONFIG_USB],[test "$HAVE_USB" = "yes"]) AC_ARG_ENABLE([usb],[ --disable-usb Disable support for USB devices], diff --git a/include/linux/stddef.h b/include/linux/stddef.h index 747ef183..6a1840a7 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -21,7 +21,7 @@ #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) +#ifndef CONFIG_COMEDI_HAVE_GENERIC_BOOL_TYPE typedef enum { false, true diff --git a/include/linux/types.h b/include/linux/types.h index 98c012dc..0afbf71d 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -27,6 +27,10 @@ typedef unsigned long resource_size_t; /* resource_size_t is either u32 or u64, depending on CONFIG_RESOURCES_64BIT */ #endif +#ifndef CONFIG_COMEDI_HAVE_GENERIC_BOOL_TYPE +typedef _Bool bool; +#endif + #include_next #endif diff --git a/m4/as-linux.m4 b/m4/as-linux.m4 index 2e2ee9d8..93107ea9 100644 --- a/m4/as-linux.m4 +++ b/m4/as-linux.m4 @@ -953,3 +953,21 @@ AC_DEFUN([COMEDI_CHECK_HAVE_LINUX_SEMAPHORE_H], $3 fi ]) + +# COMEDI_CHECK_HAVE_GENERIC_BOOL_TYPE([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# ------------------------------------------------------------- +# Check if kernel is new enough to have generic 'bool' type in +# and 'false' and 'true' enum constants in . This was added +# in vanilla 2.6.19, but backported to RHEL5 2.6.18. +AC_DEFUN([COMEDI_CHECK_HAVE_GENERIC_BOOL_TYPE], +[ + AC_MSG_CHECKING([$1 for 'bool' in include/linux/types.h]) + if grep -q 'bool;' "$1/include/linux/types.h" 2>/dev/null; then + AC_MSG_RESULT([yes]) + $2 + else + AC_MSG_RESULT([no]) + $3 + fi +]) -- 2.26.2