OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void | 97 void |
98 runtime·cgocall(void (*fn)(void*), void *arg) | 98 runtime·cgocall(void (*fn)(void*), void *arg) |
99 { | 99 { |
100 Defer d; | 100 Defer d; |
101 | 101 |
102 if(m->racecall) { | 102 if(m->racecall) { |
103 runtime·asmcgocall(fn, arg); | 103 runtime·asmcgocall(fn, arg); |
104 return; | 104 return; |
105 } | 105 } |
106 | 106 |
107 » if(!runtime·iscgo && !Windows) | 107 » if(!runtime·iscgo && !Windows && !Solaris) |
108 runtime·throw("cgocall unavailable"); | 108 runtime·throw("cgocall unavailable"); |
109 | 109 |
110 if(fn == 0) | 110 if(fn == 0) |
111 runtime·throw("cgocall nil"); | 111 runtime·throw("cgocall nil"); |
112 | 112 |
113 if(raceenabled) | 113 if(raceenabled) |
114 runtime·racereleasemerge(&cgosync); | 114 runtime·racereleasemerge(&cgosync); |
115 | 115 |
116 // Create an extra M for callbacks on threads not created by Go on first
cgo call. | 116 // Create an extra M for callbacks on threads not created by Go on first
cgo call. |
117 if(runtime·needextram && runtime·cas(&runtime·needextram, 1, 0)) | 117 if(runtime·needextram && runtime·cas(&runtime·needextram, 1, 0)) |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 runtime·cgounimpl(void) // called from (incomplete) assembly | 334 runtime·cgounimpl(void) // called from (incomplete) assembly |
335 { | 335 { |
336 runtime·throw("runtime: cgo not implemented"); | 336 runtime·throw("runtime: cgo not implemented"); |
337 } | 337 } |
338 | 338 |
339 // For cgo-using programs with external linking, | 339 // For cgo-using programs with external linking, |
340 // export "main" (defined in assembly) so that libc can handle basic | 340 // export "main" (defined in assembly) so that libc can handle basic |
341 // C runtime startup and call the Go program as if it were | 341 // C runtime startup and call the Go program as if it were |
342 // the C main function. | 342 // the C main function. |
343 #pragma cgo_export_static main | 343 #pragma cgo_export_static main |
OLD | NEW |