summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/cgocall.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/cgocall.c')
-rw-r--r--src/pkg/runtime/cgocall.c53
1 files changed, 14 insertions, 39 deletions
diff --git a/src/pkg/runtime/cgocall.c b/src/pkg/runtime/cgocall.c
index 2a04453fd..7b2ec26f3 100644
--- a/src/pkg/runtime/cgocall.c
+++ b/src/pkg/runtime/cgocall.c
@@ -99,12 +99,7 @@ runtime·cgocall(void (*fn)(void*), void *arg)
{
Defer d;
- if(m->racecall) {
- runtime·asmcgocall(fn, arg);
- return;
- }
-
- if(!runtime·iscgo && !Windows)
+ if(!runtime·iscgo && !Solaris && !Windows)
runtime·throw("cgocall unavailable");
if(fn == 0)
@@ -127,11 +122,10 @@ runtime·cgocall(void (*fn)(void*), void *arg)
d.fn = &endcgoV;
d.siz = 0;
d.link = g->defer;
- d.argp = (void*)-1; // unused because unlockm never recovers
+ d.argp = NoArgs;
d.special = true;
- d.free = false;
g->defer = &d;
-
+
m->ncgo++;
/*
@@ -171,17 +165,6 @@ endcgo(void)
runtime·raceacquire(&cgosync);
}
-void
-runtime·NumCgoCall(int64 ret)
-{
- M *mp;
-
- ret = 0;
- for(mp=runtime·atomicloadp(&runtime·allm); mp; mp=mp->alllink)
- ret += mp->ncgocall;
- FLUSH(&ret);
-}
-
// Helper functions for cgo code.
void (*_cgo_malloc)(void*);
@@ -235,6 +218,11 @@ struct CallbackArgs
#define CBARGS (CallbackArgs*)((byte*)m->g0->sched.sp+2*sizeof(void*))
#endif
+// Unimplemented on amd64p32
+#ifdef GOARCH_amd64p32
+#define CBARGS (CallbackArgs*)(nil)
+#endif
+
// On 386, stack frame is three words, plus caller PC.
#ifdef GOARCH_386
#define CBARGS (CallbackArgs*)((byte*)m->g0->sched.sp+4*sizeof(void*))
@@ -251,21 +239,9 @@ runtime·cgocallbackg(void)
runtime·exit(2);
}
- if(m->racecall) {
- // We were not in syscall, so no need to call runtime·exitsyscall.
- // However we must set m->locks for the following reason.
- // Race detector runtime makes __tsan_symbolize cgo callback
- // holding internal mutexes. The mutexes are not cooperative with Go scheduler.
- // So if we deschedule a goroutine that holds race detector internal mutex
- // (e.g. preempt it), another goroutine will deadlock trying to acquire the same mutex.
- m->locks++;
- runtime·cgocallbackg1();
- m->locks--;
- } else {
- runtime·exitsyscall(); // coming out of cgo call
- runtime·cgocallbackg1();
- runtime·entersyscall(); // going back to cgo call
- }
+ runtime·exitsyscall(); // coming out of cgo call
+ runtime·cgocallbackg1();
+ runtime·entersyscall(); // going back to cgo call
}
void
@@ -283,19 +259,18 @@ runtime·cgocallbackg1(void)
d.fn = &unwindmf;
d.siz = 0;
d.link = g->defer;
- d.argp = (void*)-1; // unused because unwindm never recovers
+ d.argp = NoArgs;
d.special = true;
- d.free = false;
g->defer = &d;
- if(raceenabled && !m->racecall)
+ if(raceenabled)
runtime·raceacquire(&cgosync);
// Invoke callback.
cb = CBARGS;
runtime·newstackcall(cb->fn, cb->arg, cb->argsize);
- if(raceenabled && !m->racecall)
+ if(raceenabled)
runtime·racereleasemerge(&cgosync);
// Pop defer.