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
https://golang.org/cl/834045
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index 1a1895d..169f90b 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -544,8 +544,8 @@
 
 // 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 @@
 	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.