#include "config.h"
-#ifdef HAVE_SGEN_GC
+#if defined(HAVE_SGEN_GC) && !defined(USE_COOP_GC)
#if !defined(__MACH__) && !MONO_MACH_ARCH_SUPPORTED && defined(HAVE_PTHREAD_KILL)
#include <errno.h>
#include <glib.h>
-#include "metadata/sgen-gc.h"
-#include "metadata/gc-internal.h"
-#include "metadata/sgen-archdep.h"
+#include "sgen/sgen-gc.h"
+#include "metadata/gc-internals.h"
+#include "sgen/sgen-archdep.h"
#include "metadata/object-internals.h"
#include "utils/mono-signal-handler.h"
#endif
const static int restart_signal_num = SIGXCPU;
-static MonoSemType suspend_ack_semaphore;
-static MonoSemType *suspend_ack_semaphore_ptr;
+static SgenSemaphore suspend_ack_semaphore;
+static SgenSemaphore *suspend_ack_semaphore_ptr;
static sigset_t suspend_signal_mask;
static sigset_t suspend_ack_signal_mask;
gpointer stack_start;
info->client_info.stopped_domain = mono_domain_get ();
- info->signal = 0;
+ info->client_info.signal = 0;
stop_count = sgen_global_stop_count;
/* duplicate signal */
- if (0 && info->stop_count == stop_count)
+ if (0 && info->client_info.stop_count == stop_count)
return;
#ifdef USE_MONO_CTX
stack_start = NULL;
}
#else
- info->stopped_ip = context ? (gpointer) ARCH_SIGCTX_IP (context) : NULL;
+ info->client_info.stopped_ip = context ? (gpointer) ARCH_SIGCTX_IP (context) : NULL;
stack_start = context ? (char*) ARCH_SIGCTX_SP (context) - REDZONE_SIZE : NULL;
#endif
/* Notify the JIT */
if (mono_gc_get_gc_callbacks ()->thread_suspend_func)
- mono_gc_get_gc_callbacks ()->thread_suspend_func (info->runtime_data, context, NULL);
+ mono_gc_get_gc_callbacks ()->thread_suspend_func (info->client_info.runtime_data, context, NULL);
- SGEN_LOG (4, "Posting suspend_ack_semaphore for suspend from %p %p", info, (gpointer)mono_native_thread_id_get ());
+ SGEN_LOG (4, "Posting suspend_ack_semaphore for suspend from %p %p", info, (gpointer) (gsize) mono_native_thread_id_get ());
/*
Block the restart signal.
pthread_sigmask (SIG_BLOCK, &suspend_ack_signal_mask, NULL);
/* notify the waiting thread */
- MONO_SEM_POST (suspend_ack_semaphore_ptr);
- info->stop_count = stop_count;
+ SGEN_SEMAPHORE_POST (suspend_ack_semaphore_ptr);
+ info->client_info.stop_count = stop_count;
/* wait until we receive the restart signal */
do {
- info->signal = 0;
+ info->client_info.signal = 0;
sigsuspend (&suspend_signal_mask);
- } while (info->signal != restart_signal_num);
+ } while (info->client_info.signal != restart_signal_num);
/* Unblock the restart signal. */
pthread_sigmask (SIG_UNBLOCK, &suspend_ack_signal_mask, NULL);
- SGEN_LOG (4, "Posting suspend_ack_semaphore for resume from %p %p\n", info, (gpointer)mono_native_thread_id_get ());
+ SGEN_LOG (4, "Posting suspend_ack_semaphore for resume from %p %p\n", info, (gpointer) (gsize) mono_native_thread_id_get ());
/* notify the waiting thread */
- MONO_SEM_POST (suspend_ack_semaphore_ptr);
+ SGEN_SEMAPHORE_POST (suspend_ack_semaphore_ptr);
}
/* LOCKING: assumes the GC lock is held (by the stopping thread) */
int old_errno = errno;
info = mono_thread_info_current ();
- info->signal = restart_signal_num;
- SGEN_LOG (4, "Restart handler in %p %p", info, (gpointer)mono_native_thread_id_get ());
+ info->client_info.signal = restart_signal_num;
+ SGEN_LOG (4, "Restart handler in %p %p", info, (gpointer) (gsize) mono_native_thread_id_get ());
errno = old_errno;
}
int i, result;
for (i = 0; i < count; ++i) {
- while ((result = MONO_SEM_WAIT (suspend_ack_semaphore_ptr)) != 0) {
+ while ((result = SGEN_SEMAPHORE_WAIT (suspend_ack_semaphore_ptr)) != 0) {
if (errno != EINTR) {
- g_error ("MONO_SEM_WAIT FAILED with %d errno %d (%s)", result, errno, strerror (errno));
+ g_error ("SGEN_SEMAPHORE_WAIT FAILED with %d errno %d (%s)", result, errno, strerror (errno));
}
}
}
sgen_thread_handshake (BOOL suspend)
{
int count, result;
- SgenThreadInfo *info;
int signum = suspend ? suspend_signal_num : restart_signal_num;
MonoNativeThreadId me = mono_native_thread_id_get ();
count = 0;
mono_thread_info_current ()->client_info.suspend_done = TRUE;
- FOREACH_THREAD_SAFE (info) {
+ FOREACH_THREAD (info) {
if (mono_native_thread_id_equals (mono_thread_info_get_tid (info), me)) {
continue;
}
} else {
info->client_info.skip = 1;
}
- } END_FOREACH_THREAD_SAFE
+ } FOREACH_THREAD_END
sgen_wait_for_suspend_ack (count);
return;
suspend_ack_semaphore_ptr = &suspend_ack_semaphore;
- MONO_SEM_INIT (&suspend_ack_semaphore, 0);
+ SGEN_SEMAPHORE_INIT (&suspend_ack_semaphore, 0);
sigfillset (&sinfo.sa_mask);
sinfo.sa_flags = SA_RESTART | SA_SIGINFO;
g_error ("failed sigaction");
}
- sinfo.sa_handler = (void*) restart_handler;
+ sinfo.sa_handler = (void (*)(int))restart_handler;
if (sigaction (restart_signal_num, &sinfo, NULL) != 0) {
g_error ("failed sigaction");
}