[project @ 2004-10-02 07:32:25 by dons]
[ghc-hetmet.git] / ghc / rts / RtsUtils.c
index 89a8af1..f4d61b1 100644 (file)
 #include <stdarg.h>
 #include <stdio.h>
 
+#if defined(openbsd_TARGET_OS)
+# ifdef HAVE_SIGNAL_H
+#  include <signal.h>
+# endif
+# ifdef HAVE_PTHREAD_H
+#  include <pthread.h>
+# endif
+#endif
+
 /* -----------------------------------------------------------------------------
    Result-checking malloc wrappers.
    -------------------------------------------------------------------------- */
@@ -288,3 +297,19 @@ heapCheckFail( void )
 }
 #endif
 
+/* 
+ * It seems that pthreads and signals interact oddly in OpenBSD
+ * pthreads (and possibly FreeBSD). When linking with -lpthreads, we
+ * have to use pthread_kill to send blockable signals. So use that
+ * when we have a threaded rts. So System.Posix.Signals will call
+ * genericRaise(), rather than raise(3).
+ */
+#if defined(openbsd_TARGET_OS)
+int genericRaise(int sig) {
+# if defined(THREADED_RTS)
+        return pthread_kill(pthread_self(), sig);
+# else
+        return raise(sig);
+# endif
+}
+#endif