LEFT | RIGHT |
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 /* | 5 /* |
6 * basic types | 6 * basic types |
7 */ | 7 */ |
8 typedef signed char int8; | 8 typedef signed char int8; |
9 typedef unsigned char uint8; | 9 typedef unsigned char uint8; |
10 typedef signed short int16; | 10 typedef signed short int16; |
11 typedef unsigned short uint16; | 11 typedef unsigned short uint16; |
12 typedef signed int int32; | 12 typedef signed int int32; |
13 typedef unsigned int uint32; | 13 typedef unsigned int uint32; |
14 typedef signed long long int int64; | 14 typedef signed long long int int64; |
15 typedef unsigned long long int uint64; | 15 typedef unsigned long long int uint64; |
16 typedef float float32; | 16 typedef float float32; |
17 typedef double float64; | 17 typedef double float64; |
18 | 18 |
19 #ifdef _64BIT | 19 #ifdef _64BIT |
20 typedef uint64 uintptr; | 20 typedef uint64 uintptr; |
21 typedef int64 intptr; | 21 typedef int64 intptr; |
| 22 typedef int64 intgo; // Go's int |
| 23 typedef uint64 uintgo; // Go's uint |
22 #else | 24 #else |
23 typedef uint32 uintptr; | 25 typedef uint32 uintptr; |
24 typedef int32» » intptr; | 26 typedef»int32» » intptr; |
| 27 typedef»int32» » intgo; // Go's int |
| 28 typedef»uint32» » uintgo; // Go's uint |
25 #endif | 29 #endif |
26 | 30 |
27 /* | 31 /* |
28 * get rid of C types | 32 * get rid of C types |
29 * the / / / forces a syntax error immediately, | 33 * the / / / forces a syntax error immediately, |
30 * which will show "last name: XXunsigned". | 34 * which will show "last name: XXunsigned". |
31 */ | 35 */ |
32 #define unsigned XXunsigned / / / | 36 #define unsigned XXunsigned / / / |
33 #define signed XXsigned / / / | 37 #define signed XXsigned / / / |
34 #define char XXchar / / / | 38 #define char XXchar / / / |
35 #define short XXshort / / / | 39 #define short XXshort / / / |
36 #define int XXint / / / | 40 #define int XXint / / / |
37 #define long XXlong / / / | 41 #define long XXlong / / / |
38 #define float XXfloat / / / | 42 #define float XXfloat / / / |
39 #define double XXdouble / / / | 43 #define double XXdouble / / / |
40 | 44 |
41 /* | 45 /* |
42 * defined types | 46 * defined types |
43 */ | 47 */ |
44 typedef uint8 bool; | 48 typedef uint8 bool; |
45 typedef uint8 byte; | 49 typedef uint8 byte; |
46 typedef struct Func Func; | 50 typedef struct Func Func; |
47 typedef struct G G; | 51 typedef struct G G; |
48 typedef struct Gobuf Gobuf; | 52 typedef struct Gobuf Gobuf; |
49 typedef»union» Lock» » Lock; | 53 typedef»struct» Lock» » Lock; |
50 typedef struct M M; | 54 typedef struct M M; |
| 55 typedef struct P P; |
51 typedef struct Mem Mem; | 56 typedef struct Mem Mem; |
52 typedef»union» Note» » Note; | 57 typedef»struct» Note» » Note; |
53 typedef struct Slice Slice; | 58 typedef struct Slice Slice; |
54 typedef struct Stktop Stktop; | 59 typedef struct Stktop Stktop; |
55 typedef struct String String; | 60 typedef struct String String; |
| 61 typedef struct FuncVal FuncVal; |
56 typedef struct SigTab SigTab; | 62 typedef struct SigTab SigTab; |
57 typedef struct MCache MCache; | 63 typedef struct MCache MCache; |
58 typedef struct FixAlloc FixAlloc; | 64 typedef struct FixAlloc FixAlloc; |
59 typedef struct Iface Iface; | 65 typedef struct Iface Iface; |
60 typedef struct Itab Itab; | 66 typedef struct Itab Itab; |
61 typedef struct InterfaceType InterfaceType; | 67 typedef struct InterfaceType InterfaceType; |
62 typedef struct Eface Eface; | 68 typedef struct Eface Eface; |
63 typedef struct Type Type; | 69 typedef struct Type Type; |
64 typedef struct ChanType ChanType; | 70 typedef struct ChanType ChanType; |
65 typedef struct MapType MapType; | 71 typedef struct MapType MapType; |
66 typedef struct Defer Defer; | 72 typedef struct Defer Defer; |
| 73 typedef struct DeferChunk DeferChunk; |
67 typedef struct Panic Panic; | 74 typedef struct Panic Panic; |
68 typedef struct Hmap Hmap; | 75 typedef struct Hmap Hmap; |
69 typedef struct Hchan Hchan; | 76 typedef struct Hchan Hchan; |
70 typedef struct Complex64 Complex64; | 77 typedef struct Complex64 Complex64; |
71 typedef struct Complex128 Complex128; | 78 typedef struct Complex128 Complex128; |
72 typedef struct WinCall WinCall; | 79 typedef struct WinCall WinCall; |
73 typedef struct SEH SEH; | 80 typedef struct SEH SEH; |
74 typedef struct Timers Timers; | 81 typedef struct Timers Timers; |
75 typedef struct Timer Timer; | 82 typedef struct Timer Timer; |
76 typedef struct» GCStats»» GCStats; | 83 typedef»struct» GCStats»» GCStats; |
77 typedef struct» LFNode» » LFNode; | 84 typedef»struct» LFNode» » LFNode; |
78 typedef struct» ParFor» » ParFor; | 85 typedef»struct» ParFor» » ParFor; |
79 typedef struct» ParForThread» ParForThread; | 86 typedef»struct» ParForThread» ParForThread; |
80 | 87 typedef»struct» CgoMal» » CgoMal; |
81 /* | 88 typedef»struct» PollDesc» PollDesc; |
82 * per-cpu declaration. | 89 |
| 90 /* |
| 91 * Per-CPU declaration. |
| 92 * |
83 * "extern register" is a special storage class implemented by 6c, 8c, etc. | 93 * "extern register" is a special storage class implemented by 6c, 8c, etc. |
84 * on machines with lots of registers, it allocates a register that will not be | 94 * On the ARM, it is an actual register; elsewhere it is a slot in thread- |
85 * used in generated code. on the x86, it allocates a slot indexed by a | 95 * local storage indexed by a segment register. See zasmhdr in |
86 * segment register. | 96 * src/cmd/dist/buildruntime.c for details, and be aware that the linker may |
| 97 * make further OS-specific changes to the compiler's output. For example, |
| 98 * 6l/linux rewrites 0(GS) as -16(FS). |
87 * | 99 * |
88 * amd64: allocated downwards from R15 | 100 * Every C file linked into a Go program must include runtime.h so that the |
89 * x86: allocated upwards from 0(GS) | 101 * C compiler (6c, 8c, etc.) knows to avoid other uses of these dedicated |
90 * arm: allocated downwards from R10 | 102 * registers. The Go compiler (6g, 8g, etc.) knows to avoid them. |
91 * | |
92 * every C file linked into a Go program must include runtime.h | |
93 * so that the C compiler knows to avoid other uses of these registers. | |
94 * the Go compilers know to avoid them. | |
95 */ | 103 */ |
96 extern register G* g; | 104 extern register G* g; |
97 extern register M* m; | 105 extern register M* m; |
98 | 106 |
99 /* | 107 /* |
100 * defined constants | 108 * defined constants |
101 */ | 109 */ |
102 enum | 110 enum |
103 { | 111 { |
104 // G status | 112 // G status |
105 // | 113 // |
106 // If you add to this list, add to the list | 114 // If you add to this list, add to the list |
107 // of "okay during garbage collection" status | 115 // of "okay during garbage collection" status |
108 // in mgc0.c too. | 116 // in mgc0.c too. |
109 Gidle, | 117 Gidle, |
110 Grunnable, | 118 Grunnable, |
111 Grunning, | 119 Grunning, |
112 Gsyscall, | 120 Gsyscall, |
113 Gwaiting, | 121 Gwaiting, |
114 » Gmoribund, | 122 » Gmoribund_unused, // currently unused, but hardcoded in gdb scripts |
115 Gdead, | 123 Gdead, |
| 124 }; |
| 125 enum |
| 126 { |
| 127 // P status |
| 128 Pidle, |
| 129 Prunning, |
| 130 Psyscall, |
| 131 Pgcstop, |
| 132 Pdead, |
116 }; | 133 }; |
117 enum | 134 enum |
118 { | 135 { |
119 true = 1, | 136 true = 1, |
120 false = 0, | 137 false = 0, |
121 }; | 138 }; |
122 enum | 139 enum |
123 { | 140 { |
124 PtrSize = sizeof(void*), | 141 PtrSize = sizeof(void*), |
125 }; | 142 }; |
126 | 143 enum |
| 144 { |
| 145 » // Per-M stack segment cache size. |
| 146 » StackCacheSize = 32, |
| 147 » // Global <-> per-M stack segment cache transfer batch size. |
| 148 » StackCacheBatch = 16, |
| 149 }; |
| 150 enum |
| 151 { |
| 152 » // This value is generated by the linker and should be kept in |
| 153 » // sync with cmd/ld/lib.h |
| 154 » ArgsSizeUnknown = 0x80000000, |
| 155 }; |
127 /* | 156 /* |
128 * structures | 157 * structures |
129 */ | 158 */ |
130 union» Lock | 159 struct» Lock |
131 { | 160 { |
132 » uint32» key;» // futex-based impl | 161 » // Futex-based impl treats it as uint32 key, |
133 » M*» waitm;» // linked list of waiting M's (sema-based impl) | 162 » // while sema-based impl as M* waitm. |
134 }; | 163 » // Used to be a union, but unions break precise GC. |
135 union» Note | 164 » uintptr»key; |
136 { | 165 }; |
137 » uint32» key;» // futex-based impl | 166 struct» Note |
138 » M*» waitm;» // waiting M (sema-based impl) | 167 { |
| 168 » // Futex-based impl treats it as uint32 key, |
| 169 » // while sema-based impl as M* waitm. |
| 170 » // Used to be a union, but unions break precise GC. |
| 171 » uintptr»key; |
139 }; | 172 }; |
140 struct String | 173 struct String |
141 { | 174 { |
142 byte* str; | 175 byte* str; |
143 » int32» len; | 176 » intgo» len; |
| 177 }; |
| 178 struct FuncVal |
| 179 { |
| 180 » void» (*fn)(void); |
| 181 » // variable-size, fn-specific data here |
144 }; | 182 }; |
145 struct Iface | 183 struct Iface |
146 { | 184 { |
147 Itab* tab; | 185 Itab* tab; |
148 void* data; | 186 void* data; |
149 }; | 187 }; |
150 struct Eface | 188 struct Eface |
151 { | 189 { |
152 Type* type; | 190 Type* type; |
153 void* data; | 191 void* data; |
154 }; | 192 }; |
155 struct Complex64 | 193 struct Complex64 |
156 { | 194 { |
157 float32 real; | 195 float32 real; |
158 float32 imag; | 196 float32 imag; |
159 }; | 197 }; |
160 struct Complex128 | 198 struct Complex128 |
161 { | 199 { |
162 float64 real; | 200 float64 real; |
163 float64 imag; | 201 float64 imag; |
164 }; | 202 }; |
165 | 203 |
166 struct Slice | 204 struct Slice |
167 { // must not move anything | 205 { // must not move anything |
168 byte* array; // actual data | 206 byte* array; // actual data |
169 » uint32» len;» » // number of elements | 207 » uintgo» len;» » // number of elements |
170 » uint32» cap;» » // allocated number of elements | 208 » uintgo» cap;» » // allocated number of elements |
171 }; | 209 }; |
172 struct Gobuf | 210 struct Gobuf |
173 { | 211 { |
174 // The offsets of these fields are known to (hard-coded in) libmach. | 212 // The offsets of these fields are known to (hard-coded in) libmach. |
175 uintptr sp; | 213 uintptr sp; |
176 byte* pc; | 214 byte* pc; |
177 G* g; | 215 G* g; |
178 }; | 216 }; |
179 struct GCStats | 217 struct GCStats |
180 { | 218 { |
181 // the struct must consist of only uint64's, | 219 // the struct must consist of only uint64's, |
182 // because it is casted to uint64[]. | 220 // because it is casted to uint64[]. |
183 uint64 nhandoff; | 221 uint64 nhandoff; |
184 uint64 nhandoffcnt; | 222 uint64 nhandoffcnt; |
185 uint64 nprocyield; | 223 uint64 nprocyield; |
186 uint64 nosyield; | 224 uint64 nosyield; |
187 uint64 nsleep; | 225 uint64 nsleep; |
188 }; | 226 }; |
189 struct G | 227 struct G |
190 { | 228 { |
191 uintptr stackguard; // cannot move - also known to linker, libmach,
runtime/cgo | 229 uintptr stackguard; // cannot move - also known to linker, libmach,
runtime/cgo |
192 uintptr stackbase; // cannot move - also known to libmach, runtime/
cgo | 230 uintptr stackbase; // cannot move - also known to libmach, runtime/
cgo |
193 Defer* defer; | 231 Defer* defer; |
194 Panic* panic; | 232 Panic* panic; |
195 Gobuf sched; | 233 Gobuf sched; |
196 uintptr gcstack; // if status==Gsyscall, gcstack = stackb
ase to use during gc | 234 uintptr gcstack; // if status==Gsyscall, gcstack = stackb
ase to use during gc |
197 uintptr gcsp; // if status==Gsyscall, gcsp = sched.sp to use d
uring gc | 235 uintptr gcsp; // if status==Gsyscall, gcsp = sched.sp to use d
uring gc |
| 236 byte* gcpc; // if status==Gsyscall, gcpc = sched.pc to use d
uring gc |
198 uintptr gcguard; // if status==Gsyscall, gcguard = stackg
uard to use during gc | 237 uintptr gcguard; // if status==Gsyscall, gcguard = stackg
uard to use during gc |
199 uintptr stack0; | 238 uintptr stack0; |
200 » byte*» entry;» » // initial function | 239 » FuncVal*» fnstart;» » // initial function |
201 G* alllink; // on allg | 240 G* alllink; // on allg |
202 void* param; // passed parameter on wakeup | 241 void* param; // passed parameter on wakeup |
203 int16 status; | 242 int16 status; |
204 » int32» goid; | 243 » int64» goid; |
205 uint32 selgen; // valid sudog pointer | 244 uint32 selgen; // valid sudog pointer |
206 int8* waitreason; // if status==Gwaiting | 245 int8* waitreason; // if status==Gwaiting |
207 G* schedlink; | 246 G* schedlink; |
208 bool readyonstop; | |
209 bool ispanic; | 247 bool ispanic; |
| 248 bool issystem; // do not output in stack dump |
| 249 bool isbackground; // ignore in deadlock detector |
| 250 bool blockingsyscall; // hint that the next syscall will block |
| 251 int8 raceignore; // ignore race detection events |
210 M* m; // for debuggers, but offset not hard-coded | 252 M* m; // for debuggers, but offset not hard-coded |
211 M* lockedm; | 253 M* lockedm; |
212 M* idlem; | |
213 int32 sig; | 254 int32 sig; |
214 int32 writenbuf; | 255 int32 writenbuf; |
215 byte* writebuf; | 256 byte* writebuf; |
| 257 DeferChunk *dchunk; |
| 258 DeferChunk *dchunknext; |
216 uintptr sigcode0; | 259 uintptr sigcode0; |
217 uintptr sigcode1; | 260 uintptr sigcode1; |
218 uintptr sigpc; | 261 uintptr sigpc; |
219 uintptr gopc; // pc of go statement that created this goroutine | 262 uintptr gopc; // pc of go statement that created this goroutine |
| 263 uintptr racectx; |
220 uintptr end[]; | 264 uintptr end[]; |
221 }; | 265 }; |
222 struct M | 266 struct M |
223 { | 267 { |
224 // The offsets of these fields are known to (hard-coded in) libmach. | 268 // The offsets of these fields are known to (hard-coded in) libmach. |
225 G* g0; // goroutine with scheduling stack | 269 G* g0; // goroutine with scheduling stack |
226 void (*morepc)(void); | 270 void (*morepc)(void); |
227 void* moreargp; // argument pointer for more stack | 271 void* moreargp; // argument pointer for more stack |
228 Gobuf morebuf; // gobuf arg to morestack | 272 Gobuf morebuf; // gobuf arg to morestack |
229 | 273 |
230 // Fields not known to debuggers. | 274 // Fields not known to debuggers. |
231 uint32 moreframesize; // size arguments to morestack | 275 uint32 moreframesize; // size arguments to morestack |
232 uint32 moreargsize; | 276 uint32 moreargsize; |
233 uintptr cret; // return value from C | 277 uintptr cret; // return value from C |
234 uint64 procid; // for debuggers, but offset not hard-coded | 278 uint64 procid; // for debuggers, but offset not hard-coded |
235 G* gsignal; // signal-handling G | 279 G* gsignal; // signal-handling G |
236 » uint32» tls[8];»» // thread-local storage (for 386 extern register
) | 280 » uintptr»tls[4];»» // thread-local storage (for x86 extern register
) |
| 281 » void» (*mstartfn)(void); |
237 G* curg; // current running goroutine | 282 G* curg; // current running goroutine |
| 283 P* p; // attached P for executing Go code (nil if not
executing Go code) |
| 284 P* nextp; |
238 int32 id; | 285 int32 id; |
239 int32 mallocing; | 286 int32 mallocing; |
| 287 int32 throwing; |
240 int32 gcing; | 288 int32 gcing; |
241 int32 locks; | 289 int32 locks; |
242 int32 nomemprof; | 290 int32 nomemprof; |
243 int32 waitnextg; | |
244 int32 dying; | 291 int32 dying; |
245 int32 profilehz; | 292 int32 profilehz; |
246 int32 helpgc; | 293 int32 helpgc; |
| 294 bool blockingsyscall; |
| 295 bool spinning; |
247 uint32 fastrand; | 296 uint32 fastrand; |
248 » uint64» ncgocall; | 297 » uint64» ncgocall;» // number of cgo calls in total |
249 » Note» havenextg; | 298 » int32» ncgo;» » // number of cgo calls currently in progress |
250 » G*» nextg; | 299 » CgoMal*»cgomal; |
| 300 » Note» park; |
251 M* alllink; // on allm | 301 M* alllink; // on allm |
252 M* schedlink; | 302 M* schedlink; |
253 uint32 machport; // Return address for Mach IPC (OS X) | 303 uint32 machport; // Return address for Mach IPC (OS X) |
254 MCache *mcache; | 304 MCache *mcache; |
255 » FixAlloc» *stackalloc; | 305 » int32» stackinuse; |
| 306 » uint32» stackcachepos; |
| 307 » uint32» stackcachecnt; |
| 308 » void*» stackcache[StackCacheSize]; |
256 G* lockedg; | 309 G* lockedg; |
257 G* idleg; | |
258 uintptr createstack[32]; // Stack that created this thread. | 310 uintptr createstack[32]; // Stack that created this thread. |
259 uint32 freglo[16]; // D[i] lsb and F[i] | 311 uint32 freglo[16]; // D[i] lsb and F[i] |
260 uint32 freghi[16]; // D[i] msb and F[i+16] | 312 uint32 freghi[16]; // D[i] msb and F[i+16] |
261 uint32 fflag; // floating point compare flags | 313 uint32 fflag; // floating point compare flags |
| 314 uint32 locked; // tracking for LockOSThread |
262 M* nextwaitm; // next M waiting for lock | 315 M* nextwaitm; // next M waiting for lock |
263 uintptr waitsema; // semaphore for parking on locks | 316 uintptr waitsema; // semaphore for parking on locks |
264 uint32 waitsemacount; | 317 uint32 waitsemacount; |
265 uint32 waitsemalock; | 318 uint32 waitsemalock; |
266 GCStats gcstats; | 319 GCStats gcstats; |
| 320 bool racecall; |
| 321 bool needextram; |
| 322 void* racepc; |
| 323 void (*waitunlockf)(Lock*); |
| 324 void* waitlock; |
| 325 uint32 moreframesize_minalloc; |
267 | 326 |
268 uintptr settype_buf[1024]; | 327 uintptr settype_buf[1024]; |
269 uintptr settype_bufsize; | 328 uintptr settype_bufsize; |
270 | |
271 uint32 moreframesize_minalloc; | |
272 | 329 |
273 #ifdef GOOS_windows | 330 #ifdef GOOS_windows |
274 void* thread; // thread handle | 331 void* thread; // thread handle |
275 #endif | 332 #endif |
| 333 #ifdef GOOS_plan9 |
| 334 int8* notesig; |
| 335 byte* errstr; |
| 336 #endif |
276 SEH* seh; | 337 SEH* seh; |
277 uintptr end[]; | 338 uintptr end[]; |
| 339 }; |
| 340 |
| 341 struct P |
| 342 { |
| 343 Lock; |
| 344 |
| 345 uint32 status; // one of Pidle/Prunning/... |
| 346 P* link; |
| 347 uint32 tick; // incremented on every scheduler or system call |
| 348 M* m; // back-link to associated M (nil if idle) |
| 349 MCache* mcache; |
| 350 |
| 351 // Queue of runnable goroutines. |
| 352 G** runq; |
| 353 int32 runqhead; |
| 354 int32 runqtail; |
| 355 int32 runqsize; |
| 356 |
| 357 // Available G's (status == Gdead) |
| 358 G* gfree; |
| 359 int32 gfreecnt; |
| 360 |
| 361 byte pad[64]; |
| 362 }; |
| 363 |
| 364 // The m->locked word holds a single bit saying whether |
| 365 // external calls to LockOSThread are in effect, and then a counter |
| 366 // of the internal nesting depth of lockOSThread / unlockOSThread. |
| 367 enum |
| 368 { |
| 369 LockExternal = 1, |
| 370 LockInternal = 2, |
278 }; | 371 }; |
279 | 372 |
280 struct Stktop | 373 struct Stktop |
281 { | 374 { |
282 // The offsets of these fields are known to (hard-coded in) libmach. | 375 // The offsets of these fields are known to (hard-coded in) libmach. |
283 uint8* stackguard; | 376 uint8* stackguard; |
284 uint8* stackbase; | 377 uint8* stackbase; |
285 Gobuf gobuf; | 378 Gobuf gobuf; |
286 uint32 argsize; | 379 uint32 argsize; |
287 | 380 |
288 uint8* argp; // pointer to arguments in old frame | 381 uint8* argp; // pointer to arguments in old frame |
289 uintptr free; // if free>0, call stackfree using free as size | 382 uintptr free; // if free>0, call stackfree using free as size |
290 bool panic; // is this frame the top of a panic? | 383 bool panic; // is this frame the top of a panic? |
291 }; | 384 }; |
292 struct SigTab | 385 struct SigTab |
293 { | 386 { |
294 int32 flags; | 387 int32 flags; |
295 int8 *name; | 388 int8 *name; |
296 }; | 389 }; |
297 enum | 390 enum |
298 { | 391 { |
299 SigNotify = 1<<0, // let signal.Notify have signal, even if from k
ernel | 392 SigNotify = 1<<0, // let signal.Notify have signal, even if from k
ernel |
300 SigKill = 1<<1, // if signal.Notify doesn't take it, exit quietl
y | 393 SigKill = 1<<1, // if signal.Notify doesn't take it, exit quietl
y |
301 SigThrow = 1<<2, // if signal.Notify doesn't take it, exit loudly | 394 SigThrow = 1<<2, // if signal.Notify doesn't take it, exit loudly |
302 SigPanic = 1<<3, // if the signal is from the kernel, panic | 395 SigPanic = 1<<3, // if the signal is from the kernel, panic |
303 SigDefault = 1<<4, // if the signal isn't explicitly requested, don
't monitor it | 396 SigDefault = 1<<4, // if the signal isn't explicitly requested, don
't monitor it |
| 397 SigHandling = 1<<5, // our signal handler is registered |
| 398 SigIgnored = 1<<6, // the signal was ignored before we registered f
or it |
304 }; | 399 }; |
305 | 400 |
306 // NOTE(rsc): keep in sync with extern.go:/type.Func. | 401 // NOTE(rsc): keep in sync with extern.go:/type.Func. |
307 // Eventually, the loaded symbol table should be closer to this form. | 402 // Eventually, the loaded symbol table should be closer to this form. |
308 struct Func | 403 struct Func |
309 { | 404 { |
310 String name; | 405 String name; |
311 String type; // go type string | 406 String type; // go type string |
312 String src; // src file name | 407 String src; // src file name |
313 Slice pcln; // pc/ln tab for this func | 408 Slice pcln; // pc/ln tab for this func |
314 uintptr entry; // entry pc | 409 uintptr entry; // entry pc |
315 uintptr pc0; // starting pc, ln for table | 410 uintptr pc0; // starting pc, ln for table |
316 int32 ln0; | 411 int32 ln0; |
317 int32 frame; // stack frame size | 412 int32 frame; // stack frame size |
318 » int32» args;» // number of 32-bit in/out args | 413 » int32» args;» // in/out args size |
319 » int32» locals;»// number of 32-bit locals | 414 » int32» locals;»// locals size |
320 }; | 415 }; |
321 | 416 |
322 // layout of Itab known to compilers | 417 // layout of Itab known to compilers |
323 struct Itab | 418 struct Itab |
324 { | 419 { |
325 InterfaceType* inter; | 420 InterfaceType* inter; |
326 Type* type; | 421 Type* type; |
327 Itab* link; | 422 Itab* link; |
328 int32 bad; | 423 int32 bad; |
329 int32 unused; | 424 int32 unused; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // If this struct changes, adjust ../time/sleep.go:/runtimeTimer. | 466 // If this struct changes, adjust ../time/sleep.go:/runtimeTimer. |
372 struct Timer | 467 struct Timer |
373 { | 468 { |
374 int32 i; // heap index | 469 int32 i; // heap index |
375 | 470 |
376 // Timer wakes up at when, and then at when+period, ... (period > 0 only
) | 471 // Timer wakes up at when, and then at when+period, ... (period > 0 only
) |
377 // each time calling f(now, arg) in the timer goroutine, so f must be | 472 // each time calling f(now, arg) in the timer goroutine, so f must be |
378 // a well-behaved function and not block. | 473 // a well-behaved function and not block. |
379 int64 when; | 474 int64 when; |
380 int64 period; | 475 int64 period; |
381 » void» (*f)(int64, Eface); | 476 » FuncVal»*fv; |
382 Eface arg; | 477 Eface arg; |
383 }; | 478 }; |
384 | 479 |
385 // Lock-free stack node. | 480 // Lock-free stack node. |
386 struct LFNode | 481 struct LFNode |
387 { | 482 { |
388 LFNode *next; | 483 LFNode *next; |
389 uintptr pushcnt; | 484 uintptr pushcnt; |
390 }; | 485 }; |
391 | 486 |
392 // Parallel for descriptor. | 487 // Parallel for descriptor. |
393 struct ParFor | 488 struct ParFor |
394 { | 489 { |
395 void (*body)(ParFor*, uint32); // executed for each element | 490 void (*body)(ParFor*, uint32); // executed for each element |
396 uint32 done; // number of idle threads | 491 uint32 done; // number of idle threads |
397 uint32 nthr; // total number of threads | 492 uint32 nthr; // total number of threads |
398 uint32 nthrmax; // maximum number of threads | 493 uint32 nthrmax; // maximum number of threads |
399 uint32 thrseq; // thread id sequencer | 494 uint32 thrseq; // thread id sequencer |
400 uint32 cnt; // iteration space [0, cnt) | 495 uint32 cnt; // iteration space [0, cnt) |
401 void *ctx; // arbitrary user context | 496 void *ctx; // arbitrary user context |
402 bool wait; // if true, wait while all threads finis
h processing, | 497 bool wait; // if true, wait while all threads finis
h processing, |
403 // otherwise parfor may return while oth
er threads are still working | 498 // otherwise parfor may return while oth
er threads are still working |
404 ParForThread *thr; // array of thread descriptors | 499 ParForThread *thr; // array of thread descriptors |
| 500 uint32 pad; // to align ParForThread.pos for 64-bit
atomic operations |
405 // stats | 501 // stats |
406 uint64 nsteal; | 502 uint64 nsteal; |
407 uint64 nstealcnt; | 503 uint64 nstealcnt; |
408 uint64 nprocyield; | 504 uint64 nprocyield; |
409 uint64 nosyield; | 505 uint64 nosyield; |
410 uint64 nsleep; | 506 uint64 nsleep; |
| 507 }; |
| 508 |
| 509 // Track memory allocated by code not written in Go during a cgo call, |
| 510 // so that the garbage collector can see them. |
| 511 struct CgoMal |
| 512 { |
| 513 CgoMal *next; |
| 514 void *alloc; |
411 }; | 515 }; |
412 | 516 |
413 /* | 517 /* |
414 * defined macros | 518 * defined macros |
415 * you need super-gopher-guru privilege | 519 * you need super-gopher-guru privilege |
416 * to add this list. | 520 * to add this list. |
417 */ | 521 */ |
418 #define nelem(x) (sizeof(x)/sizeof((x)[0])) | 522 #define nelem(x) (sizeof(x)/sizeof((x)[0])) |
419 #define nil ((void*)0) | 523 #define nil ((void*)0) |
420 #define offsetof(s,m) (uint32)(&(((s*)0)->m)) | 524 #define offsetof(s,m) (uint32)(&(((s*)0)->m)) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 struct Alg | 564 struct Alg |
461 { | 565 { |
462 void (*hash)(uintptr*, uintptr, void*); | 566 void (*hash)(uintptr*, uintptr, void*); |
463 void (*equal)(bool*, uintptr, void*, void*); | 567 void (*equal)(bool*, uintptr, void*, void*); |
464 void (*print)(uintptr, void*); | 568 void (*print)(uintptr, void*); |
465 void (*copy)(uintptr, void*, void*); | 569 void (*copy)(uintptr, void*, void*); |
466 }; | 570 }; |
467 | 571 |
468 extern Alg runtime·algarray[Amax]; | 572 extern Alg runtime·algarray[Amax]; |
469 | 573 |
| 574 byte* runtime·startup_random_data; |
| 575 uint32 runtime·startup_random_data_len; |
| 576 void runtime·get_random_data(byte**, int32*); |
| 577 |
| 578 enum { |
| 579 // hashinit wants this many random bytes |
| 580 HashRandomBytes = 32 |
| 581 }; |
| 582 void runtime·hashinit(void); |
| 583 |
470 void runtime·memhash(uintptr*, uintptr, void*); | 584 void runtime·memhash(uintptr*, uintptr, void*); |
471 void runtime·nohash(uintptr*, uintptr, void*); | 585 void runtime·nohash(uintptr*, uintptr, void*); |
472 void runtime·strhash(uintptr*, uintptr, void*); | 586 void runtime·strhash(uintptr*, uintptr, void*); |
473 void runtime·interhash(uintptr*, uintptr, void*); | 587 void runtime·interhash(uintptr*, uintptr, void*); |
474 void runtime·nilinterhash(uintptr*, uintptr, void*); | 588 void runtime·nilinterhash(uintptr*, uintptr, void*); |
| 589 void runtime·aeshash(uintptr*, uintptr, void*); |
| 590 void runtime·aeshash32(uintptr*, uintptr, void*); |
| 591 void runtime·aeshash64(uintptr*, uintptr, void*); |
| 592 void runtime·aeshashstr(uintptr*, uintptr, void*); |
475 | 593 |
476 void runtime·memequal(bool*, uintptr, void*, void*); | 594 void runtime·memequal(bool*, uintptr, void*, void*); |
477 void runtime·noequal(bool*, uintptr, void*, void*); | 595 void runtime·noequal(bool*, uintptr, void*, void*); |
478 void runtime·strequal(bool*, uintptr, void*, void*); | 596 void runtime·strequal(bool*, uintptr, void*, void*); |
479 void runtime·interequal(bool*, uintptr, void*, void*); | 597 void runtime·interequal(bool*, uintptr, void*, void*); |
480 void runtime·nilinterequal(bool*, uintptr, void*, void*); | 598 void runtime·nilinterequal(bool*, uintptr, void*, void*); |
| 599 |
| 600 bool runtime·memeq(void*, void*, uintptr); |
481 | 601 |
482 void runtime·memprint(uintptr, void*); | 602 void runtime·memprint(uintptr, void*); |
483 void runtime·strprint(uintptr, void*); | 603 void runtime·strprint(uintptr, void*); |
484 void runtime·interprint(uintptr, void*); | 604 void runtime·interprint(uintptr, void*); |
485 void runtime·nilinterprint(uintptr, void*); | 605 void runtime·nilinterprint(uintptr, void*); |
486 | 606 |
487 void runtime·memcopy(uintptr, void*, void*); | 607 void runtime·memcopy(uintptr, void*, void*); |
488 void runtime·memcopy8(uintptr, void*, void*); | 608 void runtime·memcopy8(uintptr, void*, void*); |
489 void runtime·memcopy16(uintptr, void*, void*); | 609 void runtime·memcopy16(uintptr, void*, void*); |
490 void runtime·memcopy32(uintptr, void*, void*); | 610 void runtime·memcopy32(uintptr, void*, void*); |
491 void runtime·memcopy64(uintptr, void*, void*); | 611 void runtime·memcopy64(uintptr, void*, void*); |
492 void runtime·memcopy128(uintptr, void*, void*); | 612 void runtime·memcopy128(uintptr, void*, void*); |
493 void runtime·memcopy(uintptr, void*, void*); | |
494 void runtime·strcopy(uintptr, void*, void*); | 613 void runtime·strcopy(uintptr, void*, void*); |
495 void runtime·algslicecopy(uintptr, void*, void*); | 614 void runtime·algslicecopy(uintptr, void*, void*); |
496 void runtime·intercopy(uintptr, void*, void*); | 615 void runtime·intercopy(uintptr, void*, void*); |
497 void runtime·nilintercopy(uintptr, void*, void*); | 616 void runtime·nilintercopy(uintptr, void*, void*); |
498 | 617 |
499 /* | 618 /* |
500 * deferred subroutine calls | 619 * deferred subroutine calls |
501 */ | 620 */ |
502 struct Defer | 621 struct Defer |
503 { | 622 { |
504 int32 siz; | 623 int32 siz; |
505 » bool» nofree; | 624 » bool» special; // not part of defer frame |
| 625 » bool» free; // if special, free when done |
506 byte* argp; // where args were copied from | 626 byte* argp; // where args were copied from |
507 byte* pc; | 627 byte* pc; |
508 » byte*» fn; | 628 » FuncVal*» fn; |
509 Defer* link; | 629 Defer* link; |
510 void* args[1]; // padded to actual size | 630 void* args[1]; // padded to actual size |
| 631 }; |
| 632 |
| 633 struct DeferChunk |
| 634 { |
| 635 DeferChunk *prev; |
| 636 uintptr off; |
511 }; | 637 }; |
512 | 638 |
513 /* | 639 /* |
514 * panics | 640 * panics |
515 */ | 641 */ |
516 struct Panic | 642 struct Panic |
517 { | 643 { |
518 Eface arg; // argument to panic | 644 Eface arg; // argument to panic |
519 byte* stackbase; // g->stackbase in panic | 645 byte* stackbase; // g->stackbase in panic |
520 Panic* link; // link to earlier panic | 646 Panic* link; // link to earlier panic |
521 bool recovered; // whether this panic is over | 647 bool recovered; // whether this panic is over |
522 }; | 648 }; |
523 | 649 |
524 /* | 650 /* |
525 * external data | 651 * external data |
526 */ | 652 */ |
527 extern String runtime·emptystring; | 653 extern String runtime·emptystring; |
528 extern uintptr runtime·zerobase; | 654 extern uintptr runtime·zerobase; |
529 G*» runtime·allg; | 655 extern» G*» runtime·allg; |
530 G*» runtime·lastg; | 656 extern» G*» runtime·lastg; |
531 M*» runtime·allm; | 657 extern» M*» runtime·allm; |
| 658 extern» P**» runtime·allp; |
532 extern int32 runtime·gomaxprocs; | 659 extern int32 runtime·gomaxprocs; |
| 660 extern uint32 runtime·needextram; |
533 extern bool runtime·singleproc; | 661 extern bool runtime·singleproc; |
534 extern uint32 runtime·panicking; | 662 extern uint32 runtime·panicking; |
535 extern» int32» runtime·gcwaiting;» » // gc is waiting to run | 663 extern» uint32» runtime·gcwaiting;» » // gc is waiting to run |
536 int8*» runtime·goos; | 664 extern» int8*» runtime·goos; |
537 int32» runtime·ncpu; | 665 extern» int32» runtime·ncpu; |
538 extern bool runtime·iscgo; | 666 extern bool runtime·iscgo; |
539 extern void (*runtime·sysargs)(int32, uint8**); | 667 extern »void» (*runtime·sysargs)(int32, uint8**); |
540 extern» volatile int32 runtime·gcing; | 668 extern» uint32» runtime·maxstring; |
| 669 extern» uint32» runtime·Hchansize; |
| 670 extern» uint32» runtime·cpuid_ecx; |
| 671 extern» uint32» runtime·cpuid_edx; |
541 | 672 |
542 /* | 673 /* |
543 * common functions and data | 674 * common functions and data |
544 */ | 675 */ |
545 int32 runtime·strcmp(byte*, byte*); | 676 int32 runtime·strcmp(byte*, byte*); |
546 byte* runtime·strstr(byte*, byte*); | 677 byte* runtime·strstr(byte*, byte*); |
547 int32 runtime·findnull(byte*); | 678 int32 runtime·findnull(byte*); |
548 int32 runtime·findnullw(uint16*); | 679 int32 runtime·findnullw(uint16*); |
549 void runtime·dump(byte*, int32); | 680 void runtime·dump(byte*, int32); |
550 int32 runtime·runetochar(byte*, int32); | 681 int32 runtime·runetochar(byte*, int32); |
551 int32 runtime·charntorune(int32*, uint8*, int32); | 682 int32 runtime·charntorune(int32*, uint8*, int32); |
552 | 683 |
553 /* | 684 /* |
554 * very low level c-called | 685 * very low level c-called |
555 */ | 686 */ |
556 #define FLUSH(x) USED(x) | 687 #define FLUSH(x) USED(x) |
557 | 688 |
558 void runtime·gogo(Gobuf*, uintptr); | 689 void runtime·gogo(Gobuf*, uintptr); |
559 void» runtime·gogocall(Gobuf*, void(*)(void)); | 690 void» runtime·gogocall(Gobuf*, void(*)(void), uintptr); |
| 691 void» runtime·gogocallfn(Gobuf*, FuncVal*); |
560 void runtime·gosave(Gobuf*); | 692 void runtime·gosave(Gobuf*); |
561 void runtime·lessstack(void); | 693 void runtime·lessstack(void); |
562 void runtime·goargs(void); | 694 void runtime·goargs(void); |
563 void runtime·goenvs(void); | 695 void runtime·goenvs(void); |
564 void runtime·goenvs_unix(void); | 696 void runtime·goenvs_unix(void); |
565 void* runtime·getu(void); | 697 void* runtime·getu(void); |
566 void runtime·throw(int8*); | 698 void runtime·throw(int8*); |
567 void runtime·panicstring(int8*); | 699 void runtime·panicstring(int8*); |
568 void runtime·prints(int8*); | 700 void runtime·prints(int8*); |
569 void runtime·printf(int8*, ...); | 701 void runtime·printf(int8*, ...); |
570 byte* runtime·mchr(byte*, byte, byte*); | 702 byte* runtime·mchr(byte*, byte, byte*); |
571 int32» runtime·mcmp(byte*, byte*, uint32); | 703 int32» runtime·mcmp(byte*, byte*, uintptr); |
572 void» runtime·memmove(void*, void*, uint32); | 704 void» runtime·memmove(void*, void*, uintptr); |
573 void* runtime·mal(uintptr); | 705 void* runtime·mal(uintptr); |
574 String runtime·catstring(String, String); | 706 String runtime·catstring(String, String); |
575 String runtime·gostring(byte*); | 707 String runtime·gostring(byte*); |
576 String runtime·gostringn(byte*, int32); | 708 String runtime·gostringn(byte*, intgo); |
577 Slice» runtime·gobytes(byte*, int32); | 709 Slice» runtime·gobytes(byte*, intgo); |
578 String runtime·gostringnocopy(byte*); | 710 String runtime·gostringnocopy(byte*); |
579 String runtime·gostringw(uint16*); | 711 String runtime·gostringw(uint16*); |
580 void runtime·initsig(void); | 712 void runtime·initsig(void); |
581 void runtime·sigenable(uint32 sig); | 713 void runtime·sigenable(uint32 sig); |
582 int32» runtime·gotraceback(void); | 714 void» runtime·sigdisable(uint32 sig); |
| 715 int32» runtime·gotraceback(bool *crash); |
583 void runtime·goroutineheader(G*); | 716 void runtime·goroutineheader(G*); |
584 void runtime·traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp); | 717 void runtime·traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp); |
585 void runtime·tracebackothers(G*); | 718 void runtime·tracebackothers(G*); |
| 719 int32 runtime·open(int8*, int32, int32); |
| 720 int32 runtime·read(int32, void*, int32); |
586 int32 runtime·write(int32, void*, int32); | 721 int32 runtime·write(int32, void*, int32); |
| 722 int32 runtime·close(int32); |
587 int32 runtime·mincore(void*, uintptr, byte*); | 723 int32 runtime·mincore(void*, uintptr, byte*); |
588 bool runtime·cas(uint32*, uint32, uint32); | 724 bool runtime·cas(uint32*, uint32, uint32); |
589 bool runtime·cas64(uint64*, uint64*, uint64); | 725 bool runtime·cas64(uint64*, uint64*, uint64); |
590 bool runtime·casp(void**, void*, void*); | 726 bool runtime·casp(void**, void*, void*); |
591 // Don't confuse with XADD x86 instruction, | 727 // Don't confuse with XADD x86 instruction, |
592 // this one is actually 'addx', that is, add-and-fetch. | 728 // this one is actually 'addx', that is, add-and-fetch. |
593 uint32 runtime·xadd(uint32 volatile*, int32); | 729 uint32 runtime·xadd(uint32 volatile*, int32); |
594 uint64 runtime·xadd64(uint64 volatile*, int64); | 730 uint64 runtime·xadd64(uint64 volatile*, int64); |
595 uint32 runtime·xchg(uint32 volatile*, uint32); | 731 uint32 runtime·xchg(uint32 volatile*, uint32); |
| 732 uint64 runtime·xchg64(uint64 volatile*, uint64); |
596 uint32 runtime·atomicload(uint32 volatile*); | 733 uint32 runtime·atomicload(uint32 volatile*); |
597 void runtime·atomicstore(uint32 volatile*, uint32); | 734 void runtime·atomicstore(uint32 volatile*, uint32); |
598 void runtime·atomicstore64(uint64 volatile*, uint64); | 735 void runtime·atomicstore64(uint64 volatile*, uint64); |
599 uint64 runtime·atomicload64(uint64 volatile*); | 736 uint64 runtime·atomicload64(uint64 volatile*); |
600 void* runtime·atomicloadp(void* volatile*); | 737 void* runtime·atomicloadp(void* volatile*); |
601 void runtime·atomicstorep(void* volatile*, void*); | 738 void runtime·atomicstorep(void* volatile*, void*); |
602 void» runtime·jmpdefer(byte*, void*); | 739 void» runtime·jmpdefer(FuncVal*, void*); |
603 void runtime·exit1(int32); | 740 void runtime·exit1(int32); |
604 void runtime·ready(G*); | 741 void runtime·ready(G*); |
605 byte* runtime·getenv(int8*); | 742 byte* runtime·getenv(int8*); |
606 int32 runtime·atoi(byte*); | 743 int32 runtime·atoi(byte*); |
607 void» runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void)); | 744 void» runtime·newosproc(M *mp, void *stk); |
608 void» runtime·signalstack(byte*, int32); | 745 void» runtime·mstart(void); |
609 G* runtime·malg(int32); | 746 G* runtime·malg(int32); |
610 void runtime·asminit(void); | 747 void runtime·asminit(void); |
| 748 void runtime·mpreinit(M*); |
611 void runtime·minit(void); | 749 void runtime·minit(void); |
| 750 void runtime·unminit(void); |
| 751 void runtime·signalstack(byte*, int32); |
612 Func* runtime·findfunc(uintptr); | 752 Func* runtime·findfunc(uintptr); |
613 int32 runtime·funcline(Func*, uintptr); | 753 int32 runtime·funcline(Func*, uintptr); |
614 void* runtime·stackalloc(uint32); | 754 void* runtime·stackalloc(uint32); |
615 void runtime·stackfree(void*, uintptr); | 755 void runtime·stackfree(void*, uintptr); |
616 MCache* runtime·allocmcache(void); | 756 MCache* runtime·allocmcache(void); |
617 void runtime·freemcache(MCache*); | 757 void runtime·freemcache(MCache*); |
618 void runtime·mallocinit(void); | 758 void runtime·mallocinit(void); |
619 void runtime·mprofinit(void); | 759 void runtime·mprofinit(void); |
620 bool runtime·ifaceeq_c(Iface, Iface); | 760 bool runtime·ifaceeq_c(Iface, Iface); |
621 bool runtime·efaceeq_c(Eface, Eface); | 761 bool runtime·efaceeq_c(Eface, Eface); |
622 uintptr»runtime·ifacehash(Iface); | 762 uintptr»runtime·ifacehash(Iface, uintptr); |
623 uintptr»runtime·efacehash(Eface); | 763 uintptr»runtime·efacehash(Eface, uintptr); |
624 void* runtime·malloc(uintptr size); | 764 void* runtime·malloc(uintptr size); |
625 void runtime·free(void *v); | 765 void runtime·free(void *v); |
626 bool» runtime·addfinalizer(void*, void(*fn)(void*), int32); | 766 bool» runtime·addfinalizer(void*, FuncVal *fn, uintptr); |
627 void runtime·runpanic(Panic*); | 767 void runtime·runpanic(Panic*); |
628 void* runtime·getcallersp(void*); | 768 void* runtime·getcallersp(void*); |
629 int32 runtime·mcount(void); | 769 int32 runtime·mcount(void); |
630 int32 runtime·gcount(void); | 770 int32 runtime·gcount(void); |
631 void runtime·mcall(void(*)(G*)); | 771 void runtime·mcall(void(*)(G*)); |
632 uint32 runtime·fastrand1(void); | 772 uint32 runtime·fastrand1(void); |
633 | 773 |
| 774 void runtime·setmg(M*, G*); |
| 775 void runtime·newextram(void); |
634 void runtime·exit(int32); | 776 void runtime·exit(int32); |
635 void runtime·breakpoint(void); | 777 void runtime·breakpoint(void); |
636 void runtime·gosched(void); | 778 void runtime·gosched(void); |
637 void runtime·park(void(*)(Lock*), Lock*, int8*); | 779 void runtime·park(void(*)(Lock*), Lock*, int8*); |
638 void runtime·tsleep(int64, int8*); | 780 void runtime·tsleep(int64, int8*); |
639 M* runtime·newm(void); | 781 M* runtime·newm(void); |
640 void runtime·goexit(void); | 782 void runtime·goexit(void); |
641 void runtime·asmcgocall(void (*fn)(void*), void*); | 783 void runtime·asmcgocall(void (*fn)(void*), void*); |
642 void runtime·entersyscall(void); | 784 void runtime·entersyscall(void); |
| 785 void runtime·entersyscallblock(void); |
643 void runtime·exitsyscall(void); | 786 void runtime·exitsyscall(void); |
644 G*» runtime·newproc1(byte*, byte*, int32, int32, void*); | 787 G*» runtime·newproc1(FuncVal*, byte*, int32, int32, void*); |
645 bool runtime·sigsend(int32 sig); | 788 bool runtime·sigsend(int32 sig); |
646 int32 runtime·callers(int32, uintptr*, int32); | 789 int32 runtime·callers(int32, uintptr*, int32); |
647 int32» runtime·gentraceback(byte*, byte*, byte*, G*, int32, uintptr*, int32); | 790 int32» runtime·gentraceback(byte*, byte*, byte*, G*, int32, uintptr*, int32, vo
id (*)(Func*, byte*, byte*, void*), void*); |
648 int64 runtime·nanotime(void); | 791 int64 runtime·nanotime(void); |
649 void runtime·dopanic(int32); | 792 void runtime·dopanic(int32); |
650 void runtime·startpanic(void); | 793 void runtime·startpanic(void); |
651 void runtime·unwindstack(G*, byte*); | 794 void runtime·unwindstack(G*, byte*); |
652 void runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp); | 795 void runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp); |
653 void runtime·resetcpuprofiler(int32); | 796 void runtime·resetcpuprofiler(int32); |
654 void runtime·setcpuprofilerate(void(*)(uintptr*, int32), int32); | 797 void runtime·setcpuprofilerate(void(*)(uintptr*, int32), int32); |
655 void runtime·usleep(uint32); | 798 void runtime·usleep(uint32); |
656 int64 runtime·cputicks(void); | 799 int64 runtime·cputicks(void); |
| 800 int64 runtime·tickspersecond(void); |
| 801 void runtime·blockevent(int64, int32); |
| 802 extern int64 runtime·blockprofilerate; |
| 803 void runtime·addtimer(Timer*); |
| 804 bool runtime·deltimer(Timer*); |
| 805 G* runtime·netpoll(bool); |
| 806 void runtime·netpollinit(void); |
| 807 int32 runtime·netpollopen(uintptr, PollDesc*); |
| 808 int32 runtime·netpollclose(uintptr); |
| 809 void runtime·netpollready(G**, PollDesc*, int32); |
| 810 void runtime·crash(void); |
657 | 811 |
658 #pragma varargck argpos runtime·printf 1 | 812 #pragma varargck argpos runtime·printf 1 |
659 #pragma varargck type "d" int32 | 813 #pragma varargck type "d" int32 |
660 #pragma varargck type "d" uint32 | 814 #pragma varargck type "d" uint32 |
661 #pragma varargck type "D" int64 | 815 #pragma varargck type "D" int64 |
662 #pragma varargck type "D" uint64 | 816 #pragma varargck type "D" uint64 |
663 #pragma varargck type "x" int32 | 817 #pragma varargck type "x" int32 |
664 #pragma varargck type "x" uint32 | 818 #pragma varargck type "x" uint32 |
665 #pragma varargck type "X" int64 | 819 #pragma varargck type "X" int64 |
666 #pragma varargck type "X" uint64 | 820 #pragma varargck type "X" uint64 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 /* | 895 /* |
742 * This is consistent across Linux and BSD. | 896 * This is consistent across Linux and BSD. |
743 * If a new OS is added that is different, move this to | 897 * If a new OS is added that is different, move this to |
744 * $GOOS/$GOARCH/defs.h. | 898 * $GOOS/$GOARCH/defs.h. |
745 */ | 899 */ |
746 #define EACCES 13 | 900 #define EACCES 13 |
747 | 901 |
748 /* | 902 /* |
749 * low level C-called | 903 * low level C-called |
750 */ | 904 */ |
| 905 // for mmap, we only pass the lower 32 bits of file offset to the· |
| 906 // assembly routine; the higher bits (if required), should be provided |
| 907 // by the assembly routine as 0. |
751 uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32); | 908 uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32); |
752 void runtime·munmap(byte*, uintptr); | 909 void runtime·munmap(byte*, uintptr); |
753 void runtime·madvise(byte*, uintptr, int32); | 910 void runtime·madvise(byte*, uintptr, int32); |
754 void runtime·memclr(byte*, uintptr); | 911 void runtime·memclr(byte*, uintptr); |
755 void runtime·setcallerpc(void*, void*); | 912 void runtime·setcallerpc(void*, void*); |
756 void* runtime·getcallerpc(void*); | 913 void* runtime·getcallerpc(void*); |
757 | 914 |
758 /* | 915 /* |
759 * runtime go-called | 916 * runtime go-called |
760 */ | 917 */ |
761 void runtime·printbool(bool); | 918 void runtime·printbool(bool); |
| 919 void runtime·printbyte(int8); |
762 void runtime·printfloat(float64); | 920 void runtime·printfloat(float64); |
763 void runtime·printint(int64); | 921 void runtime·printint(int64); |
764 void runtime·printiface(Iface); | 922 void runtime·printiface(Iface); |
765 void runtime·printeface(Eface); | 923 void runtime·printeface(Eface); |
766 void runtime·printstring(String); | 924 void runtime·printstring(String); |
767 void runtime·printpc(void*); | 925 void runtime·printpc(void*); |
768 void runtime·printpointer(void*); | 926 void runtime·printpointer(void*); |
769 void runtime·printuint(uint64); | 927 void runtime·printuint(uint64); |
770 void runtime·printhex(uint64); | 928 void runtime·printhex(uint64); |
771 void runtime·printslice(Slice); | 929 void runtime·printslice(Slice); |
772 void runtime·printcomplex(Complex128); | 930 void runtime·printcomplex(Complex128); |
773 void» reflect·call(byte*, byte*, uint32); | 931 void» reflect·call(FuncVal*, byte*, uint32); |
774 void runtime·panic(Eface); | 932 void runtime·panic(Eface); |
775 void runtime·panicindex(void); | 933 void runtime·panicindex(void); |
776 void runtime·panicslice(void); | 934 void runtime·panicslice(void); |
777 | 935 |
778 /* | 936 /* |
779 * runtime c-called (but written in Go) | 937 * runtime c-called (but written in Go) |
780 */ | 938 */ |
781 void runtime·printany(Eface); | 939 void runtime·printany(Eface); |
782 void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*
); | 940 void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*
); |
783 void runtime·newErrorString(String, Eface*); | 941 void runtime·newErrorString(String, Eface*); |
(...skipping 20 matching lines...) Expand all Loading... |
804 float64 runtime·frexp(float64 d, int32 *ep); | 962 float64 runtime·frexp(float64 d, int32 *ep); |
805 bool runtime·isInf(float64 f, int32 sign); | 963 bool runtime·isInf(float64 f, int32 sign); |
806 bool runtime·isNaN(float64 f); | 964 bool runtime·isNaN(float64 f); |
807 float64 runtime·ldexp(float64 d, int32 e); | 965 float64 runtime·ldexp(float64 d, int32 e); |
808 float64 runtime·modf(float64 d, float64 *ip); | 966 float64 runtime·modf(float64 d, float64 *ip); |
809 void runtime·semacquire(uint32*); | 967 void runtime·semacquire(uint32*); |
810 void runtime·semrelease(uint32*); | 968 void runtime·semrelease(uint32*); |
811 int32 runtime·gomaxprocsfunc(int32 n); | 969 int32 runtime·gomaxprocsfunc(int32 n); |
812 void runtime·procyield(uint32); | 970 void runtime·procyield(uint32); |
813 void runtime·osyield(void); | 971 void runtime·osyield(void); |
814 void» runtime·LockOSThread(void); | 972 void» runtime·lockOSThread(void); |
815 void» runtime·UnlockOSThread(void); | 973 void» runtime·unlockOSThread(void); |
816 | 974 |
817 void runtime·mapassign(MapType*, Hmap*, byte*, byte*); | 975 void runtime·mapassign(MapType*, Hmap*, byte*, byte*); |
818 void runtime·mapaccess(MapType*, Hmap*, byte*, byte*, bool*); | 976 void runtime·mapaccess(MapType*, Hmap*, byte*, byte*, bool*); |
819 void runtime·mapiternext(struct hash_iter*); | 977 void runtime·mapiternext(struct hash_iter*); |
820 bool runtime·mapiterkey(struct hash_iter*, void*); | 978 bool runtime·mapiterkey(struct hash_iter*, void*); |
821 void runtime·mapiterkeyvalue(struct hash_iter*, void*, void*); | |
822 Hmap* runtime·makemap_c(MapType*, int64); | 979 Hmap* runtime·makemap_c(MapType*, int64); |
823 | 980 |
824 Hchan* runtime·makechan_c(ChanType*, int64); | 981 Hchan* runtime·makechan_c(ChanType*, int64); |
825 void» runtime·chansend(ChanType*, Hchan*, byte*, bool*); | 982 void» runtime·chansend(ChanType*, Hchan*, byte*, bool*, void*); |
826 void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*); | 983 void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*); |
827 int32» runtime·chanlen(Hchan*); | 984 bool» runtime·showframe(Func*, bool); |
828 int32» runtime·chancap(Hchan*); | 985 |
829 bool» runtime·showframe(Func*); | 986 void» runtime·ifaceE2I(InterfaceType*, Eface, Iface*); |
830 | |
831 void» runtime·ifaceE2I(struct InterfaceType*, Eface, Iface*); | |
832 | 987 |
833 uintptr runtime·memlimit(void); | 988 uintptr runtime·memlimit(void); |
834 | 989 |
835 // If appropriate, ask the operating system to control whether this | 990 // If appropriate, ask the operating system to control whether this |
836 // thread should receive profiling signals. This is only necessary on OS X. | 991 // thread should receive profiling signals. This is only necessary on OS X. |
837 // An operating system should not deliver a profiling signal to a | 992 // An operating system should not deliver a profiling signal to a |
838 // thread that is not actually executing (what good is that?), but that's | 993 // thread that is not actually executing (what good is that?), but that's |
839 // what OS X prefers to do. When profiling is turned on, we mask | 994 // what OS X prefers to do. When profiling is turned on, we mask |
840 // away the profiling signal when threads go to sleep, so that OS X | 995 // away the profiling signal when threads go to sleep, so that OS X |
841 // is forced to deliver the signal to a thread that's actually running. | 996 // is forced to deliver the signal to a thread that's actually running. |
842 // This is a no-op on other systems. | 997 // This is a no-op on other systems. |
843 void runtime·setprof(bool); | 998 void runtime·setprof(bool); |
844 | 999 |
845 // float.c | 1000 // float.c |
846 extern float64 runtime·nan; | 1001 extern float64 runtime·nan; |
847 extern float64 runtime·posinf; | 1002 extern float64 runtime·posinf; |
848 extern float64 runtime·neginf; | 1003 extern float64 runtime·neginf; |
849 extern uint64 ·nan; | 1004 extern uint64 ·nan; |
850 extern uint64 ·posinf; | 1005 extern uint64 ·posinf; |
851 extern uint64 ·neginf; | 1006 extern uint64 ·neginf; |
852 #define ISNAN(f) ((f) != (f)) | 1007 #define ISNAN(f) ((f) != (f)) |
853 | 1008 |
854 enum | 1009 enum |
855 { | 1010 { |
856 » UseSpanType = 1, | 1011 » PreciseGC = 1, |
857 }; | 1012 » UseSpanType = (1 && PreciseGC), |
| 1013 }; |
LEFT | RIGHT |