]> sigrok.org Git - libserialport.git/commitdiff
linux: Check for BOTHER macro at configure time.
authorMartin Ling <redacted>
Wed, 24 Sep 2014 19:04:39 +0000 (20:04 +0100)
committerUwe Hermann <redacted>
Sat, 1 Nov 2014 17:36:09 +0000 (18:36 +0100)
This fixes bug #363.

configure.ac
libserialport_internal.h
linux_termios.c

index 96d5277bb23a5204682365a0582ea2f04d823250..f8123d21aa7769defe0fe607b784f7a4fcae182b 100644 (file)
@@ -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 <linux/termios.h>]])
 
+# 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 <linux/termios.h>
+]],
+[[
+#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 <linux/serial.h>]])
index 8ef8376f9a5d29b1b176adcb4b9bb879b8049b86..28c307602063032809a50c5402b877044736ff8e 100644 (file)
@@ -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
 
index 23c7ae96539c9d5155a243102e55e09045c9cd7d..92793df06d61b7de6d63bd3624a097e4b57ae280 100644 (file)
@@ -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