1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

Fix building on Cygwin.

There were two issues: first, feature test macros were only defined
for __linux__, so defintions we needed were not included. Enable the
same feature test macros for __CYGWIN__.

Second, the Cygwin headers do not define TIOCOUTQ, needed to use
ioctl() to get the number of bytes in the output queue. Return
SP_ERR_SUPP on Cygwin for this operation.

This fixes bug #963.
This commit is contained in:
Martin Ling 2020-01-25 14:51:56 +00:00 committed by Uwe Hermann
parent f6abee5c78
commit 2be41b1265
2 changed files with 8 additions and 2 deletions

View File

@ -27,8 +27,8 @@
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif
/* These Linux/glibc specific defines must appear before other headers.*/ /* These feature test macros must appear before other headers.*/
#ifdef __linux__ #if defined(__linux__) || defined(__CYGWIN__)
/* For timeradd, timersub, timercmp, realpath. */ /* For timeradd, timersub, timercmp, realpath. */
#define _BSD_SOURCE 1 /* for glibc < 2.19 */ #define _BSD_SOURCE 1 /* for glibc < 2.19 */
#define _DEFAULT_SOURCE 1 /* for glibc >= 2.20 */ #define _DEFAULT_SOURCE 1 /* for glibc >= 2.20 */

View File

@ -1307,6 +1307,11 @@ SP_API enum sp_return sp_output_waiting(struct sp_port *port)
{ {
TRACE("%p", port); TRACE("%p", port);
#ifdef __CYGWIN__
/* TIOCOUTQ is not defined in Cygwin headers */
RETURN_ERROR(SP_ERR_SUPP,
"Getting output bytes waiting is not supported on Cygwin");
#else
CHECK_OPEN_PORT(); CHECK_OPEN_PORT();
DEBUG_FMT("Checking output bytes waiting on port %s", port->name); DEBUG_FMT("Checking output bytes waiting on port %s", port->name);
@ -1324,6 +1329,7 @@ SP_API enum sp_return sp_output_waiting(struct sp_port *port)
RETURN_FAIL("TIOCOUTQ ioctl failed"); RETURN_FAIL("TIOCOUTQ ioctl failed");
RETURN_INT(bytes_waiting); RETURN_INT(bytes_waiting);
#endif #endif
#endif
} }
SP_API enum sp_return sp_new_event_set(struct sp_event_set **result_ptr) SP_API enum sp_return sp_new_event_set(struct sp_event_set **result_ptr)