Make sure that a prototype is included for 'setIOManagerControlFd'
[ghc.git] / rts / Capability.c
index 5988d42..14c99d0 100644 (file)
@@ -26,6 +26,7 @@
 #include "sm/GC.h" // for gcWorkerThread()
 #include "STM.h"
 #include "RtsUtils.h"
+#include "rts/IOManager.h"
 
 #include <string.h>
 
@@ -255,6 +256,7 @@ initCapability( Capability *cap, nat i )
     cap->spark_stats.converted  = 0;
     cap->spark_stats.gcd        = 0;
     cap->spark_stats.fizzled    = 0;
+    cap->io_manager_control_wr_fd = -1;
 #endif
     cap->total_allocated        = 0;
 
@@ -273,6 +275,8 @@ initCapability( Capability *cap, nat i )
        cap->mut_lists[g] = NULL;
     }
 
+    cap->weak_ptr_list_hd = NULL;
+    cap->weak_ptr_list_tl = NULL;
     cap->free_tvar_watch_queues = END_STM_WATCH_QUEUE;
     cap->free_invariant_check_queues = END_INVARIANT_CHECK_QUEUE;
     cap->free_trec_chunks = END_STM_CHUNK_LIST;
@@ -357,15 +361,18 @@ moreCapabilities (nat from USED_IF_THREADS, nat to USED_IF_THREADS)
         // BaseReg (eg. unregisterised), so in this case
        // capabilities[0] must coincide with &MainCapability.
         capabilities[0] = &MainCapability;
+        initCapability(&MainCapability, 0);
     }
-
-    for (i = 0; i < to; i++) {
-        if (i < from) {
-            capabilities[i] = old_capabilities[i];
-        } else {
-            capabilities[i] = stgMallocBytes(sizeof(Capability),
-                                             "moreCapabilities");
-            initCapability(capabilities[i], i);
+    else
+    {
+        for (i = 0; i < to; i++) {
+            if (i < from) {
+                capabilities[i] = old_capabilities[i];
+            } else {
+                capabilities[i] = stgMallocBytes(sizeof(Capability),
+                                                 "moreCapabilities");
+                initCapability(capabilities[i], i);
+            }
         }
     }
 
@@ -983,7 +990,8 @@ freeCapabilities (void)
     nat i;
     for (i=0; i < n_capabilities; i++) {
         freeCapability(capabilities[i]);
-        stgFree(capabilities[i]);
+        if (capabilities[i] != &MainCapability)
+            stgFree(capabilities[i]);
     }
 #else
     freeCapability(&MainCapability);
@@ -1069,3 +1077,21 @@ rtsBool checkSparkCountInvariant (void)
 
 }
 #endif
+
+void setIOManagerControlFd(nat cap_no USED_IF_THREADS, int fd USED_IF_THREADS) {
+#if defined(THREADED_RTS)
+    if (cap_no < n_capabilities) {
+        capabilities[cap_no]->io_manager_control_wr_fd = fd;
+    } else {
+        errorBelch("warning: setIOManagerControlFd called with illegal capability number.");
+    }
+#endif
+}
+
+// Local Variables:
+// mode: C
+// fill-column: 80
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// End: