aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-09-06 15:27:26 -0400
committerRuss Cox <rsc@golang.org>2014-09-06 15:27:26 -0400
commita09e61395ee5e71c4c4a37fa0faed87592a04834 (patch)
treeaff5484c4abe40e7eb2512ce5df91b74e964ead9 /src/pkg/runtime/runtime.c
parente8d65b92d7129edf4ca495206467f600960e803e (diff)
downloadgo-a09e61395ee5e71c4c4a37fa0faed87592a04834.tar.xz
runtime: move stubs.goc code into runtime.c
Now that the calling conventions are the same, there's no danger to using plain C for these. LGTM=bradfitz R=golang-codereviews, bradfitz CC=dvyukov, golang-codereviews, iant, khr, r https://golang.org/cl/134580043
Diffstat (limited to 'src/pkg/runtime/runtime.c')
-rw-r--r--src/pkg/runtime/runtime.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c
index d28ee58179..42ce1dadfb 100644
--- a/src/pkg/runtime/runtime.c
+++ b/src/pkg/runtime/runtime.c
@@ -341,3 +341,51 @@ runtime·timediv(int64 v, int32 div, int32 *rem)
*rem = v;
return res;
}
+
+// Helpers for Go. Must be NOSPLIT, must only call NOSPLIT functions, and must not block.
+
+#pragma textflag NOSPLIT
+G*
+runtime·getg(void)
+{
+ return g;
+}
+
+#pragma textflag NOSPLIT
+M*
+runtime·acquirem(void)
+{
+ g->m->locks++;
+ return g->m;
+}
+
+#pragma textflag NOSPLIT
+void
+runtime·releasem(M *mp)
+{
+ mp->locks--;
+ if(mp->locks == 0 && g->preempt) {
+ // restore the preemption request in case we've cleared it in newstack
+ g->stackguard0 = StackPreempt;
+ }
+}
+
+#pragma textflag NOSPLIT
+MCache*
+runtime·gomcache(void)
+{
+ return g->m->mcache;
+}
+
+#pragma textflag NOSPLIT
+Slice
+reflect·typelinks(void)
+{
+ extern Type *runtime·typelink[], *runtime·etypelink[];
+ Slice ret;
+
+ ret.array = (byte*)runtime·typelink;
+ ret.len = runtime·etypelink - runtime·typelink;
+ ret.cap = ret.len;
+ return ret;
+}