]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add load_g call in arm callback.
authorKeith Randall <khr@golang.org>
Thu, 25 Sep 2014 15:37:04 +0000 (08:37 -0700)
committerKeith Randall <khr@golang.org>
Thu, 25 Sep 2014 15:37:04 +0000 (08:37 -0700)
Need to restore the g register.  Somehow this line vaporized from
CL 144130043.  Also cgo_topofstack -> _cgo_topofstack, that vaporized also.

TBR=rsc
CC=golang-codereviews
https://golang.org/cl/150940044

src/cmd/cgo/out.go
src/runtime/asm_386.s
src/runtime/asm_amd64.s
src/runtime/asm_arm.s
src/runtime/cgo/callbacks.c

index 4e5b3a24541ae11b1d05213a89a7371579fa767b..d92bed9bf014ca9268eb8d970a08c193bd911031 100644 (file)
@@ -44,7 +44,7 @@ func (p *Package) writeDefs() {
        fmt.Fprintf(fm, "int main() { return 0; }\n")
        if *importRuntimeCgo {
                fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*, int), void *a, int c) { }\n")
-               fmt.Fprintf(fm, "char* cgo_topofstack(void) { return (char*)0; }\n")
+               fmt.Fprintf(fm, "char* _cgo_topofstack(void) { return (char*)0; }\n")
        } else {
                // If we're not importing runtime/cgo, we *are* runtime/cgo,
                // which provides crosscall2.  We just need a prototype.
@@ -522,7 +522,7 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) {
        fmt.Fprintf(fgcc, "\t%s %v *a = v;\n", ctype, p.packedAttribute())
        if n.FuncType.Result != nil {
                // Save the stack top for use below.
-               fmt.Fprintf(fgcc, "\tchar *stktop = cgo_topofstack();\n")
+               fmt.Fprintf(fgcc, "\tchar *stktop = _cgo_topofstack();\n")
        }
        fmt.Fprintf(fgcc, "\t")
        if t := n.FuncType.Result; t != nil {
@@ -552,7 +552,7 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) {
        if n.FuncType.Result != nil {
                // The cgo call may have caused a stack copy (via a callback).
                // Adjust the return value pointer appropriately.
-               fmt.Fprintf(fgcc, "\ta = (void*)((char*)a + (cgo_topofstack() - stktop));\n")
+               fmt.Fprintf(fgcc, "\ta = (void*)((char*)a + (_cgo_topofstack() - stktop));\n")
                // Save the return value.
                fmt.Fprintf(fgcc, "\ta->r = r;\n")
        }
@@ -1143,7 +1143,7 @@ __cgo_size_assert(__cgo_long_long, 8)
 __cgo_size_assert(float, 4)
 __cgo_size_assert(double, 8)
 
-extern char* cgo_topofstack(void);
+extern char* _cgo_topofstack(void);
 
 #include <errno.h>
 #include <string.h>
index f1b3346e83341745268199e2040dbd35e08cfc79..1495246a25e419aafb6a6e3639c56c7d7c218f86 100644 (file)
@@ -2278,7 +2278,7 @@ TEXT runtime·return0(SB), NOSPLIT, $0
 
 // Called from cgo wrappers, this function returns g->m->curg.stack.hi.
 // Must obey the gcc calling convention.
-TEXT cgo_topofstack(SB),NOSPLIT,$0
+TEXT _cgo_topofstack(SB),NOSPLIT,$0
        get_tls(CX)
        MOVL    g(CX), AX
        MOVL    g_m(AX), AX
index b4c6c6bdca99a7acfa1adb2298e8fef4119dae87..3f7f6084101decc8798d1d1a0be269c8d3b85d01 100644 (file)
@@ -2224,7 +2224,7 @@ TEXT runtime·return0(SB), NOSPLIT, $0
 
 // Called from cgo wrappers, this function returns g->m->curg.stack.hi.
 // Must obey the gcc calling convention.
-TEXT cgo_topofstack(SB),NOSPLIT,$0
+TEXT _cgo_topofstack(SB),NOSPLIT,$0
        get_tls(CX)
        MOVQ    g(CX), AX
        MOVQ    g_m(AX), AX
index 2c5de8afb19d2b42a3de63d8f2de327b33512fe6..06bd0751dbe56721af127a57016f530c81e5b2b7 100644 (file)
@@ -1303,7 +1303,8 @@ yieldloop:
 
 // Called from cgo wrappers, this function returns g->m->curg.stack.hi.
 // Must obey the gcc calling convention.
-TEXT cgo_topofstack(SB),NOSPLIT,$0
+TEXT _cgo_topofstack(SB),NOSPLIT,$0
+       BL      runtime·load_g(SB)
        MOVW    g_m(g), R0
        MOVW    m_curg(R0), R0
        MOVW    (g_stack+stack_hi)(R0), R0
index cea9b1667ff78d1e183f1c2766600d42bc9c98ee..282beeea8830ff28830c52373f6f5249d2c92c1d 100644 (file)
@@ -79,5 +79,5 @@ void (*_cgo_free)(void*) = x_cgo_free;
 extern void x_cgo_thread_start(void*);
 void (*_cgo_thread_start)(void*) = x_cgo_thread_start;
 
-#pragma cgo_export_static cgo_topofstack
-#pragma cgo_export_dynamic cgo_topofstack
+#pragma cgo_export_static _cgo_topofstack
+#pragma cgo_export_dynamic _cgo_topofstack