From bb4a78f339088c49c4fca105826105dd13f00936 Mon Sep 17 00:00:00 2001 From: panne Date: Thu, 3 Oct 2002 13:29:07 +0000 Subject: [PATCH] [project @ 2002-10-03 13:29:07 by panne] Warning police #7: Improved typing of TSOs a bit, getting rid of a bunch of C compiler warnings. --- Control/Concurrent.hs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Control/Concurrent.hs b/Control/Concurrent.hs index d41b462..968e303 100644 --- a/Control/Concurrent.hs +++ b/Control/Concurrent.hs @@ -81,6 +81,7 @@ import GHC.TopHandler ( reportStackOverflow, reportError ) import GHC.IOBase ( IO(..) ) import GHC.IOBase ( unsafeInterleaveIO ) import GHC.Base +import GHC.Ptr #endif #ifdef __HUGS__ @@ -147,12 +148,17 @@ functions blocks only the thread making the call. -- cmp_thread in the RTS. #ifdef __GLASGOW_HASKELL__ -foreign import ccall unsafe "cmp_thread" cmp_thread :: Addr# -> Addr# -> Int +type StgTSO = Ptr () + +id2TSO :: ThreadId -> StgTSO +id2TSO (ThreadId t) = unsafeCoerce# t + +foreign import ccall unsafe "cmp_thread" cmp_thread :: StgTSO -> StgTSO -> Int -- Returns -1, 0, 1 cmpThread :: ThreadId -> ThreadId -> Ordering -cmpThread (ThreadId t1) (ThreadId t2) = - case cmp_thread (unsafeCoerce# t1) (unsafeCoerce# t2) of +cmpThread t1 t2 = + case cmp_thread (id2TSO t1) (id2TSO t2) of -1 -> LT 0 -> EQ _ -> GT -- must be 1 @@ -166,12 +172,12 @@ instance Eq ThreadId where instance Ord ThreadId where compare = cmpThread -foreign import ccall unsafe "rts_getThreadId" getThreadId :: Addr# -> Int +foreign import ccall unsafe "rts_getThreadId" getThreadId :: StgTSO -> Int instance Show ThreadId where - showsPrec d (ThreadId t) = + showsPrec d t = showString "ThreadId " . - showsPrec d (getThreadId (unsafeCoerce# t)) + showsPrec d (getThreadId (id2TSO t)) {- | This sparks off a new thread to run the 'IO' computation passed as the -- 1.7.10.4