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 | 22 typedef int64 intgo; // Go's int |
23 typedef uint64 uintgo; // Go's uint | 23 typedef uint64 uintgo; // Go's uint |
| 24 typedef uint64 uintreg; |
24 #else | 25 #else |
25 typedef uint32 uintptr; | 26 typedef uint32 uintptr; |
26 typedef int32 intptr; | 27 typedef int32 intptr; |
27 typedef int32 intgo; // Go's int | 28 typedef int32 intgo; // Go's int |
28 typedef uint32 uintgo; // Go's uint | 29 typedef uint32 uintgo; // Go's uint |
| 30 typedef uint32 uintreg; |
| 31 #endif |
| 32 |
| 33 #ifdef _64BITREG |
| 34 //typedef uint64 uintreg; |
| 35 #else |
| 36 //typedef uint32 uintreg; |
29 #endif | 37 #endif |
30 | 38 |
31 /* | 39 /* |
32 * get rid of C types | 40 * get rid of C types |
33 * the / / / forces a syntax error immediately, | 41 * the / / / forces a syntax error immediately, |
34 * which will show "last name: XXunsigned". | 42 * which will show "last name: XXunsigned". |
35 */ | 43 */ |
36 #define unsigned XXunsigned / / / | 44 #define unsigned XXunsigned / / / |
37 #define signed XXsigned / / / | 45 #define signed XXsigned / / / |
38 #define char XXchar / / / | 46 #define char XXchar / / / |
(...skipping 26 matching lines...) Expand all Loading... |
65 typedef struct Itab Itab; | 73 typedef struct Itab Itab; |
66 typedef struct InterfaceType InterfaceType; | 74 typedef struct InterfaceType InterfaceType; |
67 typedef struct Eface Eface; | 75 typedef struct Eface Eface; |
68 typedef struct Type Type; | 76 typedef struct Type Type; |
69 typedef struct PtrType PtrType; | 77 typedef struct PtrType PtrType; |
70 typedef struct ChanType ChanType; | 78 typedef struct ChanType ChanType; |
71 typedef struct MapType MapType; | 79 typedef struct MapType MapType; |
72 typedef struct Defer Defer; | 80 typedef struct Defer Defer; |
73 typedef struct Panic Panic; | 81 typedef struct Panic Panic; |
74 typedef struct Hmap Hmap; | 82 typedef struct Hmap Hmap; |
| 83 typedef struct Hiter Hiter; |
75 typedef struct Hchan Hchan; | 84 typedef struct Hchan Hchan; |
76 typedef struct Complex64 Complex64; | 85 typedef struct Complex64 Complex64; |
77 typedef struct Complex128 Complex128; | 86 typedef struct Complex128 Complex128; |
78 typedef struct LibCall LibCall; | 87 typedef struct LibCall LibCall; |
79 typedef struct SEH SEH; | 88 typedef struct SEH SEH; |
| 89 typedef struct SEHUnwind SEHUnwind; |
80 typedef struct WinCallbackContext WinCallbackContext; | 90 typedef struct WinCallbackContext WinCallbackContext; |
81 typedef struct Timers Timers; | 91 typedef struct Timers Timers; |
82 typedef struct Timer Timer; | 92 typedef struct Timer Timer; |
83 typedef struct GCStats GCStats; | 93 typedef struct GCStats GCStats; |
84 typedef struct LFNode LFNode; | 94 typedef struct LFNode LFNode; |
85 typedef struct ParFor ParFor; | 95 typedef struct ParFor ParFor; |
86 typedef struct ParForThread ParForThread; | 96 typedef struct ParForThread ParForThread; |
87 typedef struct CgoMal CgoMal; | 97 typedef struct CgoMal CgoMal; |
88 typedef struct PollDesc PollDesc; | 98 typedef struct PollDesc PollDesc; |
89 typedef struct DebugVars DebugVars; | 99 typedef struct DebugVars DebugVars; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 byte* array; // actual data | 211 byte* array; // actual data |
202 uintgo len; // number of elements | 212 uintgo len; // number of elements |
203 uintgo cap; // allocated number of elements | 213 uintgo cap; // allocated number of elements |
204 }; | 214 }; |
205 struct Gobuf | 215 struct Gobuf |
206 { | 216 { |
207 // The offsets of sp, pc, and g are known to (hard-coded in) libmach. | 217 // The offsets of sp, pc, and g are known to (hard-coded in) libmach. |
208 uintptr sp; | 218 uintptr sp; |
209 uintptr pc; | 219 uintptr pc; |
210 G* g; | 220 G* g; |
211 uintptr ret; | |
212 void* ctxt; | 221 void* ctxt; |
| 222 uintreg ret; |
213 uintptr lr; | 223 uintptr lr; |
214 }; | 224 }; |
215 struct GCStats | 225 struct GCStats |
216 { | 226 { |
217 // the struct must consist of only uint64's, | 227 // the struct must consist of only uint64's, |
218 // because it is casted to uint64[]. | 228 // because it is casted to uint64[]. |
219 uint64 nhandoff; | 229 uint64 nhandoff; |
220 uint64 nhandoffcnt; | 230 uint64 nhandoffcnt; |
221 uint64 nprocyield; | 231 uint64 nprocyield; |
222 uint64 nosyield; | 232 uint64 nosyield; |
223 uint64 nsleep; | 233 uint64 nsleep; |
224 }; | 234 }; |
225 | 235 |
226 struct LibCall | 236 struct LibCall |
227 { | 237 { |
228 void (*fn)(void*); | 238 void (*fn)(void*); |
229 uintptr n; // number of parameters | 239 uintptr n; // number of parameters |
230 void* args; // parameters | 240 void* args; // parameters |
231 uintptr r1; // return values | 241 uintptr r1; // return values |
232 uintptr r2; | 242 uintptr r2; |
233 uintptr err; // error number | 243 uintptr err; // error number |
234 }; | 244 }; |
| 245 |
235 struct SEH | 246 struct SEH |
236 { | 247 { |
237 void* prev; | 248 void* prev; |
238 void* handler; | 249 void* handler; |
239 }; | 250 }; |
| 251 |
| 252 struct SEHUnwind |
| 253 { |
| 254 SEHUnwind* link; |
| 255 SEH* seh; |
| 256 }; |
| 257 |
240 // describes how to handle callback | 258 // describes how to handle callback |
241 struct WinCallbackContext | 259 struct WinCallbackContext |
242 { | 260 { |
243 void* gobody; // Go function to call | 261 void* gobody; // Go function to call |
244 uintptr argsize; // callback arguments size (in bytes) | 262 uintptr argsize; // callback arguments size (in bytes) |
245 uintptr restorestack; // adjust stack on return by (in bytes) (386 onl
y) | 263 uintptr restorestack; // adjust stack on return by (in bytes) (386 onl
y) |
246 bool cleanstack; | 264 bool cleanstack; |
247 }; | 265 }; |
248 | 266 |
249 struct G | 267 struct G |
250 { | 268 { |
251 // stackguard0 can be set to StackPreempt as opposed to stackguard | 269 // stackguard0 can be set to StackPreempt as opposed to stackguard |
252 uintptr stackguard0; // cannot move - also known to linker, libmach,
runtime/cgo | 270 uintptr stackguard0; // cannot move - also known to linker, libmach,
runtime/cgo |
253 uintptr stackbase; // cannot move - also known to libmach, runtime/
cgo | 271 uintptr stackbase; // cannot move - also known to libmach, runtime/
cgo |
254 uint32 panicwrap; // cannot move - also known to linker | 272 uint32 panicwrap; // cannot move - also known to linker |
255 uint32 selgen; // valid sudog pointer | |
256 Defer* defer; | 273 Defer* defer; |
257 Panic* panic; | 274 Panic* panic; |
258 Gobuf sched; | 275 Gobuf sched; |
259 uintptr syscallstack; // if status==Gsyscall, syscallstack = stackbase
to use during gc | 276 uintptr syscallstack; // if status==Gsyscall, syscallstack = stackbase
to use during gc |
260 uintptr syscallsp; // if status==Gsyscall, syscallsp = sched.sp to
use during gc | 277 uintptr syscallsp; // if status==Gsyscall, syscallsp = sched.sp to
use during gc |
261 uintptr syscallpc; // if status==Gsyscall, syscallpc = sched.pc to
use during gc | 278 uintptr syscallpc; // if status==Gsyscall, syscallpc = sched.pc to
use during gc |
262 uintptr syscallguard; // if status==Gsyscall, syscallguard = stackguar
d to use during gc | 279 uintptr syscallguard; // if status==Gsyscall, syscallguard = stackguar
d to use during gc |
263 uintptr stackguard; // same as stackguard0, but not set to StackPree
mpt | 280 uintptr stackguard; // same as stackguard0, but not set to StackPree
mpt |
264 uintptr stack0; | 281 uintptr stack0; |
265 uintptr stacksize; | 282 uintptr stacksize; |
266 void* param; // passed parameter on wakeup | 283 void* param; // passed parameter on wakeup |
267 int16 status; | 284 int16 status; |
268 int64 goid; | 285 int64 goid; |
269 int64 waitsince; // approx time when the G become blocked | 286 int64 waitsince; // approx time when the G become blocked |
270 int8* waitreason; // if status==Gwaiting | 287 int8* waitreason; // if status==Gwaiting |
271 G* schedlink; | 288 G* schedlink; |
272 bool ispanic; | 289 bool ispanic; |
273 bool issystem; // do not output in stack dump | 290 bool issystem; // do not output in stack dump |
274 bool isbackground; // ignore in deadlock detector | 291 bool isbackground; // ignore in deadlock detector |
275 bool preempt; // preemption signal, duplicates stackguard0 = S
tackPreempt | 292 bool preempt; // preemption signal, duplicates stackguard0 = S
tackPreempt |
| 293 bool paniconfault; // panic (instead of crash) on unexpected fault
address |
276 int8 raceignore; // ignore race detection events | 294 int8 raceignore; // ignore race detection events |
277 M* m; // for debuggers, but offset not hard-coded | 295 M* m; // for debuggers, but offset not hard-coded |
278 M* lockedm; | 296 M* lockedm; |
279 int32 sig; | 297 int32 sig; |
280 int32 writenbuf; | 298 int32 writenbuf; |
281 byte* writebuf; | 299 byte* writebuf; |
282 uintptr sigcode0; | 300 uintptr sigcode0; |
283 uintptr sigcode1; | 301 uintptr sigcode1; |
284 uintptr sigpc; | 302 uintptr sigpc; |
285 uintptr gopc; // pc of go statement that created this goroutin
e | 303 uintptr gopc; // pc of go statement that created this goroutin
e |
286 uintptr racectx; | 304 uintptr racectx; |
287 uintptr end[]; | 305 uintptr end[]; |
288 }; | 306 }; |
| 307 |
| 308 // Define a symbol for windows/386 because that is the only |
| 309 // system with SEH handling, and we end up checking that |
| 310 // repeatedly. |
| 311 #ifdef GOOS_windows |
| 312 #ifdef GOARCH_386 |
| 313 #define GOOSARCH_windows_386 |
| 314 #endif |
| 315 #endif |
| 316 |
289 struct M | 317 struct M |
290 { | 318 { |
291 G* g0; // goroutine with scheduling stack | 319 G* g0; // goroutine with scheduling stack |
292 void* moreargp; // argument pointer for more stack | 320 void* moreargp; // argument pointer for more stack |
293 Gobuf morebuf; // gobuf arg to morestack | 321 Gobuf morebuf; // gobuf arg to morestack |
294 | 322 |
295 // Fields not known to debuggers. | 323 // Fields not known to debuggers. |
296 uint32 moreframesize; // size arguments to morestack | 324 uint32 moreframesize; // size arguments to morestack |
297 » uint32» moreargsize; | 325 » uint32» moreargsize;» // known by amd64 asm to follow moreframesize |
298 » uintptr»cret;» » // return value from C | 326 » uintreg»cret;» » // return value from C |
299 uint64 procid; // for debuggers, but offset not hard-coded | 327 uint64 procid; // for debuggers, but offset not hard-coded |
300 G* gsignal; // signal-handling G | 328 G* gsignal; // signal-handling G |
301 uintptr tls[4]; // thread-local storage (for x86 extern register
) | 329 uintptr tls[4]; // thread-local storage (for x86 extern register
) |
302 void (*mstartfn)(void); | 330 void (*mstartfn)(void); |
303 G* curg; // current running goroutine | 331 G* curg; // current running goroutine |
304 G* caughtsig; // goroutine running during fatal signal | 332 G* caughtsig; // goroutine running during fatal signal |
305 P* p; // attached P for executing Go code (nil if not
executing Go code) | 333 P* p; // attached P for executing Go code (nil if not
executing Go code) |
306 P* nextp; | 334 P* nextp; |
307 int32 id; | 335 int32 id; |
308 int32 mallocing; | 336 int32 mallocing; |
309 int32 throwing; | 337 int32 throwing; |
310 int32 gcing; | 338 int32 gcing; |
311 int32 locks; | 339 int32 locks; |
312 int32 dying; | 340 int32 dying; |
313 int32 profilehz; | 341 int32 profilehz; |
314 int32 helpgc; | 342 int32 helpgc; |
315 » bool» spinning; | 343 » bool» spinning;» // M is out of work and is actively looking for
work |
| 344 » bool» blocked;» // M is blocked on a Note |
316 uint32 fastrand; | 345 uint32 fastrand; |
317 uint64 ncgocall; // number of cgo calls in total | 346 uint64 ncgocall; // number of cgo calls in total |
318 int32 ncgo; // number of cgo calls currently in progress | 347 int32 ncgo; // number of cgo calls currently in progress |
319 CgoMal* cgomal; | 348 CgoMal* cgomal; |
320 Note park; | 349 Note park; |
321 M* alllink; // on allm | 350 M* alllink; // on allm |
322 M* schedlink; | 351 M* schedlink; |
323 uint32 machport; // Return address for Mach IPC (OS X) | 352 uint32 machport; // Return address for Mach IPC (OS X) |
324 MCache* mcache; | 353 MCache* mcache; |
325 int32 stackinuse; | 354 int32 stackinuse; |
326 uint32 stackcachepos; | 355 uint32 stackcachepos; |
327 uint32 stackcachecnt; | 356 uint32 stackcachecnt; |
328 void* stackcache[StackCacheSize]; | 357 void* stackcache[StackCacheSize]; |
329 G* lockedg; | 358 G* lockedg; |
330 uintptr createstack[32];// Stack that created this thread. | 359 uintptr createstack[32];// Stack that created this thread. |
331 uint32 freglo[16]; // D[i] lsb and F[i] | 360 uint32 freglo[16]; // D[i] lsb and F[i] |
332 uint32 freghi[16]; // D[i] msb and F[i+16] | 361 uint32 freghi[16]; // D[i] msb and F[i+16] |
333 uint32 fflag; // floating point compare flags | 362 uint32 fflag; // floating point compare flags |
334 uint32 locked; // tracking for LockOSThread | 363 uint32 locked; // tracking for LockOSThread |
335 M* nextwaitm; // next M waiting for lock | 364 M* nextwaitm; // next M waiting for lock |
336 uintptr waitsema; // semaphore for parking on locks | 365 uintptr waitsema; // semaphore for parking on locks |
337 uint32 waitsemacount; | 366 uint32 waitsemacount; |
338 uint32 waitsemalock; | 367 uint32 waitsemalock; |
339 GCStats gcstats; | 368 GCStats gcstats; |
340 bool needextram; | 369 bool needextram; |
341 bool (*waitunlockf)(G*, void*); | 370 bool (*waitunlockf)(G*, void*); |
342 void* waitlock; | 371 void* waitlock; |
343 | |
344 uintptr settype_buf[1024]; | |
345 uintptr settype_bufsize; | |
346 | |
347 #ifdef GOOS_windows | 372 #ifdef GOOS_windows |
348 void* thread; // thread handle | 373 void* thread; // thread handle |
349 // these are here because they are too large to be on the stack | 374 // these are here because they are too large to be on the stack |
350 // of low-level NOSPLIT functions. | 375 // of low-level NOSPLIT functions. |
351 LibCall libcall; | 376 LibCall libcall; |
| 377 uintptr libcallpc; // for cpu profiler |
| 378 uintptr libcallsp; |
| 379 G* libcallg; |
352 #endif | 380 #endif |
353 #ifdef GOOS_solaris | 381 #ifdef GOOS_solaris |
354 int32* perrno; // pointer to TLS errno | 382 int32* perrno; // pointer to TLS errno |
355 // these are here because they are too large to be on the stack | 383 // these are here because they are too large to be on the stack |
356 // of low-level NOSPLIT functions. | 384 // of low-level NOSPLIT functions. |
357 LibCall libcall; | 385 LibCall libcall; |
358 struct { | 386 struct { |
359 int64 tv_sec; | 387 int64 tv_sec; |
360 int64 tv_nsec; | 388 int64 tv_nsec; |
361 } ts; | 389 } ts; |
362 struct { | 390 struct { |
363 uintptr v[6]; | 391 uintptr v[6]; |
364 } scratch; | 392 } scratch; |
365 #endif | 393 #endif |
366 #ifdef GOOS_plan9 | 394 #ifdef GOOS_plan9 |
367 int8* notesig; | 395 int8* notesig; |
368 byte* errstr; | 396 byte* errstr; |
369 #endif | 397 #endif |
370 SEH* seh; | 398 SEH* seh; |
| 399 SEHUnwind* sehunwind; |
371 uintptr end[]; | 400 uintptr end[]; |
372 }; | 401 }; |
373 | 402 |
374 struct P | 403 struct P |
375 { | 404 { |
376 Lock; | 405 Lock; |
377 | 406 |
378 int32 id; | 407 int32 id; |
379 uint32 status; // one of Pidle/Prunning/... | 408 uint32 status; // one of Pidle/Prunning/... |
380 P* link; | 409 P* link; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 struct Itab | 495 struct Itab |
467 { | 496 { |
468 InterfaceType* inter; | 497 InterfaceType* inter; |
469 Type* type; | 498 Type* type; |
470 Itab* link; | 499 Itab* link; |
471 int32 bad; | 500 int32 bad; |
472 int32 unused; | 501 int32 unused; |
473 void (*fun[])(void); | 502 void (*fun[])(void); |
474 }; | 503 }; |
475 | 504 |
| 505 #ifdef GOOS_nacl |
| 506 enum { |
| 507 NaCl = 1, |
| 508 }; |
| 509 #else |
| 510 enum { |
| 511 NaCl = 0, |
| 512 }; |
| 513 #endif |
| 514 |
476 #ifdef GOOS_windows | 515 #ifdef GOOS_windows |
477 enum { | 516 enum { |
478 Windows = 1 | 517 Windows = 1 |
479 }; | 518 }; |
480 #else | 519 #else |
481 enum { | 520 enum { |
482 Windows = 0 | 521 Windows = 0 |
483 }; | 522 }; |
484 #endif | 523 #endif |
485 #ifdef GOOS_solaris | 524 #ifdef GOOS_solaris |
(...skipping 13 matching lines...) Expand all Loading... |
499 bool sleeping; | 538 bool sleeping; |
500 bool rescheduling; | 539 bool rescheduling; |
501 Note waitnote; | 540 Note waitnote; |
502 Timer **t; | 541 Timer **t; |
503 int32 len; | 542 int32 len; |
504 int32 cap; | 543 int32 cap; |
505 }; | 544 }; |
506 | 545 |
507 // Package time knows the layout of this structure. | 546 // Package time knows the layout of this structure. |
508 // If this struct changes, adjust ../time/sleep.go:/runtimeTimer. | 547 // If this struct changes, adjust ../time/sleep.go:/runtimeTimer. |
| 548 // For GOOS=nacl, package syscall knows the layout of this structure. |
| 549 // If this struct changes, adjust ../syscall/net_nacl.go:/runtimeTimer. |
509 struct Timer | 550 struct Timer |
510 { | 551 { |
511 int32 i; // heap index | 552 int32 i; // heap index |
512 | 553 |
513 // Timer wakes up at when, and then at when+period, ... (period > 0 only
) | 554 // Timer wakes up at when, and then at when+period, ... (period > 0 only
) |
514 // each time calling f(now, arg) in the timer goroutine, so f must be | 555 // each time calling f(now, arg) in the timer goroutine, so f must be |
515 // a well-behaved function and not block. | 556 // a well-behaved function and not block. |
516 int64 when; | 557 int64 when; |
517 int64 period; | 558 int64 period; |
518 FuncVal *fv; | 559 FuncVal *fv; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 struct DebugVars | 601 struct DebugVars |
561 { | 602 { |
562 int32 allocfreetrace; | 603 int32 allocfreetrace; |
563 int32 efence; | 604 int32 efence; |
564 int32 gctrace; | 605 int32 gctrace; |
565 int32 scheddetail; | 606 int32 scheddetail; |
566 int32 schedtrace; | 607 int32 schedtrace; |
567 }; | 608 }; |
568 | 609 |
569 extern bool runtime·precisestack; | 610 extern bool runtime·precisestack; |
| 611 extern bool runtime·copystack; |
570 | 612 |
571 /* | 613 /* |
572 * defined macros | 614 * defined macros |
573 * you need super-gopher-guru privilege | 615 * you need super-gopher-guru privilege |
574 * to add this list. | 616 * to add this list. |
575 */ | 617 */ |
576 #define nelem(x) (sizeof(x)/sizeof((x)[0])) | 618 #define nelem(x) (sizeof(x)/sizeof((x)[0])) |
577 #define nil ((void*)0) | 619 #define nil ((void*)0) |
578 #define offsetof(s,m) (uint32)(&(((s*)0)->m)) | 620 #define offsetof(s,m) (uint32)(&(((s*)0)->m)) |
579 #define»ROUND(x, n)» (((x)+(n)-1)&~((n)-1)) /* all-caps to mark as macro: it
evaluates n twice */ | 621 #define»ROUND(x, n)» (((x)+(n)-1)&~(uintptr)((n)-1)) /* all-caps to mark as m
acro: it evaluates n twice */ |
580 | 622 |
581 /* | 623 /* |
582 * known to compiler | 624 * known to compiler |
583 */ | 625 */ |
584 enum { | 626 enum { |
585 » Structrnd = sizeof(uintptr) | 627 » Structrnd = sizeof(uintreg), |
586 }; | 628 }; |
587 | 629 |
588 /* | 630 /* |
589 * type algorithms - known to compiler | 631 * type algorithms - known to compiler |
590 */ | 632 */ |
591 enum | 633 enum |
592 { | 634 { |
593 AMEM, | 635 AMEM, |
594 AMEM0, | 636 AMEM0, |
595 AMEM8, | 637 AMEM8, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 Func* fn; // function being run | 745 Func* fn; // function being run |
704 uintptr pc; // program counter within fn | 746 uintptr pc; // program counter within fn |
705 uintptr lr; // program counter at caller aka link register | 747 uintptr lr; // program counter at caller aka link register |
706 uintptr sp; // stack pointer at pc | 748 uintptr sp; // stack pointer at pc |
707 uintptr fp; // stack pointer at caller aka frame pointer | 749 uintptr fp; // stack pointer at caller aka frame pointer |
708 byte* varp; // top of local variables | 750 byte* varp; // top of local variables |
709 byte* argp; // pointer to function arguments | 751 byte* argp; // pointer to function arguments |
710 uintptr arglen; // number of bytes at argp | 752 uintptr arglen; // number of bytes at argp |
711 }; | 753 }; |
712 | 754 |
713 int32» runtime·gentraceback(uintptr, uintptr, uintptr, G*, int32, uintptr*, int
32, void(*)(Stkframe*, void*), void*, bool); | 755 int32» runtime·gentraceback(uintptr, uintptr, uintptr, G*, int32, uintptr*, int
32, bool(*)(Stkframe*, void*), void*, bool); |
714 void runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G* gp); | 756 void runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G* gp); |
715 void runtime·tracebackothers(G*); | 757 void runtime·tracebackothers(G*); |
716 bool runtime·haszeroargs(uintptr pc); | 758 bool runtime·haszeroargs(uintptr pc); |
717 bool runtime·topofstack(Func*); | 759 bool runtime·topofstack(Func*); |
718 enum | 760 enum |
719 { | 761 { |
720 // The maximum number of frames we print for a traceback | 762 // The maximum number of frames we print for a traceback |
721 TracebackMaxFrames = 100, | 763 TracebackMaxFrames = 100, |
722 }; | 764 }; |
723 | 765 |
(...skipping 25 matching lines...) Expand all Loading... |
749 * common functions and data | 791 * common functions and data |
750 */ | 792 */ |
751 int32 runtime·strcmp(byte*, byte*); | 793 int32 runtime·strcmp(byte*, byte*); |
752 byte* runtime·strstr(byte*, byte*); | 794 byte* runtime·strstr(byte*, byte*); |
753 intgo runtime·findnull(byte*); | 795 intgo runtime·findnull(byte*); |
754 intgo runtime·findnullw(uint16*); | 796 intgo runtime·findnullw(uint16*); |
755 void runtime·dump(byte*, int32); | 797 void runtime·dump(byte*, int32); |
756 int32 runtime·runetochar(byte*, int32); | 798 int32 runtime·runetochar(byte*, int32); |
757 int32 runtime·charntorune(int32*, uint8*, int32); | 799 int32 runtime·charntorune(int32*, uint8*, int32); |
758 | 800 |
759 /* | 801 |
760 * very low level c-called | 802 /* |
761 */ | 803 * This macro is used when writing C functions |
| 804 * called as if they were Go functions. |
| 805 * Passed the address of a result before a return statement, |
| 806 * it makes sure the result has been flushed to memory |
| 807 * before the return. |
| 808 * |
| 809 * It is difficult to write such functions portably, because |
| 810 * of the varying requirements on the alignment of the |
| 811 * first output value. Almost all code should write such |
| 812 * functions in .goc files, where goc2c (part of cmd/dist) |
| 813 * can arrange the correct alignment for the target system. |
| 814 * Goc2c also takes care of conveying to the garbage collector |
| 815 * which parts of the argument list are inputs vs outputs. |
| 816 * |
| 817 * Therefore, do NOT use this macro if at all possible. |
| 818 */· |
762 #define FLUSH(x) USED(x) | 819 #define FLUSH(x) USED(x) |
| 820 |
| 821 /* |
| 822 * GoOutput is a type with the same alignment requirements as the |
| 823 * initial output argument from a Go function. Only for use in cases |
| 824 * where using goc2c is not possible. See comment on FLUSH above. |
| 825 */ |
| 826 typedef uint64 GoOutput; |
763 | 827 |
764 void runtime·gogo(Gobuf*); | 828 void runtime·gogo(Gobuf*); |
765 void runtime·gostartcall(Gobuf*, void(*)(void), void*); | 829 void runtime·gostartcall(Gobuf*, void(*)(void), void*); |
766 void runtime·gostartcallfn(Gobuf*, FuncVal*); | 830 void runtime·gostartcallfn(Gobuf*, FuncVal*); |
767 void runtime·gosave(Gobuf*); | 831 void runtime·gosave(Gobuf*); |
768 void runtime·lessstack(void); | 832 void runtime·lessstack(void); |
769 void runtime·goargs(void); | 833 void runtime·goargs(void); |
770 void runtime·goenvs(void); | 834 void runtime·goenvs(void); |
771 void runtime·goenvs_unix(void); | 835 void runtime·goenvs_unix(void); |
772 void* runtime·getu(void); | 836 void* runtime·getu(void); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 void runtime·signalstack(byte*, int32); | 873 void runtime·signalstack(byte*, int32); |
810 void runtime·symtabinit(void); | 874 void runtime·symtabinit(void); |
811 Func* runtime·findfunc(uintptr); | 875 Func* runtime·findfunc(uintptr); |
812 int32 runtime·funcline(Func*, uintptr, String*); | 876 int32 runtime·funcline(Func*, uintptr, String*); |
813 int32 runtime·funcarglen(Func*, uintptr); | 877 int32 runtime·funcarglen(Func*, uintptr); |
814 int32 runtime·funcspdelta(Func*, uintptr); | 878 int32 runtime·funcspdelta(Func*, uintptr); |
815 int8* runtime·funcname(Func*); | 879 int8* runtime·funcname(Func*); |
816 int32 runtime·pcdatavalue(Func*, int32, uintptr); | 880 int32 runtime·pcdatavalue(Func*, int32, uintptr); |
817 void* runtime·stackalloc(uint32); | 881 void* runtime·stackalloc(uint32); |
818 void runtime·stackfree(void*, uintptr); | 882 void runtime·stackfree(void*, uintptr); |
| 883 void runtime·shrinkstack(G*); |
819 MCache* runtime·allocmcache(void); | 884 MCache* runtime·allocmcache(void); |
820 void runtime·freemcache(MCache*); | 885 void runtime·freemcache(MCache*); |
821 void runtime·mallocinit(void); | 886 void runtime·mallocinit(void); |
822 bool runtime·ifaceeq_c(Iface, Iface); | 887 bool runtime·ifaceeq_c(Iface, Iface); |
823 bool runtime·efaceeq_c(Eface, Eface); | 888 bool runtime·efaceeq_c(Eface, Eface); |
824 uintptr runtime·ifacehash(Iface, uintptr); | 889 uintptr runtime·ifacehash(Iface, uintptr); |
825 uintptr runtime·efacehash(Eface, uintptr); | 890 uintptr runtime·efacehash(Eface, uintptr); |
826 void* runtime·malloc(uintptr size); | 891 void* runtime·malloc(uintptr size); |
827 void runtime·free(void *v); | 892 void runtime·free(void *v); |
828 void runtime·runpanic(Panic*); | 893 void runtime·runpanic(Panic*); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 void runtime·blockevent(int64, int32); | 950 void runtime·blockevent(int64, int32); |
886 extern int64 runtime·blockprofilerate; | 951 extern int64 runtime·blockprofilerate; |
887 void runtime·addtimer(Timer*); | 952 void runtime·addtimer(Timer*); |
888 bool runtime·deltimer(Timer*); | 953 bool runtime·deltimer(Timer*); |
889 G* runtime·netpoll(bool); | 954 G* runtime·netpoll(bool); |
890 void runtime·netpollinit(void); | 955 void runtime·netpollinit(void); |
891 int32 runtime·netpollopen(uintptr, PollDesc*); | 956 int32 runtime·netpollopen(uintptr, PollDesc*); |
892 int32 runtime·netpollclose(uintptr); | 957 int32 runtime·netpollclose(uintptr); |
893 void runtime·netpollready(G**, PollDesc*, int32); | 958 void runtime·netpollready(G**, PollDesc*, int32); |
894 uintptr runtime·netpollfd(PollDesc*); | 959 uintptr runtime·netpollfd(PollDesc*); |
895 void» runtime·netpollarmread(uintptr fd); | 960 void» runtime·netpollarm(PollDesc*, int32); |
896 void» runtime·netpollarmwrite(uintptr fd); | 961 void**» runtime·netpolluser(PollDesc*); |
897 void runtime·crash(void); | 962 void runtime·crash(void); |
898 void runtime·parsedebugvars(void); | 963 void runtime·parsedebugvars(void); |
899 void _rt0_go(void); | 964 void _rt0_go(void); |
900 void* runtime·funcdata(Func*, int32); | 965 void* runtime·funcdata(Func*, int32); |
| 966 int32 runtime·setmaxthreads(int32); |
| 967 G* runtime·timejump(void); |
| 968 |
| 969 // On Windows 386, we have functions for saving and restoring |
| 970 // the SEH values; elsewhere #define them away. |
| 971 #ifdef GOOSARCH_windows_386 |
| 972 SEH* runtime·getseh(void); |
| 973 void runtime·setseh(SEH*); |
| 974 #else |
| 975 #define runtime·getseh() nil |
| 976 #define runtime·setseh(x) do{}while(0) |
| 977 #endif |
901 | 978 |
902 #pragma varargck argpos runtime·printf 1 | 979 #pragma varargck argpos runtime·printf 1 |
903 #pragma varargck type "c" int32 | 980 #pragma varargck type "c" int32 |
904 #pragma varargck type "d" int32 | 981 #pragma varargck type "d" int32 |
905 #pragma varargck type "d" uint32 | 982 #pragma varargck type "d" uint32 |
906 #pragma varargck type "D" int64 | 983 #pragma varargck type "D" int64 |
907 #pragma varargck type "D" uint64 | 984 #pragma varargck type "D" uint64 |
908 #pragma varargck type "x" int32 | 985 #pragma varargck type "x" int32 |
909 #pragma varargck type "x" uint32 | 986 #pragma varargck type "x" uint32 |
910 #pragma varargck type "X" int64 | 987 #pragma varargck type "X" int64 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 * Parallel for over [0, n). | 1056 * Parallel for over [0, n). |
980 * body() is executed for each iteration. | 1057 * body() is executed for each iteration. |
981 * nthr - total number of worker threads. | 1058 * nthr - total number of worker threads. |
982 * ctx - arbitrary user context. | 1059 * ctx - arbitrary user context. |
983 * if wait=true, threads return from parfor() when all work is done; | 1060 * if wait=true, threads return from parfor() when all work is done; |
984 * otherwise, threads can return while other threads are still finishing process
ing. | 1061 * otherwise, threads can return while other threads are still finishing process
ing. |
985 */ | 1062 */ |
986 ParFor* runtime·parforalloc(uint32 nthrmax); | 1063 ParFor* runtime·parforalloc(uint32 nthrmax); |
987 void runtime·parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool
wait, void (*body)(ParFor*, uint32)); | 1064 void runtime·parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool
wait, void (*body)(ParFor*, uint32)); |
988 void runtime·parfordo(ParFor *desc); | 1065 void runtime·parfordo(ParFor *desc); |
989 | 1066 void» runtime·parforiters(ParFor*, uintptr, uintptr*, uintptr*); |
990 /* | |
991 * This is consistent across Linux and BSD. | |
992 * If a new OS is added that is different, move this to | |
993 * $GOOS/$GOARCH/defs.h. | |
994 */ | |
995 #define EACCES» » 13 | |
996 | 1067 |
997 /* | 1068 /* |
998 * low level C-called | 1069 * low level C-called |
999 */ | 1070 */ |
1000 // for mmap, we only pass the lower 32 bits of file offset to the· | 1071 // for mmap, we only pass the lower 32 bits of file offset to the· |
1001 // assembly routine; the higher bits (if required), should be provided | 1072 // assembly routine; the higher bits (if required), should be provided |
1002 // by the assembly routine as 0. | 1073 // by the assembly routine as 0. |
1003 uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32); | 1074 uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32); |
1004 void runtime·munmap(byte*, uintptr); | 1075 void runtime·munmap(byte*, uintptr); |
1005 void runtime·madvise(byte*, uintptr, int32); | 1076 void runtime·madvise(byte*, uintptr, int32); |
(...skipping 15 matching lines...) Expand all Loading... |
1021 void runtime·printpointer(void*); | 1092 void runtime·printpointer(void*); |
1022 void runtime·printuint(uint64); | 1093 void runtime·printuint(uint64); |
1023 void runtime·printhex(uint64); | 1094 void runtime·printhex(uint64); |
1024 void runtime·printslice(Slice); | 1095 void runtime·printslice(Slice); |
1025 void runtime·printcomplex(Complex128); | 1096 void runtime·printcomplex(Complex128); |
1026 void runtime·newstackcall(FuncVal*, byte*, uint32); | 1097 void runtime·newstackcall(FuncVal*, byte*, uint32); |
1027 void reflect·call(FuncVal*, byte*, uint32); | 1098 void reflect·call(FuncVal*, byte*, uint32); |
1028 void runtime·panic(Eface); | 1099 void runtime·panic(Eface); |
1029 void runtime·panicindex(void); | 1100 void runtime·panicindex(void); |
1030 void runtime·panicslice(void); | 1101 void runtime·panicslice(void); |
| 1102 void runtime·panicdivide(void); |
1031 | 1103 |
1032 /* | 1104 /* |
1033 * runtime c-called (but written in Go) | 1105 * runtime c-called (but written in Go) |
1034 */ | 1106 */ |
1035 void runtime·printany(Eface); | 1107 void runtime·printany(Eface); |
1036 void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*
); | 1108 void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*
); |
1037 void runtime·newErrorString(String, Eface*); | 1109 void runtime·newErrorString(String, Eface*); |
1038 void runtime·newErrorCString(int8*, Eface*); | 1110 void runtime·newErrorCString(int8*, Eface*); |
1039 void runtime·fadd64c(uint64, uint64, uint64*); | 1111 void runtime·fadd64c(uint64, uint64, uint64*); |
1040 void runtime·fsub64c(uint64, uint64, uint64*); | 1112 void runtime·fsub64c(uint64, uint64, uint64*); |
(...skipping 20 matching lines...) Expand all Loading... |
1061 bool runtime·isNaN(float64 f); | 1133 bool runtime·isNaN(float64 f); |
1062 float64 runtime·ldexp(float64 d, int32 e); | 1134 float64 runtime·ldexp(float64 d, int32 e); |
1063 float64 runtime·modf(float64 d, float64 *ip); | 1135 float64 runtime·modf(float64 d, float64 *ip); |
1064 void runtime·semacquire(uint32*, bool); | 1136 void runtime·semacquire(uint32*, bool); |
1065 void runtime·semrelease(uint32*); | 1137 void runtime·semrelease(uint32*); |
1066 int32 runtime·gomaxprocsfunc(int32 n); | 1138 int32 runtime·gomaxprocsfunc(int32 n); |
1067 void runtime·procyield(uint32); | 1139 void runtime·procyield(uint32); |
1068 void runtime·osyield(void); | 1140 void runtime·osyield(void); |
1069 void runtime·lockOSThread(void); | 1141 void runtime·lockOSThread(void); |
1070 void runtime·unlockOSThread(void); | 1142 void runtime·unlockOSThread(void); |
1071 | 1143 bool» runtime·lockedOSThread(void); |
1072 Hchan*» runtime·makechan_c(ChanType*, int64); | 1144 |
1073 void» runtime·chansend(ChanType*, Hchan*, byte*, bool*, void*); | |
1074 void» runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*); | |
1075 bool runtime·showframe(Func*, G*); | 1145 bool runtime·showframe(Func*, G*); |
1076 void runtime·printcreatedby(G*); | 1146 void runtime·printcreatedby(G*); |
1077 | 1147 |
1078 void runtime·ifaceE2I(InterfaceType*, Eface, Iface*); | 1148 void runtime·ifaceE2I(InterfaceType*, Eface, Iface*); |
1079 bool runtime·ifaceE2I2(InterfaceType*, Eface, Iface*); | 1149 bool runtime·ifaceE2I2(InterfaceType*, Eface, Iface*); |
1080 uintptr runtime·memlimit(void); | 1150 uintptr runtime·memlimit(void); |
1081 | 1151 |
1082 // float.c | 1152 // float.c |
1083 extern float64 runtime·nan; | 1153 extern float64 runtime·nan; |
1084 extern float64 runtime·posinf; | 1154 extern float64 runtime·posinf; |
1085 extern float64 runtime·neginf; | 1155 extern float64 runtime·neginf; |
1086 extern uint64 ·nan; | 1156 extern uint64 ·nan; |
1087 extern uint64 ·posinf; | 1157 extern uint64 ·posinf; |
1088 extern uint64 ·neginf; | 1158 extern uint64 ·neginf; |
1089 #define ISNAN(f) ((f) != (f)) | 1159 #define ISNAN(f) ((f) != (f)) |
1090 | 1160 |
1091 enum | 1161 enum |
1092 { | 1162 { |
1093 UseSpanType = 1, | 1163 UseSpanType = 1, |
1094 }; | 1164 }; |
LEFT | RIGHT |