[gjs/master.windows: 9/18] Fix building of gjs_profiler_chain_signal() on Windows



commit 5d222f489248660829842a4cfdb9d0fc17921d05
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Feb 22 13:12:56 2019 +0800

    Fix building of gjs_profiler_chain_signal() on Windows
    
    Define a macro in gjs/macros.h to denote the handler type, which is
    siginfo_t* on UNIX and a void * on non-UNIX so that the code will build,
    as there is no siginfo_t on Windows.
    
    Also avoid including UNIX-only headers unconditionally.

 configure.ac     |  1 +
 gjs/macros.h     |  1 +
 gjs/profiler.cpp | 16 +++++++++++-----
 3 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e3e6fdb7..0e5de34b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,7 @@ AC_LANG([C++])
 AC_USE_SYSTEM_EXTENSIONS
 AC_PROG_CXX
 AX_CXX_COMPILE_STDCXX_14
+AC_CHECK_HEADERS([sys/syscall.h unistd.h])
 
 LT_PREREQ([2.2.0])
 # no stupid static libraries
diff --git a/gjs/macros.h b/gjs/macros.h
index dae6c430..111141d4 100644
--- a/gjs/macros.h
+++ b/gjs/macros.h
@@ -32,6 +32,7 @@
 # else
 #  define GJS_EXPORT __declspec(dllimport)
 # endif
+#    define siginfo_t void
 #else
 # define GJS_EXPORT
 #endif
diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp
index cc53f5f3..d74689c1 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -27,11 +27,7 @@
 #include <errno.h>
 #include <memory>
 #include <signal.h>
-#include <sys/syscall.h>
 #include <sys/types.h>
-#include <unistd.h>
-
-#include <glib-unix.h>
 
 #include "jsapi-wrapper.h"
 #include <js/ProfilingStack.h>
@@ -39,9 +35,19 @@
 #include "context.h"
 #include "jsapi-util.h"
 #include "profiler-private.h"
+
 #ifdef ENABLE_PROFILER
 # include <alloca.h>
-# include "util/sp-capture-writer.h"
+#    ifdef HAVE_SYS_SYSCALL_H
+#        include <sys/syscall.h>
+#    endif
+#    ifdef HAVE_UNISTD_H
+#        include <unistd.h>
+#    endif
+#    ifdef G_OS_UNIX
+#        include <glib-unix.h>
+#    endif
+#    include "util/sp-capture-writer.h"
 #endif
 
 /*


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