LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "arch_GOARCH.h" | 6 #include "arch_GOARCH.h" |
7 #include "stack.h" | 7 #include "stack.h" |
8 #include "cgocall.h" | 8 #include "cgocall.h" |
9 #include "race.h" | 9 #include "race.h" |
10 #include "../../cmd/ld/textflag.h" | 10 #include "../../cmd/ld/textflag.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 m->ncgocall++; | 115 m->ncgocall++; |
116 | 116 |
117 /* | 117 /* |
118 * Lock g to m to ensure we stay on the same stack if we do a | 118 * Lock g to m to ensure we stay on the same stack if we do a |
119 * cgo callback. Add entry to defer stack in case of panic. | 119 * cgo callback. Add entry to defer stack in case of panic. |
120 */ | 120 */ |
121 runtime·lockOSThread(); | 121 runtime·lockOSThread(); |
122 d.fn = &endcgoV; | 122 d.fn = &endcgoV; |
123 d.siz = 0; | 123 d.siz = 0; |
124 d.link = g->defer; | 124 d.link = g->defer; |
125 » d.argp = (void*)-1; // unused because unlockm never recovers | 125 » d.argp = NoArgs; |
126 d.special = true; | 126 d.special = true; |
127 g->defer = &d; | 127 g->defer = &d; |
128 ········ | 128 ········ |
129 m->ncgo++; | 129 m->ncgo++; |
130 | 130 |
131 /* | 131 /* |
132 * Announce we are entering a system call | 132 * Announce we are entering a system call |
133 * so that the scheduler knows to create another | 133 * so that the scheduler knows to create another |
134 * M to run goroutines while we are in the | 134 * M to run goroutines while we are in the |
135 * foreign code. | 135 * foreign code. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 if(m->needextram) { | 253 if(m->needextram) { |
254 m->needextram = 0; | 254 m->needextram = 0; |
255 runtime·newextram(); | 255 runtime·newextram(); |
256 } | 256 } |
257 | 257 |
258 // Add entry to defer stack in case of panic. | 258 // Add entry to defer stack in case of panic. |
259 d.fn = &unwindmf; | 259 d.fn = &unwindmf; |
260 d.siz = 0; | 260 d.siz = 0; |
261 d.link = g->defer; | 261 d.link = g->defer; |
262 » d.argp = (void*)-1; // unused because unwindm never recovers | 262 » d.argp = NoArgs; |
263 d.special = true; | 263 d.special = true; |
264 g->defer = &d; | 264 g->defer = &d; |
265 | 265 |
266 if(raceenabled) | 266 if(raceenabled) |
267 runtime·raceacquire(&cgosync); | 267 runtime·raceacquire(&cgosync); |
268 | 268 |
269 // Invoke callback. | 269 // Invoke callback. |
270 cb = CBARGS; | 270 cb = CBARGS; |
271 runtime·newstackcall(cb->fn, cb->arg, cb->argsize); | 271 runtime·newstackcall(cb->fn, cb->arg, cb->argsize); |
272 | 272 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 runtime·cgounimpl(void) // called from (incomplete) assembly | 309 runtime·cgounimpl(void) // called from (incomplete) assembly |
310 { | 310 { |
311 runtime·throw("runtime: cgo not implemented"); | 311 runtime·throw("runtime: cgo not implemented"); |
312 } | 312 } |
313 | 313 |
314 // For cgo-using programs with external linking, | 314 // For cgo-using programs with external linking, |
315 // export "main" (defined in assembly) so that libc can handle basic | 315 // export "main" (defined in assembly) so that libc can handle basic |
316 // C runtime startup and call the Go program as if it were | 316 // C runtime startup and call the Go program as if it were |
317 // the C main function. | 317 // the C main function. |
318 #pragma cgo_export_static main | 318 #pragma cgo_export_static main |
LEFT | RIGHT |