# Check for specific termios structures.
AC_CHECK_TYPE([struct termios2], [AC_DEFINE(HAVE_TERMIOS2, 1)], [], [[#include <linux/termios.h>]])
AC_CHECK_TYPE([struct termiox], [AC_DEFINE(HAVE_TERMIOX, 1)], [], [[#include <linux/termios.h>]])
+AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
+ [AC_DEFINE(HAVE_TERMIOS_SPEED, 1)], [], [[#include <linux/termios.h>]])
+AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
+ [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include <linux/termios.h>]])
AC_SUBST(MAKEFLAGS, '--no-print-directory')
AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
* TCSETX/TCGETX ioctls used with struct termiox, others do not.
*/
-#if defined(__linux__) && !defined(__ANDROID__)
-
#include <linux/termios.h>
#include "linux_termios.h"
#endif
}
+#ifdef USE_TERMIOS_SPEED
int get_termios_speed(void *data)
{
#ifdef HAVE_TERMIOS2
term->c_cflag |= BOTHER;
term->c_ispeed = term->c_ospeed = speed;
}
+#endif
#ifdef HAVE_TERMIOX
int get_termiox_size(void)
termx->x_cflag |= DSRXON;
}
#endif
-
-#endif
#define TIOCOUTQ FIONWRITE
#endif
+/* Non-standard baudrates are not available everywhere. */
+#if defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED)
+#define USE_TERMIOS_SPEED
+#endif
+
#include "libserialport.h"
struct sp_port {
#endif
}
-#ifdef __linux__
+#ifdef USE_TERMIOS_SPEED
static enum sp_return get_baudrate(int fd, int *baudrate)
{
void *data;
RETURN_OK();
}
+#endif /* USE_TERMIOS_SPEED */
#ifdef USE_TERMIOX
static enum sp_return get_flow(int fd, struct port_data *data)
RETURN_OK();
}
#endif /* USE_TERMIOX */
-#endif /* __linux__ */
static enum sp_return get_config(struct sp_port *port, struct port_data *data,
struct sp_port_config *config)
if (i == NUM_STD_BAUDRATES) {
#ifdef __APPLE__
config->baudrate = (int)data->term.c_ispeed;
-#elif defined(__linux__)
+#elif defined(USE_TERMIOS_SPEED)
TRY(get_baudrate(port->fd, &config->baudrate));
#else
config->baudrate = -1;
baud_nonstd = B0;
#endif
-#ifdef __linux__
+#ifdef USE_TERMIOS_SPEED
int baud_nonstd = 0;
#endif
if (cfsetspeed(&data->term, B9600) < 0)
RETURN_FAIL("cfsetspeed() failed");
baud_nonstd = config->baudrate;
-#elif defined(__linux__)
+#elif defined(USE_TERMIOS_SPEED)
baud_nonstd = 1;
#else
RETURN_ERROR(SP_ERR_SUPP, "Non-standard baudrate not supported");
RETURN_FAIL("cfsetspeed() failed");
}
#elif defined(__linux__)
+#ifdef USE_TERMIOS_SPEED
if (baud_nonstd)
TRY(set_baudrate(port->fd, config->baudrate));
+#endif
#ifdef USE_TERMIOX
if (data->termiox_supported)
TRY(set_flow(port->fd, data));