void (*sp_debug_handler)(const char *format, ...) = sp_default_debug_handler;
-static void get_time(struct timeval *time);
-
static enum sp_return get_config(struct sp_port *port, struct port_data *data,
struct sp_port_config *config);
static enum sp_return set_config(struct sp_port *port, struct port_data *data,
const struct sp_port_config *config);
+#ifndef _WIN32
static void get_time(struct timeval *time)
{
#ifdef HAVE_CLOCK_GETTIME
gettimeofday(time, NULL);
#endif
}
+#endif
SP_API enum sp_return sp_get_port_by_name(const char *portname, struct sp_port **port_ptr)
{
RETURN_CODEVAL(ret);
}
#else
- int flags_local = O_NONBLOCK | O_NOCTTY;
+ int flags_local = O_NONBLOCK | O_NOCTTY | O_CLOEXEC;
/* Map 'flags' to the OS-specific settings. */
if ((flags & SP_MODE_READ_WRITE) == SP_MODE_READ_WRITE)
#else
int result;
while (1) {
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && (__ANDROID_API__ < 21)
+ /* Android only has tcdrain from platform 21 onwards.
+ * On previous API versions, use the ioctl directly. */
int arg = 1;
result = ioctl(port->fd, TCSBRK, &arg);
#else