diff --git a/src/pkg/runtime/cgocall.c b/src/pkg/runtime/cgocall.c index e6ece954221..74e5a308573 100644 --- a/src/pkg/runtime/cgocall.c +++ b/src/pkg/runtime/cgocall.c @@ -53,13 +53,12 @@ runtime·cgocall(void (*fn)(void*), void *arg) // (arg/argsize) on to the stack, calls the function, copies the // arguments back where they came from, and finally returns to the old // stack. -uintptr +void runtime·cgocallback(void (*fn)(void), void *arg, int32 argsize) { Gobuf oldsched, oldg1sched; G *g1; void *sp; - uintptr ret; if(g != m->g0) runtime·throw("bad g in cgocallback"); @@ -71,11 +70,11 @@ runtime·cgocallback(void (*fn)(void), void *arg, int32 argsize) runtime·startcgocallback(g1); sp = g1->sched.sp - argsize; - if(sp < g1->stackguard - StackGuard + 4) // +4 for return address + if(sp < g1->stackguard - StackGuard + 8) // +8 for return address runtime·throw("g stack overflow in cgocallback"); runtime·mcpy(sp, arg, argsize); - ret = runtime·runcgocallback(g1, sp, fn); + runtime·runcgocallback(g1, sp, fn); runtime·mcpy(arg, sp, argsize); @@ -83,8 +82,6 @@ runtime·cgocallback(void (*fn)(void), void *arg, int32 argsize) m->sched = oldsched; g1->sched = oldg1sched; - - return ret; } void diff --git a/src/pkg/runtime/cgocall.h b/src/pkg/runtime/cgocall.h index 7c24e167b4a..1ad954eb120 100644 --- a/src/pkg/runtime/cgocall.h +++ b/src/pkg/runtime/cgocall.h @@ -7,6 +7,6 @@ */ void runtime·cgocall(void (*fn)(void*), void*); -uintptr runtime·cgocallback(void (*fn)(void), void*, int32); +void runtime·cgocallback(void (*fn)(void), void*, int32); void *runtime·cmalloc(uintptr); void runtime·cfree(void*); diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index b76632a2d4e..cea07e4a70a 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -443,7 +443,7 @@ void runtime·breakpoint(void); void runtime·gosched(void); void runtime·goexit(void); void runtime·runcgo(void (*fn)(void*), void*); -uintptr runtime·runcgocallback(G*, void*, void (*fn)()); +void runtime·runcgocallback(G*, void*, void (*fn)()); void runtime·entersyscall(void); void runtime·exitsyscall(void); void runtime·startcgocallback(G*); diff --git a/src/pkg/runtime/windows/386/sys.s b/src/pkg/runtime/windows/386/sys.s index d1a8a49a9c3..26069d3912d 100644 --- a/src/pkg/runtime/windows/386/sys.s +++ b/src/pkg/runtime/windows/386/sys.s @@ -107,7 +107,11 @@ sigdone: // DX = total size of arguments // TEXT runtime·callbackasm+0(SB),7,$0 + // preserve whatever's at the memory location that + // the callback will use to store the return value LEAL 8(SP), CX + PUSHL 0(CX)(DX*1) + ADDL $4, DX // extend argsize by size of return value // save registers as required for windows callback PUSHL 0(FS) @@ -129,7 +133,7 @@ TEXT runtime·callbackasm+0(SB),7,$0 CALL runtime·cgocallback(SB) // restore registers as required for windows callback - POPL CX + POPL AX POPL CX POPL DX POPL BX @@ -139,6 +143,8 @@ TEXT runtime·callbackasm+0(SB),7,$0 POPL 0(FS) CLD + MOVL -4(CX)(DX*1), AX + POPL -4(CX)(DX*1) RET // void tstart(M *newm);