[sgen] Semaphore type defined in client code.
authorMark Probst <mark.probst@gmail.com>
Thu, 1 Jan 2015 21:37:32 +0000 (13:37 -0800)
committerMark Probst <mark.probst@gmail.com>
Wed, 29 Apr 2015 17:59:48 +0000 (10:59 -0700)
`mono-semaphore.h` depends on io-layer, which we can't expect
anybody to include.

mono/metadata/sgen-client-mono.h
mono/metadata/sgen-gc.c
mono/metadata/sgen-marksweep.c
mono/metadata/sgen-os-posix.c

index ae1ebcbab81137f113a96b4899b078296b673b4c..3d0338ce5af344f79ee893560ea27ce2dadc85d2 100644 (file)
@@ -142,6 +142,7 @@ struct _SgenClientThreadInfo {
 #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);
@@ -541,4 +542,10 @@ void sgen_wait_for_suspend_ack (int count);
 #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
index 82252dc43b0daca34367a9b320df1614ca65b0ce..b008ae8cca964f46425b7e0976a716c0b626cad7 100644 (file)
 #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"
 
index d1901a16c2d10cd5d9be82b2a1aa5a26048f8f23..f4c774acf29d76f9293a7058f224f33ebeeda731 100644 (file)
@@ -28,8 +28,6 @@
 #include <math.h>
 #include <errno.h>
 
-#include "utils/mono-semaphore.h"
-
 #include "metadata/sgen-gc.h"
 #include "metadata/sgen-protocol.h"
 #include "metadata/sgen-cardtable.h"
index d36eb5551fbb8b7d01793961e940f565a0dc165b..cb7d6539c24411f47c945dde2cc40cc5c0a4cb11 100644 (file)
@@ -43,8 +43,8 @@ const static int suspend_signal_num = SIGPWR;
 #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;
@@ -117,7 +117,7 @@ suspend_thread (SgenThreadInfo *info, void *context)
        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 */
@@ -131,7 +131,7 @@ suspend_thread (SgenThreadInfo *info, void *context)
 
        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) */
@@ -185,9 +185,9 @@ sgen_wait_for_suspend_ack (int count)
        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));
                        }
                }
        }
@@ -237,7 +237,7 @@ sgen_os_init (void)
                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;