Skip to content

Commit

Permalink
Compile with libc's without cispeed / cospeed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
npat-efault committed Apr 12, 2018
1 parent eb0f53a commit 1acf1dd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions custbaud.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@
#ifndef CUSTBAUD_H
#define CUSTBAUD_H

#include <termios.h>

#ifndef NO_CUSTOM_BAUD

#if defined (__linux__)

/* Enable by-default for kernels > 2.6.0 on x86 and x86_64 only */
#include <linux/version.h>
#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
Expand Down Expand Up @@ -87,7 +95,6 @@

#endif /* of ndef NO_CUSTOM_BAUD else */

#include <termios.h>

int use_custom_baud();
int cfsetispeed_custom(struct termios *tios, int speed);
Expand Down

0 comments on commit 1acf1dd

Please sign in to comment.