libgo: Always initialize semaphores.
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Mon, 4 Apr 2011 23:43:59 +0000 (23:43 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 4 Apr 2011 23:43:59 +0000 (23:43 +0000)
2011-04-03  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

PR go/48222
* runtime/malloc.goc (runtime_mallocinit): Call
runtime_Mprof_Init, runtime_initfintab.
* runtime/cpuprof.c (runtime_cpuprofinit): New function.
* runtime/runtime.h (runtime_cpuprofinit): Declare it.
* runtime/go-main.c (main): Use it.

From-SVN: r171960

libgo/runtime/cpuprof.c
libgo/runtime/go-main.c
libgo/runtime/malloc.goc
libgo/runtime/runtime.h

index 07567ccaffd1b38a8e98aafa16d88891d1a61db1..3797e1ce1e08afed58896b47c6132a919e4c0ae5 100644 (file)
@@ -114,6 +114,12 @@ static void add(Profile*, uintptr*, int32);
 static bool evict(Profile*, Entry*);
 static bool flushlog(Profile*);
 
+void
+runtime_cpuprofinit(void)
+{
+       runtime_initlock(&lk);
+}
+
 // LostProfileData is a no-op function used in profiles
 // to mark the number of profiling stack traces that were
 // discarded due to slow data writers.
index a6dbf347fb01ba107b1ffd7540723c8746fe25d4..37956d5de7d633dd13c915ab04bceb6aead4fc91 100644 (file)
@@ -48,6 +48,7 @@ main (int argc, char **argv)
   struct __go_string *values;
 
   runtime_mallocinit ();
+  runtime_cpuprofinit ();
   __go_gc_goroutine_init (&argc);
 
   Args.__count = argc;
index 5f99c4b73a42b79e8ca27474445ab5e4f9fa96d3..196271abd04dd62ece4d9c60d31ed0bdce63c908 100644 (file)
@@ -350,6 +350,12 @@ runtime_mallocinit(void)
        runtime_MHeap_Init(&runtime_mheap, runtime_SysAlloc);
        m->mcache = runtime_allocmcache();
 
+       // Initialize malloc profiling.
+       runtime_Mprof_Init();
+
+       // Initialize finalizer.
+       runtime_initfintab();
+
        // See if it works.
        runtime_free(runtime_malloc(1));
 }
index af98683aab13a1a304c7a19cb138f0e30aa2217a..00ba40f6f286c02af84c6544af6aa99c5393031c 100644 (file)
@@ -189,6 +189,7 @@ void        runtime_walkfintab(void (*fn)(void*), void (*scan)(byte *, int64));
 #define runtime_casp(pval, old, new) __sync_bool_compare_and_swap (pval, old, new)
 
 void   runtime_sigprof(uint8 *pc, uint8 *sp, uint8 *lr);
+void   runtime_cpuprofinit(void);
 void   runtime_resetcpuprofiler(int32);
 void   runtime_setcpuprofilerate(void(*)(uintptr*, int32), int32);