Make comparison on equalities work right (ie look at the types)
[ghc-hetmet.git] / includes / TSO.h
index 0c3e4ee..c6ec669 100644 (file)
@@ -124,7 +124,21 @@ typedef union {
 typedef struct StgTSO_ {
     StgHeader               header;
 
-    struct StgTSO_*         link;       /* Links threads onto blocking queues */
+    /* The link field, for linking threads together in lists (e.g. the
+       run queue on a Capability.
+    */
+    struct StgTSO_*         _link;
+    /*
+       NOTE!!!  do not modify _link directly, it is subject to
+       a write barrier for generational GC.  Instead use the
+       setTSOLink() function.  Exceptions to this rule are:
+
+       * setting the link field to END_TSO_QUEUE
+       * putting a TSO on the blackhole_queue
+       * setting the link field of the currently running TSO, as it
+         will already be dirty.
+    */
+
     struct StgTSO_*         global_link;    /* Links all threads together */
     
     StgWord16               what_next;      /* Values defined in Constants.h */
@@ -159,6 +173,9 @@ typedef struct StgTSO_ {
 #ifdef DIST
     StgTSODistInfo dist;
 #endif
+#ifdef mingw32_HOST_OS
+    StgWord32 saved_winerror;
+#endif
 
     /* The thread stack... */
     StgWord32         stack_size;     /* stack size in *words* */
@@ -169,6 +186,13 @@ typedef struct StgTSO_ {
 } StgTSO;
 
 /* -----------------------------------------------------------------------------
+   functions
+   -------------------------------------------------------------------------- */
+
+extern void dirty_TSO  (Capability *cap, StgTSO *tso);
+extern void setTSOLink (Capability *cap, StgTSO *tso, StgTSO *target);
+
+/* -----------------------------------------------------------------------------
    Invariants:
 
    An active thread has the following properties:
@@ -215,16 +239,6 @@ typedef struct StgTSO_ {
       (tso->sp is left pointing at the top word on the stack so that
       the return value or exception will be retained by a GC).
 
-   tso->blocked_exceptions is either:
-
-      NULL             if async exceptions are unblocked.
-
-      END_TSO_QUEUE    if async exceptions are blocked, but no threads
-                       are currently waiting to deliver.
-
-      (StgTSO *)tso    if threads are currently awaiting delivery of
-                       exceptions to this thread.
-
    The 2 cases BlockedOnGA and BlockedOnGA_NoSend are needed in a GUM
    setup only. They mark a TSO that has entered a FETCH_ME or
    FETCH_ME_BQ closure, respectively; only the first TSO hitting the 
@@ -248,11 +262,7 @@ extern StgTSO dummy_tso;
 
 
 /* this is the NIL ptr for a TSO queue (e.g. runnable queue) */
-#if IN_STG_CODE
-#define END_TSO_QUEUE  (stg_END_TSO_QUEUE_closure)
-#else
 #define END_TSO_QUEUE  ((StgTSO *)(void*)&stg_END_TSO_QUEUE_closure)
-#endif
 
 #if defined(PAR) || defined(GRAN)
 /* this is the NIL ptr for a blocking queue */