MSVC: Use <io.h> as an alternative for <unistd.h>
authorAdrian Perez de Castro <aperez@igalia.com>
Mon, 5 Aug 2019 10:52:18 +0000 (13:52 +0300)
committerRan Benita <ran234@gmail.com>
Sat, 28 Dec 2019 14:12:15 +0000 (16:12 +0200)
Only the input/output functions from <unistd.h> options are used, so
using <io.h> when building with MSVC should be enough. The inclusion
of the header in context-priv.c does not seem to be needed (tested
on GNU/Linux) and so it is removed.

Signed-off-by: Ran Benita <ran@unusedvar.com>
src/context-priv.c
src/context.c
test/common.c
test/context.c

index dc85651eaeeb32183421fb1860ffa5efb8640383..3c1544035d386a0f543c67cd91d15b1aff8ead2d 100644 (file)
@@ -29,7 +29,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include <unistd.h>
 
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
index 9fac0abba1a24d5cd29e66a8271459b320b37cc1..fbb48dc8aa4dcd7029612321ba7d7be9b139fb45 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include <unistd.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <io.h>
+# ifndef S_ISDIR
+#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# endif
+#else
+# include <unistd.h>
+#endif
 
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
index 3784d8b1ab76f991e36dc32b7ff78579519ec736..446ce58a0329b881d22fb16b98fe114f5f4805e0 100644 (file)
 
 #include <limits.h>
 #include <fcntl.h>
+#ifdef _MSC_VER
+#include <io.h>
+#else
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <termios.h>
index 13d47a1a687ba00214c5b4ad1a762316f77055ce..2f5fd37dc955d76151c132884a06cd4d4cc5723e 100644 (file)
 
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <unistd.h>
+#ifdef _MSC_VER
+# include <io.h>
+# include <direct.h>
+# ifndef S_ISDIR
+#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# endif
+#else
+# include <unistd.h>
+#endif
 
 /* keeps a cache of all makedir/maketmpdir directories so we can free and
  * rmdir them in one go, see unmakedirs() */