[gjs/wip/ptomato/windows: 1/2] gi/function.cpp, util/log.cpp: Allow build on Windows



commit fadddccb7bae1ee9b67ec3229e73995527845cff
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jan 16 15:38:13 2017 +0800

    gi/function.cpp, util/log.cpp: Allow build on Windows
    
    Windows compilers may not ship with unistd.h, as unistd.h on Windows is
    essentially a wrapper that includes items like io.h and process.h that
    contains the functions we need from UNIX's unistd.h, plus some POSIX
    macros defines.  Also, for function.cpp, remove the includes for
    sys/mman.h and unistd.h, as they were unneeded.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775868

 gi/function.cpp |    3 +--
 util/log.cpp    |   11 ++++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 7d72c59..c38bbca 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -40,8 +40,7 @@
 #include <util/log.h>
 
 #include <girepository.h>
-#include <sys/mman.h>
-#include <unistd.h>
+
 #include <errno.h>
 #include <string.h>
 
diff --git a/util/log.cpp b/util/log.cpp
index f787cbd..bacb12b 100644
--- a/util/log.cpp
+++ b/util/log.cpp
@@ -31,7 +31,16 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <unistd.h>
+
+#ifdef G_OS_WIN32
+# include <io.h>
+# include <process.h>
+# ifndef F_OK
+#  define F_OK 0
+# endif
+#else
+# include <unistd.h>
+#endif
 
 /* prefix is allowed if it's in the ;-delimited environment variable
  * GJS_DEBUG_TOPICS or if that variable is not set.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]