b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From 6fad89a36968fe1bf6aed63f44b7e2e375271e76 Mon Sep 17 00:00:00 2001 |
| 2 | From: Nick Patavalis <npat@efault.net> |
| 3 | Date: Thu, 12 Apr 2018 15:16:04 +0300 |
| 4 | Subject: [PATCH] Compile with libc's without cispeed / cospeed |
| 5 | |
| 6 | Some libc implementations (e.g. musl) do not define the cispeed and |
| 7 | cospeed struct termios fields. So we have to check the |
| 8 | _HAVE_STRUCT_TERMIOS_C_ISPEED and _HAVE_STRUCT_TERMIOS_C_OSPEED |
| 9 | macros. If not defined, we disable custom baudrate support. |
| 10 | --- |
| 11 | custbaud.h | 10 +++++++++- |
| 12 | 1 file changed, 9 insertions(+), 1 deletion(-) |
| 13 | |
| 14 | --- a/custbaud.h |
| 15 | +++ b/custbaud.h |
| 16 | @@ -26,6 +26,8 @@ |
| 17 | #ifndef CUSTBAUD_H |
| 18 | #define CUSTBAUD_H |
| 19 | |
| 20 | +#include <termios.h> |
| 21 | + |
| 22 | #ifndef NO_CUSTOM_BAUD |
| 23 | |
| 24 | #if defined (__linux__) |
| 25 | @@ -33,7 +35,13 @@ |
| 26 | /* Enable by-default for kernels > 2.6.0 on x86 and x86_64 only */ |
| 27 | #include <linux/version.h> |
| 28 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) |
| 29 | -#if defined (__i386__) || defined (__x86_64__) || defined (USE_CUSTOM_BAUD) |
| 30 | +/* Some libc implementations (e.g. musl) do not define the cispeed and |
| 31 | + cospeed struct termios fields. We do not support custom baudrates |
| 32 | + on them. */ |
| 33 | +#if ( (defined (__i386__) || defined (__x86_64__)) \ |
| 34 | + && defined (_HAVE_STRUCT_TERMIOS_C_ISPEED) \ |
| 35 | + && defined (_HAVE_STRUCT_TERMIOS_C_OSPEED) ) \ |
| 36 | + || defined (USE_CUSTOM_BAUD) |
| 37 | #ifndef USE_CUSTOM_BAUD |
| 38 | #define USE_CUSTOM_BAUD |
| 39 | #endif |