[project @ 2005-04-27 09:48:34 by simonmar]
authorsimonmar <unknown>
Wed, 27 Apr 2005 09:48:34 +0000 (09:48 +0000)
committersimonmar <unknown>
Wed, 27 Apr 2005 09:48:34 +0000 (09:48 +0000)
Remove uses of stderr from .cmm code.

We can't reliably refer to stdin/stdout/stderr from .cmm, because the
C standard doesn't specify whether stderr is a variable or a macro.

ghc/rts/Apply.cmm
ghc/rts/Exception.cmm
ghc/rts/HeapStackCheck.cmm
ghc/rts/PrimOps.cmm
ghc/rts/Profiling.c
ghc/rts/Profiling.h

index 1fe444e..e4197ec 100644 (file)
@@ -41,7 +41,7 @@ INFO_TABLE_RET( stg_ap_0,
     // fn is in R1, no args on the stack
 
     IF_DEBUG(apply,
-       foreign "C" fprintf(W_[stderr] "ptr", stg_ap_0_ret_str);
+       foreign "C" debugBelch(stg_ap_0_ret_str);
        foreign "C" printClosure(R1 "ptr"));
 
     IF_DEBUG(sanity,
index f8d305e..6192f6d 100644 (file)
@@ -330,7 +330,7 @@ raisezh_fast
      * the info was only displayed for an *uncaught* exception.
      */
     if (RtsFlags_ProfFlags_showCCSOnException(RtsFlags)) {
-      foreign "C" fprintCCS(W_[stderr] "ptr",W_[CCCS] "ptr");
+      foreign "C" fprintCCS_stderr(W_[CCCS] "ptr");
     }
 #endif
 
index 90b1158..db4af25 100644 (file)
@@ -611,7 +611,7 @@ __stg_gc_fun
         Sp(2) = R1;
         Sp(1) = size;
         Sp(0) = stg_gc_fun_info;
-        // DEBUG_ONLY(foreign "C" fprintf(stderr, "stg_fun_gc_gen(ARG_GEN)"););
+        // DEBUG_ONLY(foreign "C" debugBelch("stg_fun_gc_gen(ARG_GEN)"););
         GC_GENERIC
     } else { 
        jump W_[stg_stack_save_entries + WDS(type)];
index 7cb1aaf..cfdaca6 100644 (file)
@@ -289,7 +289,7 @@ mkWeakzh_fast
   StgWeak_link(w)      = W_[weak_ptr_list];
   W_[weak_ptr_list]    = w;
 
-  IF_DEBUG(weak, foreign "C" fprintf(W_[stderr] "ptr",stg_weak_msg,w));
+  IF_DEBUG(weak, foreign "C" debugBelch(stg_weak_msg,w));
 
   RET_P(w);
 }
index b9900f5..028dc5a 100644 (file)
@@ -916,6 +916,13 @@ fprintCCS( FILE *f, CostCentreStack *ccs )
   fprintf(f,">");
 }
 
+/* For calling from .cmm code, where we can't reliably refer to stderr */
+void
+fprintCCS_stderr( CostCentreStack *ccs )
+{
+    fprintCCS(stderr, ccs);
+}
+
 #ifdef DEBUG
 void
 debugCCS( CostCentreStack *ccs )
index 7ed7bdc..4b66989 100644 (file)
@@ -27,6 +27,7 @@ void PrintNewStackDecls ( void );
 extern lnat RTS_VAR(total_prof_ticks);
 
 extern void fprintCCS( FILE *f, CostCentreStack *ccs );
+extern void fprintCCS_stderr( CostCentreStack *ccs );
 
 #ifdef DEBUG
 extern void debugCCS( CostCentreStack *ccs );