MSVC: Use <io.h> as an alternative for <unistd.h> 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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/src/context-priv.c b/src/context-priv.c
index dc85651..3c15440 100644
--- a/src/context-priv.c
+++ b/src/context-priv.c
@@ -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"
diff --git a/src/context.c b/src/context.c
index 9fac0ab..fbb48dc 100644
--- a/src/context.c
+++ b/src/context.c
@@ -29,7 +29,15 @@
#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"
diff --git a/test/common.c b/test/common.c
index 3784d8b..446ce58 100644
--- a/test/common.c
+++ b/test/common.c
@@ -34,7 +34,11 @@
#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>
diff --git a/test/context.c b/test/context.c
index 13d47a1..2f5fd37 100644
--- a/test/context.c
+++ b/test/context.c
@@ -30,7 +30,15 @@
#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() */