[gjs/meson.msvc: 1/5] gjs/*.cpp, util/*.cpp: Check for sys/signal.h and _WIN32
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/meson.msvc: 1/5] gjs/*.cpp, util/*.cpp: Check for sys/signal.h and _WIN32
- Date: Mon, 28 Oct 2019 08:21:26 +0000 (UTC)
commit ee20ae4c7fe73aafd000f73f83fd4d89b9aba9b1
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Oct 25 15:25:01 2019 +0800
gjs/*.cpp, util/*.cpp: Check for sys/signal.h and _WIN32
Add a configure-time check for sys/signal.h and only include it in the
sources when it is found. For context.h, since it is public, only
include it when we are not building for Windows (i.e. _WIN32 is not
defined), because it does not exist for Windows.
Also, we might be checking for G_OS_WIN32 before we include the GLib
headers, so check for the presence of _WIN32 in those cases, since it
will be defined by default on all compilers targeting Windows.
configure.ac | 2 +-
doc/CPP_Style_Guide.md | 2 +-
gjs/console.cpp | 2 ++
gjs/context.cpp | 2 ++
gjs/context.h | 5 ++++-
gjs/debugger.cpp | 2 +-
gjs/engine.cpp | 2 +-
gjs/importer.cpp | 2 +-
gjs/jsapi-util.cpp | 2 +-
gjs/profiler.cpp | 6 ++++--
meson.build | 1 +
util/log.cpp | 2 +-
win32/config.h.win32.in | 3 +++
13 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 259e9632..d6b405ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,7 @@ AC_LANG([C++])
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_14
-AC_CHECK_HEADERS([sys/syscall.h unistd.h])
+AC_CHECK_HEADERS([sys/signal.h sys/syscall.h unistd.h])
LT_PREREQ([2.2.0])
# no stupid static libraries
diff --git a/doc/CPP_Style_Guide.md b/doc/CPP_Style_Guide.md
index 321c843a..0fb3be79 100644
--- a/doc/CPP_Style_Guide.md
+++ b/doc/CPP_Style_Guide.md
@@ -451,7 +451,7 @@ Here is an example of all of the above rules together:
#include <string.h> // for strlen
-#ifdef XP_WIN
+#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
diff --git a/gjs/console.cpp b/gjs/console.cpp
index b094f07e..04d25050 100644
--- a/gjs/console.cpp
+++ b/gjs/console.cpp
@@ -29,6 +29,8 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h> // for close
+#elif defined (_WIN32)
+# include <io.h>
#endif
#include <gio/gio.h>
diff --git a/gjs/context.cpp b/gjs/context.cpp
index a9e871ab..ce38ebd5 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -31,6 +31,8 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h> // for getpid
+#elif defined (_WIN32)
+# include <process.h>
#endif
#include <new>
diff --git a/gjs/context.h b/gjs/context.h
index a02deb0b..b173c32c 100644
--- a/gjs/context.h
+++ b/gjs/context.h
@@ -29,7 +29,10 @@
#endif
#include <stdbool.h> /* IWYU pragma: keep */
-#include <sys/signal.h> /* for siginfo_t */
+
+#ifndef _WIN32
+# include <sys/signal.h> /* for siginfo_t */
+#endif
#include <glib-object.h>
#include <glib.h>
diff --git a/gjs/debugger.cpp b/gjs/debugger.cpp
index 05db7ced..217e3a28 100644
--- a/gjs/debugger.cpp
+++ b/gjs/debugger.cpp
@@ -34,7 +34,7 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h> // for isatty, STDIN_FILENO
-#elif defined(XP_WIN)
+#elif defined(_WIN32)
# include <io.h>
# ifndef STDIN_FILENO
# define STDIN_FILENO 0
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index 2b61d98b..359bcc77 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -23,7 +23,7 @@
#include <stdint.h>
-#ifdef G_OS_WIN32
+#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 8d0d7401..72e2cb61 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -23,7 +23,7 @@
#include <string.h> // for size_t, strcmp, strlen
-#ifdef G_OS_WIN32
+#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 6804aeaf..d76dec55 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -25,7 +25,7 @@
#include <stdio.h> // for sscanf
#include <string.h> // for strlen
-#ifdef XP_WIN
+#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp
index cce5792c..7321a93f 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -21,9 +21,11 @@
* IN THE SOFTWARE.
*/
-#include <config.h> // for ENABLE_PROFILER, HAVE_SYS_SYSCALL_H, HAVE_UNISTD_H
+#include <config.h> // for ENABLE_PROFILER, HAVE_SYS_SYSCALL_H, HAVE_UNISTD_H, HAVE_SYS_SIGNAL_H
-#include <sys/signal.h> // for siginfo_t, sigevent, ...
+#ifdef HAVE_SYS_SIGNAL_H
+# include <sys/signal.h> // for siginfo_t, sigevent, ...
+#endif
#include <glib-object.h>
#include <glib.h>
diff --git a/meson.build b/meson.build
index 523a71e1..76ff07e7 100644
--- a/meson.build
+++ b/meson.build
@@ -302,6 +302,7 @@ if build_readline
endif
header_conf.set('HAVE_SYS_SYSCALL_H', cxx.check_header('sys/syscall.h'))
header_conf.set('HAVE_UNISTD_H', cxx.check_header('unistd.h'))
+header_conf.set('HAVE_SYS_SIGNAL_H', cxx.check_header('sys/signal.h'))
# enable GNU extensions on systems that have them
header_conf.set('_GNU_SOURCE', 1)
diff --git a/util/log.cpp b/util/log.cpp
index 4286a408..4361fc81 100644
--- a/util/log.cpp
+++ b/util/log.cpp
@@ -26,7 +26,7 @@
#include <stdio.h> // for FILE, fprintf, fflush, fopen, fputs, fseek
#include <string.h> // for strchr, strcmp
-#ifdef G_OS_WIN32
+#ifdef _WIN32
# include <io.h>
# include <process.h>
# ifndef F_OK
diff --git a/win32/config.h.win32.in b/win32/config.h.win32.in
index d9a526ad..8e3e1a8c 100644
--- a/win32/config.h.win32.in
+++ b/win32/config.h.win32.in
@@ -47,6 +47,9 @@
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
+/* Define to 1 if you have the <sys/signal.h> header file. */
+/* #undef HAVE_SYS_SIGNAL_H */
+
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]