summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-04 23:43:59 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-04 23:43:59 +0000
commitb8439d263974fb29dc3ff2ed7bf1f127b391bf42 (patch)
treef21f4ad61a3f22ffc7d3ad730456f5392faa6d8a
parentbe2fc38d70dc0a29072fda25871c6772b8a15a1f (diff)
downloadgcc-b8439d263974fb29dc3ff2ed7bf1f127b391bf42.tar.gz
libgo: Always initialize semaphores.
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171960 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libgo/runtime/cpuprof.c6
-rw-r--r--libgo/runtime/go-main.c1
-rw-r--r--libgo/runtime/malloc.goc6
-rw-r--r--libgo/runtime/runtime.h1
4 files changed, 14 insertions, 0 deletions
diff --git a/libgo/runtime/cpuprof.c b/libgo/runtime/cpuprof.c
index 07567ccaffd..3797e1ce1e0 100644
--- a/libgo/runtime/cpuprof.c
+++ b/libgo/runtime/cpuprof.c
@@ -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.
diff --git a/libgo/runtime/go-main.c b/libgo/runtime/go-main.c
index a6dbf347fb0..37956d5de7d 100644
--- a/libgo/runtime/go-main.c
+++ b/libgo/runtime/go-main.c
@@ -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;
diff --git a/libgo/runtime/malloc.goc b/libgo/runtime/malloc.goc
index 5f99c4b73a4..196271abd04 100644
--- a/libgo/runtime/malloc.goc
+++ b/libgo/runtime/malloc.goc
@@ -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));
}
diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h
index af98683aab1..00ba40f6f28 100644
--- a/libgo/runtime/runtime.h
+++ b/libgo/runtime/runtime.h
@@ -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);