From 59182fbbbf79b31552f84f875485bfaee1a34270 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Wed, 24 Sep 2014 20:04:39 +0100 Subject: [PATCH] linux: Check for BOTHER macro at configure time. This fixes bug #363. --- configure.ac | 15 +++++++++++++++ libserialport_internal.h | 2 +- linux_termios.c | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 96d5277..f8123d2 100644 --- a/configure.ac +++ b/configure.ac @@ -119,6 +119,21 @@ AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed], AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed], [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include ]]) +# Check for the BOTHER definition, needed for setting arbitrary baud rates. +# We can't just #ifdef BOTHER in the code, because of the separation between +# code using libc headers and code using kernel termios.h headers. +AC_MSG_CHECKING(for BOTHER) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +]], +[[ +#ifndef BOTHER +#error BOTHER is not defined +#endif +]])], +[AC_DEFINE(HAVE_BOTHER, 1) +AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) + # Check for serial_struct. AC_CHECK_TYPE([struct serial_struct], [AC_DEFINE(HAVE_SERIAL_STRUCT, 1)], [], [[#include ]]) diff --git a/libserialport_internal.h b/libserialport_internal.h index 8ef8376..28c3076 100644 --- a/libserialport_internal.h +++ b/libserialport_internal.h @@ -78,7 +78,7 @@ #endif /* Non-standard baudrates are not available everywhere. */ -#if defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED) +#if (defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED)) && defined(HAVE_BOTHER) #define USE_TERMIOS_SPEED #endif diff --git a/linux_termios.c b/linux_termios.c index 23c7ae9..92793df 100644 --- a/linux_termios.c +++ b/linux_termios.c @@ -64,7 +64,7 @@ SP_PRIV size_t get_termios_size(void) #endif } -#if defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED) +#if (defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED)) && defined(HAVE_BOTHER) SP_PRIV int get_termios_speed(void *data) { #ifdef HAVE_TERMIOS2