// (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");
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);
m->sched = oldsched;
g1->sched = oldg1sched;
-
- return ret;
}
void
*/
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*);
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*);
// 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)
CALL runtime·cgocallback(SB)
// restore registers as required for windows callback
- POPL CX
+ POPL AX
POPL CX
POPL DX
POPL BX
POPL 0(FS)
CLD
+ MOVL -4(CX)(DX*1), AX
+ POPL -4(CX)(DX*1)
RET
// void tstart(M *newm);