]> sigrok.org Git - libserialport.git/blobdiff - libserialport_internal.h
Use O_CLOEXEC where available
[libserialport.git] / libserialport_internal.h
index 3f01b6dae5f6ccf5456e77610793236d4182d517..d784472bb12d0c218413d645ff38e3dec8588da3 100644 (file)
@@ -53,6 +53,7 @@
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
+#include <time.h>
 #include <poll.h>
 #endif
 #ifdef __APPLE__
@@ -61,6 +62,7 @@
 #include <IOKit/serial/IOSerialKeys.h>
 #include <IOKit/serial/ioss.h>
 #include <sys/syslimits.h>
+#include <mach/mach_time.h>
 #endif
 #ifdef __linux__
 #include <dirent.h>
 #define TIOCOUTQ FIONWRITE
 #endif
 
+/*
+ * O_CLOEXEC is not available everywhere, fallback to not setting the
+ * flag on those systems.
+ */
+#ifndef _WIN32
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+#endif
+
 /* Non-standard baudrates are not available everywhere. */
 #if (defined(HAVE_TERMIOS_SPEED) || defined(HAVE_TERMIOS2_SPEED)) && HAVE_DECL_BOTHER
 #define USE_TERMIOS_SPEED