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



commit 016d97fc4f7116ba0c0b3cad01e51cf6b07100be
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 | 16 ++++++++++------
 3 files changed, 18 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..90fe8c96 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -27,16 +27,19 @@
 #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>
 
 #include "context.h"
+
+#ifdef G_OS_UNIX
+# include <sys/syscall.h>
+# include <glib-unix.h>
+#endif
+
 #include "jsapi-util.h"
 #include "profiler-private.h"
 #ifdef ENABLE_PROFILER
@@ -573,7 +576,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 +588,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]