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



commit 59a41eb0d5b973dc5232bbd7db856724f4d648ca
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.

 gjs/context.h    |  4 ++--
 gjs/macros.h     |  6 ++++++
 gjs/profiler.cpp | 15 +++++++++------
 3 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/gjs/context.h b/gjs/context.h
index 2b54b6bf..bc57fa10 100644
--- a/gjs/context.h
+++ b/gjs/context.h
@@ -83,8 +83,8 @@ void            gjs_context_gc                    (GjsContext  *context);
 
 GJS_EXPORT GJS_USE GjsProfiler* gjs_context_get_profiler(GjsContext* self);
 
-GJS_EXPORT GJS_USE bool gjs_profiler_chain_signal(GjsContext* context,
-                                                  siginfo_t* info);
+GJS_EXPORT GJS_USE bool gjs_profiler_chain_signal(GjsContext*             context,
+                                                  GJS_SIGNAL_HANDLER_TYPE info);
 
 GJS_EXPORT
 void            gjs_dumpstack                     (void);
diff --git a/gjs/macros.h b/gjs/macros.h
index dae6c430..a2026228 100644
--- a/gjs/macros.h
+++ b/gjs/macros.h
@@ -63,4 +63,10 @@
  */
 #define GJS_JSAPI_RETURN_CONVENTION GJS_USE
 
+#ifdef G_OS_UNIX
+# define GJS_SIGNAL_HANDLER_TYPE siginfo_t *
+#else
+# define GJS_SIGNAL_HANDLER_TYPE void *
+#endif
+
 #endif /* GJS_MACROS_H */
diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp
index cc53f5f3..f56ecb6f 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -27,16 +27,18 @@
 #include <errno.h>
 #include <memory>
 #include <signal.h>
-#include <sys/syscall.h>
 #include <sys/types.h>
-#include <unistd.h>
 
-#include <glib-unix.h>
+#ifndef XP_WIN
+# include <sys/syscall.h>
+# include <glib-unix.h>
+#endif
 
 #include "jsapi-wrapper.h"
 #include <js/ProfilingStack.h>
 
 #include "context.h"
+
 #include "jsapi-util.h"
 #include "profiler-private.h"
 #ifdef ENABLE_PROFILER
@@ -573,7 +575,8 @@ _gjs_profiler_setup_signals(GjsProfiler *self,
 /**
  * gjs_profiler_chain_signal:
  * @context: a #GjsContext with a profiler attached
- * @info: #siginfo_t passed in to signal handler
+ * @info: #GJS_SIGNAL_HANDLER_TYPE passed in to signal handler, which is
+ *        equivalent to siginfo_t * on UNIX platforms.
  *
  * Use this to pass a signal info caught by another signal handler to a
  * GjsProfiler. This might be needed if you have your own complex signal
@@ -584,8 +587,8 @@ _gjs_profiler_setup_signals(GjsProfiler *self,
  * Returns: %TRUE if the signal was handled.
  */
 bool
-gjs_profiler_chain_signal(GjsContext *context,
-                          siginfo_t *info)
+gjs_profiler_chain_signal(GjsContext              *context,
+                          GJS_SIGNAL_HANDLER_TYPE  info)
 {
 #ifdef ENABLE_PROFILER
 


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