From 1acf1ddabaf3576b4023c4f6f09c5a3e4b086fb8 Mon Sep 17 00:00:00 2001 From: Nick Patavalis Date: Thu, 12 Apr 2018 15:16:04 +0300 Subject: [PATCH] Compile with libc's without cispeed / cospeed Some libc implementations (e.g. musl) do not define the cispeed and cospeed struct termios fields. So we have to check the _HAVE_STRUCT_TERMIOS_C_ISPEED and _HAVE_STRUCT_TERMIOS_C_OSPEED macros. If not defined, we disable custom baudrate support. --- custbaud.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/custbaud.h b/custbaud.h index 120aa89..c1734ce 100644 --- a/custbaud.h +++ b/custbaud.h @@ -26,6 +26,8 @@ #ifndef CUSTBAUD_H #define CUSTBAUD_H +#include + #ifndef NO_CUSTOM_BAUD #if defined (__linux__) @@ -33,7 +35,13 @@ /* Enable by-default for kernels > 2.6.0 on x86 and x86_64 only */ #include #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) -#if defined (__i386__) || defined (__x86_64__) || defined (USE_CUSTOM_BAUD) +/* Some libc implementations (e.g. musl) do not define the cispeed and + cospeed struct termios fields. We do not support custom baudrates + on them. */ +#if ( (defined (__i386__) || defined (__x86_64__)) \ + && defined (_HAVE_STRUCT_TERMIOS_C_ISPEED) \ + && defined (_HAVE_STRUCT_TERMIOS_C_OSPEED) ) \ + || defined (USE_CUSTOM_BAUD) #ifndef USE_CUSTOM_BAUD #define USE_CUSTOM_BAUD #endif @@ -87,7 +95,6 @@ #endif /* of ndef NO_CUSTOM_BAUD else */ -#include int use_custom_baud(); int cfsetispeed_custom(struct termios *tios, int speed);