Skip to content

Commit

Permalink
Provide checks before initiating HAVE_DECL_IOSSIOSPEED
Browse files Browse the repository at this point in the history
  • Loading branch information
William Goodspeed committed Jan 6, 2025
1 parent 300b103 commit 3058628
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@
*/
#undef HAVE_DECL_GETW

/* Define to 1 if you have the declaration of 'IOSSIOSPEED', and to 0 if you
don't. */
#undef HAVE_DECL_IOSSIOSPEED

/* Define to 1 if you have the declaration of 'program_invocation_name', and
to 0 if you don't. */
#undef HAVE_DECL_PROGRAM_INVOCATION_NAME
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ AC_CHECK_DECLS([B115200],[], AC_MSG_ERROR([B115200 not supported by header]), [[
# Non-POSIX baudrates
AC_CHECK_DECLS([B230400, B460800, B500000, B576000, B921600, B1000000, B1152000, B1500000, B2000000],[], [], [[#include <termios.h>]])

# MACOS-Specific customized baudrate
AC_CHECK_DECLS([IOSSIOSPEED],[], [], [[#include <IOKit/serial/ioss.h>]])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_SIZE_T
Expand Down
7 changes: 4 additions & 3 deletions src/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#include <termios.h>
#include <errno.h>
#include <fcntl.h>
#ifdef __APPLE__

#if defined(__APPLE__) && defined(HAVE_DECL_IOSSIOSPEED)
#include <IOKit/serial/ioss.h> // IOSSIOSPEED
#endif

Expand Down Expand Up @@ -78,7 +79,7 @@ static inline int uart_open (int *fd, const char *ttydev, int baud)
}

if (!speed_found) {
#ifndef __APPLE__
#if !defined(__APPLE__) || !defined(HAVE_DECL_IOSSIOSPEED)
fprintf(stderr,
"failed to switch to baud %d,"
"maybe your system doesn't support it?\n",
Expand Down Expand Up @@ -109,7 +110,7 @@ static inline int uart_open (int *fd, const char *ttydev, int baud)
goto err;
}

#ifdef __APPLE__
#if defined(__APPLE__) && defined(HAVE_DECL_IOSSIOSPEED)
/*
Mac OS X Tiger(10.4.11) support non-standard baud rate
through IOSSIOSPEED
Expand Down
2 changes: 1 addition & 1 deletion src/ws63flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
break;
}

#ifndef __APPLE__
#if !defined(__APPLE__) || !defined(HAVE_DECL_IOSSIOSPEED)
if (!speed_found) {
fprintf(stderr,
"Target baud %d not found,"
Expand Down

0 comments on commit 3058628

Please sign in to comment.