[gjs/gnome-3-34] gjs/*.cpp, util/*.cpp: Check for sys/signal.h and _WIN32
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-3-34] gjs/*.cpp, util/*.cpp: Check for sys/signal.h and _WIN32
- Date: Thu, 13 Feb 2020 04:05:57 +0000 (UTC)
commit 97d520cdf0fac8d61271d144232b894785647a8e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Feb 10 14:42:41 2020 +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 ++++--
util/log.cpp | 2 +-
win32/config.h.win32.in | 3 +++
12 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e9c5dc08..904e6e67 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 e8abcfb2..3f9d9eb2 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 21c5b72a..5588a3aa 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 c365c7f8..c33855a3 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..a99c9a3f 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/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]