summaryrefslogtreecommitdiff
path: root/rts/posix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2016-11-29 13:28:27 -0500
committerBen Gamari <ben@smart-cactus.org>2016-11-29 14:39:55 -0500
commit1732d7ac43ca578deca39ea5a63cbf34f3cd9dd5 (patch)
tree258f187815dddea45843d17e57dad0dfcfd020ac /rts/posix
parent36e36227e438d95fae367d10183ea43b4819854f (diff)
downloadhaskell-1732d7ac43ca578deca39ea5a63cbf34f3cd9dd5.tar.gz
Define thread primitives if they're supported.
On iOS, we use the pthread-based implementation of Itimer.c even for a non-threaded RTS. Since 999c464, this relies on synchronization primitives like Mutex, so ensure those primitives are defined whenever they are supported, even if !THREADED_RTS. Fixes #12799. Reviewers: erikd, austin, simonmar, bgamari Reviewed By: simonmar, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2712 GHC Trac Issues: #12799
Diffstat (limited to 'rts/posix')
-rw-r--r--rts/posix/OSThreads.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c
index 63e979080c..a52fbe5d37 100644
--- a/rts/posix/OSThreads.c
+++ b/rts/posix/OSThreads.c
@@ -35,7 +35,6 @@
#endif
#endif
-#if defined(THREADED_RTS)
#include "RtsUtils.h"
#include "Task.h"
@@ -215,6 +214,8 @@ freeThreadLocalKey (ThreadLocalKey *key)
}
}
+#if defined(THREADED_RTS)
+
static void *
forkOS_createThreadWrapper ( void * entry )
{
@@ -266,6 +267,23 @@ getNumberOfProcessors (void)
return nproc;
}
+#else /* !defined(THREADED_RTS) */
+
+int
+forkOS_createThread ( HsStablePtr entry STG_UNUSED )
+{
+ return -1;
+}
+
+void freeThreadingResources (void) { /* nothing */ }
+
+uint32_t getNumberOfProcessors (void)
+{
+ return 1;
+}
+
+#endif /* defined(THREADED_RTS) */
+
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY)
// Schedules the thread to run on CPU n of m. m may be less than the
// number of physical CPUs, in which case, the thread will be allowed
@@ -353,23 +371,6 @@ interruptOSThread (OSThreadId id)
pthread_kill(id, SIGPIPE);
}
-#else /* !defined(THREADED_RTS) */
-
-int
-forkOS_createThread ( HsStablePtr entry STG_UNUSED )
-{
- return -1;
-}
-
-void freeThreadingResources (void) { /* nothing */ }
-
-uint32_t getNumberOfProcessors (void)
-{
- return 1;
-}
-
-#endif /* defined(THREADED_RTS) */
-
KernelThreadId kernelThreadId (void)
{
#if defined(linux_HOST_OS)