aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libgo/runtime/malloc.goc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libgo/runtime/malloc.goc')
-rw-r--r--gcc-4.9/libgo/runtime/malloc.goc7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc-4.9/libgo/runtime/malloc.goc b/gcc-4.9/libgo/runtime/malloc.goc
index 7120457a5..37bbf5ef6 100644
--- a/gcc-4.9/libgo/runtime/malloc.goc
+++ b/gcc-4.9/libgo/runtime/malloc.goc
@@ -79,6 +79,7 @@ runtime_mallocgc(uintptr size, uintptr typ, uint32 flag)
MSpan *s;
MLink *v;
bool incallback;
+ void *closure;
if(size == 0) {
// All 0-length allocations use this pointer.
@@ -90,6 +91,10 @@ runtime_mallocgc(uintptr size, uintptr typ, uint32 flag)
m = runtime_m();
g = runtime_g();
+ // We should not be called in between __go_set_closure and the
+ // actual function call, but cope with it if we are.
+ closure = g->closure;
+
incallback = false;
if(m->mcache == nil && g->ncgo > 0) {
// For gccgo this case can occur when a cgo or SWIG function
@@ -206,6 +211,8 @@ runtime_mallocgc(uintptr size, uintptr typ, uint32 flag)
if(incallback)
runtime_entersyscall();
+ g->closure = closure;
+
return v;
}