#include "utils/mono-counters.h"
#include "utils/mono-logger-internal.h"
#include "utils/mono-time.h"
+#include "utils/mono-semaphore.h"
extern void mono_sgen_register_moved_object (void *obj, void *destination);
extern void mono_sgen_gc_event_moves (void);
#define SGEN_TV_GETTIME(tv) tv = mono_100ns_ticks ()
#define SGEN_TV_ELAPSED(start,end) (int)((end-start))
+typedef MonoSemType SgenSemaphore;
+
+#define SGEN_SEMAPHORE_INIT(sem,initial) MONO_SEM_INIT ((sem), (initial))
+#define SGEN_SEMAPHORE_POST(sem) MONO_SEM_POST ((sem))
+#define SGEN_SEMAPHORE_WAIT(sem) MONO_SEM_WAIT ((sem))
+
#endif
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
-#ifdef HAVE_SEMAPHORE_H
-#include <semaphore.h>
-#endif
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "metadata/sgen-workers.h"
#include "metadata/sgen-client.h"
#include "metadata/sgen-pointer-queue.h"
-#include "utils/mono-semaphore.h"
#include "utils/mono-proclib.h"
#include "utils/mono-memory-model.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;
pthread_sigmask (SIG_BLOCK, &suspend_ack_signal_mask, NULL);
/* notify the waiting thread */
- MONO_SEM_POST (suspend_ack_semaphore_ptr);
+ SGEN_SEMAPHORE_POST (suspend_ack_semaphore_ptr);
info->stop_count = stop_count;
/* wait until we receive the restart signal */
SGEN_LOG (4, "Posting suspend_ack_semaphore for resume from %p %p\n", info, (gpointer)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 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));
}
}
}
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;