]> granicus.if.org Git - gc/commitdiff
Change Darwin-specific code to comply with C++11 standard
authorJay Krell <jaykrell@microsoft.com>
Mon, 26 Feb 2018 04:53:37 +0000 (07:53 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 26 Feb 2018 05:38:16 +0000 (08:38 +0300)
Issue #206 (bdwgc).

* darwin_stop_world.c (GC_stack_range_for): Cast pointer which is
assinged to lo local variable to ptr_t (instead of void*).
* os_dep.c [GC_DARWIN_THREADS && MPROTECT_VDB]: Include
darwin_stop_world.h (so that GC_mprotect_stop and GC_mprotect_resume
to be declared and later defined as extern "C").
* os_dep.c [MPROTECT_VDB && DARWIN] (exc_server, exception_raise,
exception_raise_state): Wrap into extern "C" block; refine comment.
* os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state,
catch_exception_raise_state_identity): Declare as extern "C" (before
the definition).
* os_dep.c [MPROTECT_VDB && DARWIN && THREADS] (GC_mprotect_state):
Initialize to GC_MP_NORMAL (instead of integer 0).

darwin_stop_world.c
os_dep.c

index 3a8441e720e15c8084b30ace90f51245578b1844..fd04fcd28b0220430b74cadf5cfcc18e3379c028 100644 (file)
@@ -208,7 +208,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
       ABORT("thread_get_state failed");
 
 #   if defined(I386)
-      lo = (void *)state.THREAD_FLD(esp);
+      lo = (ptr_t)state.THREAD_FLD(esp);
 #     ifndef DARWIN_DONT_PARSE_STACK
         *phi = GC_FindTopOfStack(state.THREAD_FLD(esp));
 #     endif
@@ -221,7 +221,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
       GC_push_one(state.THREAD_FLD(ebp));
 
 #   elif defined(X86_64)
-      lo = (void *)state.THREAD_FLD(rsp);
+      lo = (ptr_t)state.THREAD_FLD(rsp);
 #     ifndef DARWIN_DONT_PARSE_STACK
         *phi = GC_FindTopOfStack(state.THREAD_FLD(rsp));
 #     endif
@@ -243,7 +243,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
       GC_push_one(state.THREAD_FLD(r15));
 
 #   elif defined(POWERPC)
-      lo = (void *)(state.THREAD_FLD(r1) - PPC_RED_ZONE_SIZE);
+      lo = (ptr_t)(state.THREAD_FLD(r1) - PPC_RED_ZONE_SIZE);
 #     ifndef DARWIN_DONT_PARSE_STACK
         *phi = GC_FindTopOfStack(state.THREAD_FLD(r1));
 #     endif
@@ -280,7 +280,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
       GC_push_one(state.THREAD_FLD(r31));
 
 #   elif defined(ARM32)
-      lo = (void *)state.THREAD_FLD(sp);
+      lo = (ptr_t)state.THREAD_FLD(sp);
 #     ifndef DARWIN_DONT_PARSE_STACK
         *phi = GC_FindTopOfStack(state.THREAD_FLD(r[7])); /* fp */
 #     endif
@@ -296,7 +296,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
       GC_push_one(state.THREAD_FLD(lr));
 
 #   elif defined(AARCH64)
-      lo = (void *)state.THREAD_FLD(sp);
+      lo = (ptr_t)state.THREAD_FLD(sp);
 #     ifndef DARWIN_DONT_PARSE_STACK
         *phi = GC_FindTopOfStack(state.THREAD_FLD(fp));
 #     endif
index cdda0be294b185202a44eec7e10bbaa607c8d3d2..13fe6d1262a320a7cace345f8ce513e1dca3522c 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
 # include "mm/PCR_MM.h"
 #endif
 
+#if defined(GC_DARWIN_THREADS) && defined(MPROTECT_VDB)
+  /* Declare GC_mprotect_stop and GC_mprotect_resume as extern "C".     */
+# include "private/darwin_stop_world.h"
+#endif
+
 #if !defined(NO_EXECUTE_PERMISSION)
   STATIC GC_bool GC_pages_executable = TRUE;
 #else
@@ -3919,7 +3924,12 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
 #include <mach/task.h>
 #include <pthread.h>
 
-/* These are not defined in any header, although they are documented */
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/* Some of the following prototypes are missing in any header, although */
+/* they are documented.  Some are in mach/exc.h file.                   */
 extern boolean_t
 exc_server(mach_msg_header_t *, mach_msg_header_t *);
 
@@ -3944,7 +3954,26 @@ exception_raise_state_identity(mach_port_t, mach_port_t, mach_port_t,
 GC_API_OSCALL kern_return_t
 catch_exception_raise(mach_port_t exception_port, mach_port_t thread,
                       mach_port_t task, exception_type_t exception,
-                      exception_data_t code, mach_msg_type_number_t code_count);
+                      exception_data_t code,
+                      mach_msg_type_number_t code_count);
+
+GC_API_OSCALL kern_return_t
+catch_exception_raise_state(mach_port_name_t exception_port,
+                int exception, exception_data_t code,
+                mach_msg_type_number_t codeCnt, int flavor,
+                thread_state_t old_state, int old_stateCnt,
+                thread_state_t new_state, int new_stateCnt);
+
+GC_API_OSCALL kern_return_t
+catch_exception_raise_state_identity(mach_port_name_t exception_port,
+                mach_port_t thread, mach_port_t task, int exception,
+                exception_data_t code, mach_msg_type_number_t codeCnt,
+                int flavor, thread_state_t old_state, int old_stateCnt,
+                thread_state_t new_state, int new_stateCnt);
+
+#ifdef __cplusplus
+  } /* extern "C" */
+#endif
 
 /* These should never be called, but just in case...  */
 GC_API_OSCALL kern_return_t
@@ -4019,7 +4048,7 @@ typedef enum {
   /* This value is only used on the reply port. */
 # define ID_ACK 3
 
-  STATIC GC_mprotect_state_t GC_mprotect_state = 0;
+  STATIC GC_mprotect_state_t GC_mprotect_state = GC_MP_NORMAL;
 
   /* The following should ONLY be called when the world is stopped.     */
   STATIC void GC_mprotect_thread_notify(mach_msg_id_t id)