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 / / / |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 Gsyscall, | 115 Gsyscall, |
112 Gwaiting, | 116 Gwaiting, |
113 Gmoribund, | 117 Gmoribund, |
114 Gdead, | 118 Gdead, |
115 }; | 119 }; |
116 enum | 120 enum |
117 { | 121 { |
118 true = 1, | 122 true = 1, |
119 false = 0, | 123 false = 0, |
120 }; | 124 }; |
| 125 enum |
| 126 { |
| 127 PtrSize = sizeof(void*), |
| 128 }; |
121 | 129 |
122 /* | 130 /* |
123 * structures | 131 * structures |
124 */ | 132 */ |
125 union Lock | 133 union Lock |
126 { | 134 { |
127 uint32 key; // futex-based impl | 135 uint32 key; // futex-based impl |
128 M* waitm; // linked list of waiting M's (sema-based impl) | 136 M* waitm; // linked list of waiting M's (sema-based impl) |
129 }; | 137 }; |
130 union Note | 138 union Note |
131 { | 139 { |
132 uint32 key; // futex-based impl | 140 uint32 key; // futex-based impl |
133 M* waitm; // waiting M (sema-based impl) | 141 M* waitm; // waiting M (sema-based impl) |
134 }; | 142 }; |
135 struct String | 143 struct String |
136 { | 144 { |
137 byte* str; | 145 byte* str; |
138 » int32» len; | 146 » intgo» len; |
139 }; | 147 }; |
140 struct Iface | 148 struct Iface |
141 { | 149 { |
142 Itab* tab; | 150 Itab* tab; |
143 void* data; | 151 void* data; |
144 }; | 152 }; |
145 struct Eface | 153 struct Eface |
146 { | 154 { |
147 Type* type; | 155 Type* type; |
148 void* data; | 156 void* data; |
149 }; | 157 }; |
150 struct Complex64 | 158 struct Complex64 |
151 { | 159 { |
152 float32 real; | 160 float32 real; |
153 float32 imag; | 161 float32 imag; |
154 }; | 162 }; |
155 struct Complex128 | 163 struct Complex128 |
156 { | 164 { |
157 float64 real; | 165 float64 real; |
158 float64 imag; | 166 float64 imag; |
159 }; | 167 }; |
160 | 168 |
161 struct Slice | 169 struct Slice |
162 { // must not move anything | 170 { // must not move anything |
163 byte* array; // actual data | 171 byte* array; // actual data |
164 » uint32» len;» » // number of elements | 172 » uintgo» len;» » // number of elements |
165 » uint32» cap;» » // allocated number of elements | 173 » uintgo» cap;» » // allocated number of elements |
166 }; | 174 }; |
167 struct Gobuf | 175 struct Gobuf |
168 { | 176 { |
169 // The offsets of these fields are known to (hard-coded in) libmach. | 177 // The offsets of these fields are known to (hard-coded in) libmach. |
170 uintptr sp; | 178 uintptr sp; |
171 byte* pc; | 179 byte* pc; |
172 G* g; | 180 G* g; |
173 }; | 181 }; |
174 struct GCStats | 182 struct GCStats |
175 { | 183 { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 uintptr createstack[32]; // Stack that created this thread. | 261 uintptr createstack[32]; // Stack that created this thread. |
254 uint32 freglo[16]; // D[i] lsb and F[i] | 262 uint32 freglo[16]; // D[i] lsb and F[i] |
255 uint32 freghi[16]; // D[i] msb and F[i+16] | 263 uint32 freghi[16]; // D[i] msb and F[i+16] |
256 uint32 fflag; // floating point compare flags | 264 uint32 fflag; // floating point compare flags |
257 M* nextwaitm; // next M waiting for lock | 265 M* nextwaitm; // next M waiting for lock |
258 uintptr waitsema; // semaphore for parking on locks | 266 uintptr waitsema; // semaphore for parking on locks |
259 uint32 waitsemacount; | 267 uint32 waitsemacount; |
260 uint32 waitsemalock; | 268 uint32 waitsemalock; |
261 GCStats gcstats; | 269 GCStats gcstats; |
262 | 270 |
| 271 uintptr settype_buf[1024]; |
| 272 uintptr settype_bufsize; |
| 273 |
263 #ifdef GOOS_windows | 274 #ifdef GOOS_windows |
264 void* thread; // thread handle | 275 void* thread; // thread handle |
265 #endif | 276 #endif |
266 SEH* seh; | 277 SEH* seh; |
267 uintptr end[]; | 278 uintptr end[]; |
268 }; | 279 }; |
269 | 280 |
270 struct Stktop | 281 struct Stktop |
271 { | 282 { |
272 // The offsets of these fields are known to (hard-coded in) libmach. | 283 // The offsets of these fields are known to (hard-coded in) libmach. |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 G* runtime·allg; | 518 G* runtime·allg; |
508 G* runtime·lastg; | 519 G* runtime·lastg; |
509 M* runtime·allm; | 520 M* runtime·allm; |
510 extern int32 runtime·gomaxprocs; | 521 extern int32 runtime·gomaxprocs; |
511 extern bool runtime·singleproc; | 522 extern bool runtime·singleproc; |
512 extern uint32 runtime·panicking; | 523 extern uint32 runtime·panicking; |
513 extern int32 runtime·gcwaiting; // gc is waiting to run | 524 extern int32 runtime·gcwaiting; // gc is waiting to run |
514 int8* runtime·goos; | 525 int8* runtime·goos; |
515 int32 runtime·ncpu; | 526 int32 runtime·ncpu; |
516 extern bool runtime·iscgo; | 527 extern bool runtime·iscgo; |
| 528 extern void (*runtime·sysargs)(int32, uint8**); |
| 529 extern uint32 runtime·maxstring; |
517 | 530 |
518 /* | 531 /* |
519 * common functions and data | 532 * common functions and data |
520 */ | 533 */ |
521 int32 runtime·strcmp(byte*, byte*); | 534 int32 runtime·strcmp(byte*, byte*); |
522 byte* runtime·strstr(byte*, byte*); | 535 byte* runtime·strstr(byte*, byte*); |
523 int32 runtime·findnull(byte*); | 536 int32 runtime·findnull(byte*); |
524 int32 runtime·findnullw(uint16*); | 537 int32 runtime·findnullw(uint16*); |
525 void runtime·dump(byte*, int32); | 538 void runtime·dump(byte*, int32); |
526 int32 runtime·runetochar(byte*, int32); | 539 int32 runtime·runetochar(byte*, int32); |
(...skipping 15 matching lines...) Expand all Loading... |
542 void runtime·throw(int8*); | 555 void runtime·throw(int8*); |
543 void runtime·panicstring(int8*); | 556 void runtime·panicstring(int8*); |
544 void runtime·prints(int8*); | 557 void runtime·prints(int8*); |
545 void runtime·printf(int8*, ...); | 558 void runtime·printf(int8*, ...); |
546 byte* runtime·mchr(byte*, byte, byte*); | 559 byte* runtime·mchr(byte*, byte, byte*); |
547 int32 runtime·mcmp(byte*, byte*, uint32); | 560 int32 runtime·mcmp(byte*, byte*, uint32); |
548 void runtime·memmove(void*, void*, uint32); | 561 void runtime·memmove(void*, void*, uint32); |
549 void* runtime·mal(uintptr); | 562 void* runtime·mal(uintptr); |
550 String runtime·catstring(String, String); | 563 String runtime·catstring(String, String); |
551 String runtime·gostring(byte*); | 564 String runtime·gostring(byte*); |
552 String runtime·gostringn(byte*, int32); | 565 String runtime·gostringn(byte*, intgo); |
553 Slice» runtime·gobytes(byte*, int32); | 566 Slice» runtime·gobytes(byte*, intgo); |
554 String runtime·gostringnocopy(byte*); | 567 String runtime·gostringnocopy(byte*); |
555 String runtime·gostringw(uint16*); | 568 String runtime·gostringw(uint16*); |
556 void runtime·initsig(void); | 569 void runtime·initsig(void); |
557 void runtime·sigenable(uint32 sig); | 570 void runtime·sigenable(uint32 sig); |
558 int32 runtime·gotraceback(void); | 571 int32 runtime·gotraceback(void); |
559 void runtime·goroutineheader(G*); | 572 void runtime·goroutineheader(G*); |
560 void runtime·traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp); | 573 void runtime·traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp); |
561 void runtime·tracebackothers(G*); | 574 void runtime·tracebackothers(G*); |
562 int32 runtime·write(int32, void*, int32); | 575 int32 runtime·write(int32, void*, int32); |
563 int32 runtime·mincore(void*, uintptr, byte*); | 576 int32 runtime·mincore(void*, uintptr, byte*); |
(...skipping 27 matching lines...) Expand all Loading... |
591 void runtime·stackfree(void*, uintptr); | 604 void runtime·stackfree(void*, uintptr); |
592 MCache* runtime·allocmcache(void); | 605 MCache* runtime·allocmcache(void); |
593 void runtime·freemcache(MCache*); | 606 void runtime·freemcache(MCache*); |
594 void runtime·mallocinit(void); | 607 void runtime·mallocinit(void); |
595 bool runtime·ifaceeq_c(Iface, Iface); | 608 bool runtime·ifaceeq_c(Iface, Iface); |
596 bool runtime·efaceeq_c(Eface, Eface); | 609 bool runtime·efaceeq_c(Eface, Eface); |
597 uintptr runtime·ifacehash(Iface); | 610 uintptr runtime·ifacehash(Iface); |
598 uintptr runtime·efacehash(Eface); | 611 uintptr runtime·efacehash(Eface); |
599 void* runtime·malloc(uintptr size); | 612 void* runtime·malloc(uintptr size); |
600 void runtime·free(void *v); | 613 void runtime·free(void *v); |
601 bool» runtime·addfinalizer(void*, void(*fn)(void*), int32); | 614 bool» runtime·addfinalizer(void*, void(*fn)(void*), uintptr); |
602 void runtime·runpanic(Panic*); | 615 void runtime·runpanic(Panic*); |
603 void* runtime·getcallersp(void*); | 616 void* runtime·getcallersp(void*); |
604 int32 runtime·mcount(void); | 617 int32 runtime·mcount(void); |
605 int32 runtime·gcount(void); | 618 int32 runtime·gcount(void); |
606 void runtime·mcall(void(*)(G*)); | 619 void runtime·mcall(void(*)(G*)); |
607 uint32 runtime·fastrand1(void); | 620 uint32 runtime·fastrand1(void); |
608 | 621 |
609 void runtime·exit(int32); | 622 void runtime·exit(int32); |
610 void runtime·breakpoint(void); | 623 void runtime·breakpoint(void); |
611 void runtime·gosched(void); | 624 void runtime·gosched(void); |
612 void» runtime·tsleep(int64); | 625 void» runtime·park(void(*)(Lock*), Lock*, int8*); |
| 626 void» runtime·tsleep(int64, int8*); |
613 M* runtime·newm(void); | 627 M* runtime·newm(void); |
614 void runtime·goexit(void); | 628 void runtime·goexit(void); |
615 void runtime·asmcgocall(void (*fn)(void*), void*); | 629 void runtime·asmcgocall(void (*fn)(void*), void*); |
616 void runtime·entersyscall(void); | 630 void runtime·entersyscall(void); |
617 void runtime·exitsyscall(void); | 631 void runtime·exitsyscall(void); |
618 G* runtime·newproc1(byte*, byte*, int32, int32, void*); | 632 G* runtime·newproc1(byte*, byte*, int32, int32, void*); |
619 bool runtime·sigsend(int32 sig); | 633 bool runtime·sigsend(int32 sig); |
620 int32 runtime·callers(int32, uintptr*, int32); | 634 int32 runtime·callers(int32, uintptr*, int32); |
621 int32 runtime·gentraceback(byte*, byte*, byte*, G*, int32, uintptr*, int32); | 635 int32 runtime·gentraceback(byte*, byte*, byte*, G*, int32, uintptr*, int32); |
622 int64 runtime·nanotime(void); | 636 int64 runtime·nanotime(void); |
623 void runtime·dopanic(int32); | 637 void runtime·dopanic(int32); |
624 void runtime·startpanic(void); | 638 void runtime·startpanic(void); |
625 void runtime·unwindstack(G*, byte*); | 639 void runtime·unwindstack(G*, byte*); |
626 void runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp); | 640 void runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp); |
627 void runtime·resetcpuprofiler(int32); | 641 void runtime·resetcpuprofiler(int32); |
628 void runtime·setcpuprofilerate(void(*)(uintptr*, int32), int32); | 642 void runtime·setcpuprofilerate(void(*)(uintptr*, int32), int32); |
629 void runtime·usleep(uint32); | 643 void runtime·usleep(uint32); |
630 int64 runtime·cputicks(void); | 644 int64 runtime·cputicks(void); |
631 void» runtime·contentionevent(int64); | 645 int64» runtime·tickspersecond(void); |
632 extern bool runtime·ContentionProfileRate; | 646 void» runtime·blockevent(int64, int32); |
| 647 extern int64 runtime·blockprofilerate; |
633 | 648 |
634 #pragma varargck argpos runtime·printf 1 | 649 #pragma varargck argpos runtime·printf 1 |
635 #pragma varargck type "d" int32 | 650 #pragma varargck type "d" int32 |
636 #pragma varargck type "d" uint32 | 651 #pragma varargck type "d" uint32 |
637 #pragma varargck type "D" int64 | 652 #pragma varargck type "D" int64 |
638 #pragma varargck type "D" uint64 | 653 #pragma varargck type "D" uint64 |
639 #pragma varargck type "x" int32 | 654 #pragma varargck type "x" int32 |
640 #pragma varargck type "x" uint32 | 655 #pragma varargck type "x" uint32 |
641 #pragma varargck type "X" int64 | 656 #pragma varargck type "X" int64 |
642 #pragma varargck type "X" uint64 | 657 #pragma varargck type "X" uint64 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 /* | 732 /* |
718 * This is consistent across Linux and BSD. | 733 * This is consistent across Linux and BSD. |
719 * If a new OS is added that is different, move this to | 734 * If a new OS is added that is different, move this to |
720 * $GOOS/$GOARCH/defs.h. | 735 * $GOOS/$GOARCH/defs.h. |
721 */ | 736 */ |
722 #define EACCES 13 | 737 #define EACCES 13 |
723 | 738 |
724 /* | 739 /* |
725 * low level C-called | 740 * low level C-called |
726 */ | 741 */ |
| 742 // for mmap, we only pass the lower 32 bits of file offset to the· |
| 743 // assembly routine; the higher bits (if required), should be provided |
| 744 // by the assembly routine as 0. |
727 uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32); | 745 uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32); |
728 void runtime·munmap(byte*, uintptr); | 746 void runtime·munmap(byte*, uintptr); |
729 void runtime·madvise(byte*, uintptr, int32); | 747 void runtime·madvise(byte*, uintptr, int32); |
730 void runtime·memclr(byte*, uintptr); | 748 void runtime·memclr(byte*, uintptr); |
731 void runtime·setcallerpc(void*, void*); | 749 void runtime·setcallerpc(void*, void*); |
732 void* runtime·getcallerpc(void*); | 750 void* runtime·getcallerpc(void*); |
733 | 751 |
734 /* | 752 /* |
735 * runtime go-called | 753 * runtime go-called |
736 */ | 754 */ |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 void runtime·mapassign(MapType*, Hmap*, byte*, byte*); | 811 void runtime·mapassign(MapType*, Hmap*, byte*, byte*); |
794 void runtime·mapaccess(MapType*, Hmap*, byte*, byte*, bool*); | 812 void runtime·mapaccess(MapType*, Hmap*, byte*, byte*, bool*); |
795 void runtime·mapiternext(struct hash_iter*); | 813 void runtime·mapiternext(struct hash_iter*); |
796 bool runtime·mapiterkey(struct hash_iter*, void*); | 814 bool runtime·mapiterkey(struct hash_iter*, void*); |
797 void runtime·mapiterkeyvalue(struct hash_iter*, void*, void*); | 815 void runtime·mapiterkeyvalue(struct hash_iter*, void*, void*); |
798 Hmap* runtime·makemap_c(MapType*, int64); | 816 Hmap* runtime·makemap_c(MapType*, int64); |
799 | 817 |
800 Hchan* runtime·makechan_c(ChanType*, int64); | 818 Hchan* runtime·makechan_c(ChanType*, int64); |
801 void runtime·chansend(ChanType*, Hchan*, byte*, bool*); | 819 void runtime·chansend(ChanType*, Hchan*, byte*, bool*); |
802 void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*); | 820 void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*); |
803 int32 runtime·chanlen(Hchan*); | |
804 int32 runtime·chancap(Hchan*); | |
805 bool runtime·showframe(Func*); | 821 bool runtime·showframe(Func*); |
806 | 822 |
807 void runtime·ifaceE2I(struct InterfaceType*, Eface, Iface*); | 823 void runtime·ifaceE2I(struct InterfaceType*, Eface, Iface*); |
808 | 824 |
809 uintptr runtime·memlimit(void); | 825 uintptr runtime·memlimit(void); |
810 | 826 |
811 // If appropriate, ask the operating system to control whether this | 827 // If appropriate, ask the operating system to control whether this |
812 // thread should receive profiling signals. This is only necessary on OS X. | 828 // thread should receive profiling signals. This is only necessary on OS X. |
813 // An operating system should not deliver a profiling signal to a | 829 // An operating system should not deliver a profiling signal to a |
814 // thread that is not actually executing (what good is that?), but that's | 830 // thread that is not actually executing (what good is that?), but that's |
815 // what OS X prefers to do. When profiling is turned on, we mask | 831 // what OS X prefers to do. When profiling is turned on, we mask |
816 // away the profiling signal when threads go to sleep, so that OS X | 832 // away the profiling signal when threads go to sleep, so that OS X |
817 // is forced to deliver the signal to a thread that's actually running. | 833 // is forced to deliver the signal to a thread that's actually running. |
818 // This is a no-op on other systems. | 834 // This is a no-op on other systems. |
819 void runtime·setprof(bool); | 835 void runtime·setprof(bool); |
820 | 836 |
821 // float.c | 837 // float.c |
822 extern float64 runtime·nan; | 838 extern float64 runtime·nan; |
823 extern float64 runtime·posinf; | 839 extern float64 runtime·posinf; |
824 extern float64 runtime·neginf; | 840 extern float64 runtime·neginf; |
825 extern uint64 ·nan; | 841 extern uint64 ·nan; |
826 extern uint64 ·posinf; | 842 extern uint64 ·posinf; |
827 extern uint64 ·neginf; | 843 extern uint64 ·neginf; |
828 #define ISNAN(f) ((f) != (f)) | 844 #define ISNAN(f) ((f) != (f)) |
| 845 |
| 846 enum |
| 847 { |
| 848 UseSpanType = 1, |
| 849 }; |
LEFT | RIGHT |