summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2010-04-09 13:30:35 -0700
committerIan Lance Taylor <iant@golang.org>2010-04-09 13:30:35 -0700
commit0b75b44531202fcf43f4cfd39bcc853415cc6b57 (patch)
treed2593a05312b83937e39de76abfba7518100863d /src/pkg/runtime/proc.c
parent38bc93c1d883e5d1da94f0b049f47d6f0c788bba (diff)
downloadgolang-0b75b44531202fcf43f4cfd39bcc853415cc6b57.tar.gz
Library support for cgo export.
These functions are used to call from a C function back to a Go function. This only includes 386 support. R=rsc CC=golang-dev http://codereview.appspot.com/834045
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r--src/pkg/runtime/proc.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index 1a1895dcb..169f90b73 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -544,8 +544,8 @@ gosched(void)
// The goroutine g is about to enter a system call.
// Record that it's not using the cpu anymore.
-// This is called only from the go syscall library, not
-// from the low-level system calls used by the runtime.
+// This is called only from the go syscall library and cgocall,
+// not from the low-level system calls used by the runtime.
void
·entersyscall(void)
{
@@ -604,6 +604,28 @@ void
gosched();
}
+// Start scheduling g1 again for a cgo callback.
+void
+startcgocallback(G* g1)
+{
+ lock(&sched);
+ g1->status = Grunning;
+ sched.msyscall--;
+ sched.mcpu++;
+ unlock(&sched);
+}
+
+// Stop scheduling g1 after a cgo callback.
+void
+endcgocallback(G* g1)
+{
+ lock(&sched);
+ g1->status = Gsyscall;
+ sched.mcpu--;
+ sched.msyscall++;
+ unlock(&sched);
+}
+
/*
* stack layout parameters.
* known to linkers.