github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/pkg/runtime/sys_arm.c (about) 1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "runtime.h" 6 7 // adjust Gobuf as if it executed a call to fn with context ctxt 8 // and then did an immediate Gosave. 9 void 10 runtime·gostartcall(Gobuf *gobuf, void (*fn)(void), void *ctxt) 11 { 12 if(gobuf->lr != 0) 13 runtime·throw("invalid use of gostartcall"); 14 gobuf->lr = gobuf->pc; 15 gobuf->pc = (uintptr)fn; 16 gobuf->ctxt = ctxt; 17 } 18 19 // Called to rewind context saved during morestack back to beginning of function. 20 // To help us, the linker emits a jmp back to the beginning right after the 21 // call to morestack. We just have to decode and apply that jump. 22 void 23 runtime·rewindmorestack(Gobuf *gobuf) 24 { 25 uint32 inst; 26 27 inst = *(uint32*)gobuf->pc; 28 if((gobuf->pc&3) == 0 && (inst>>24) == 0x9a) { 29 //runtime·printf("runtime: rewind pc=%p to pc=%p\n", gobuf->pc, gobuf->pc + ((int32)(inst<<8)>>6) + 8); 30 gobuf->pc += ((int32)(inst<<8)>>6) + 8; 31 return; 32 } 33 runtime·printf("runtime: pc=%p %x\n", gobuf->pc, inst); 34 runtime·throw("runtime: misuse of rewindmorestack"); 35 }