Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 1 | // Copyright 2009 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 5 | /* |
| 6 | * basic types |
| 7 | */ |
| 8 | typedef signed char int8; |
| 9 | typedef unsigned char uint8; |
| 10 | typedef signed short int16; |
| 11 | typedef unsigned short uint16; |
| 12 | typedef signed int int32; |
| 13 | typedef unsigned int uint32; |
| 14 | typedef signed long long int int64; |
| 15 | typedef unsigned long long int uint64; |
| 16 | typedef float float32; |
| 17 | typedef double float64; |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 18 | |
| 19 | #ifdef _64BIT |
Russ Cox | 75647d2 | 2008-11-17 12:32:35 -0800 | [diff] [blame] | 20 | typedef uint64 uintptr; |
Devon H. O'Dell | 659780b | 2009-11-18 09:11:39 -0800 | [diff] [blame] | 21 | typedef int64 intptr; |
Russ Cox | 10ea651 | 2012-09-24 20:57:01 -0400 | [diff] [blame] | 22 | typedef int64 intgo; // Go's int |
| 23 | typedef uint64 uintgo; // Go's uint |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 24 | #else |
| 25 | typedef uint32 uintptr; |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 26 | typedef int32 intptr; |
| 27 | typedef int32 intgo; // Go's int |
| 28 | typedef uint32 uintgo; // Go's uint |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 29 | #endif |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 30 | |
| 31 | /* |
| 32 | * get rid of C types |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 33 | * the / / / forces a syntax error immediately, |
| 34 | * which will show "last name: XXunsigned". |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 35 | */ |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 36 | #define unsigned XXunsigned / / / |
| 37 | #define signed XXsigned / / / |
| 38 | #define char XXchar / / / |
| 39 | #define short XXshort / / / |
| 40 | #define int XXint / / / |
| 41 | #define long XXlong / / / |
| 42 | #define float XXfloat / / / |
| 43 | #define double XXdouble / / / |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 44 | |
| 45 | /* |
| 46 | * defined types |
| 47 | */ |
| 48 | typedef uint8 bool; |
| 49 | typedef uint8 byte; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 50 | typedef struct Func Func; |
| 51 | typedef struct G G; |
| 52 | typedef struct Gobuf Gobuf; |
Dmitriy Vyukov | ee24bfc | 2011-11-02 16:42:01 +0300 | [diff] [blame] | 53 | typedef union Lock Lock; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 54 | typedef struct M M; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 55 | typedef struct Mem Mem; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 56 | typedef union Note Note; |
Rob Pike | 87f2208 | 2009-08-25 15:54:25 -0700 | [diff] [blame] | 57 | typedef struct Slice Slice; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 58 | typedef struct Stktop Stktop; |
Ken Thompson | 3657061 | 2009-04-09 18:16:21 -0700 | [diff] [blame] | 59 | typedef struct String String; |
Russ Cox | c3077f7 | 2008-12-19 17:11:54 -0800 | [diff] [blame] | 60 | typedef struct SigTab SigTab; |
| 61 | typedef struct MCache MCache; |
Russ Cox | d324f21 | 2011-09-30 09:40:01 -0400 | [diff] [blame] | 62 | typedef struct FixAlloc FixAlloc; |
Russ Cox | c3077f7 | 2008-12-19 17:11:54 -0800 | [diff] [blame] | 63 | typedef struct Iface Iface; |
Russ Cox | c7513ea | 2009-07-07 11:02:54 -0700 | [diff] [blame] | 64 | typedef struct Itab Itab; |
Jan Ziak | 5c1422a | 2012-11-01 13:13:20 -0400 | [diff] [blame] | 65 | typedef struct InterfaceType InterfaceType; |
Ken Thompson | f59cb49 | 2010-02-19 20:42:50 -0800 | [diff] [blame] | 66 | typedef struct Eface Eface; |
Russ Cox | c7513ea | 2009-07-07 11:02:54 -0700 | [diff] [blame] | 67 | typedef struct Type Type; |
Russ Cox | 3770b0e | 2011-08-17 15:54:17 -0400 | [diff] [blame] | 68 | typedef struct ChanType ChanType; |
Russ Cox | 65bde08 | 2011-08-17 14:56:27 -0400 | [diff] [blame] | 69 | typedef struct MapType MapType; |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 70 | typedef struct Defer Defer; |
Russ Cox | 0de7161 | 2012-12-22 14:54:39 -0500 | [diff] [blame] | 71 | typedef struct DeferChunk DeferChunk; |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 72 | typedef struct Panic Panic; |
Luuk van Dijk | 7400be8 | 2011-01-31 12:27:28 +0100 | [diff] [blame] | 73 | typedef struct Hmap Hmap; |
Russ Cox | 5ddaf9a | 2009-07-08 15:00:54 -0700 | [diff] [blame] | 74 | typedef struct Hchan Hchan; |
Ken Thompson | f59cb49 | 2010-02-19 20:42:50 -0800 | [diff] [blame] | 75 | typedef struct Complex64 Complex64; |
| 76 | typedef struct Complex128 Complex128; |
Alex Brainman | 2a80882 | 2011-08-27 23:17:00 +1000 | [diff] [blame] | 77 | typedef struct WinCall WinCall; |
Alex Brainman | afe0e97 | 2012-05-30 15:10:54 +1000 | [diff] [blame] | 78 | typedef struct SEH SEH; |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 79 | typedef struct Timers Timers; |
| 80 | typedef struct Timer Timer; |
Dmitriy Vyukov | d839a80 | 2012-04-05 20:48:28 +0400 | [diff] [blame] | 81 | typedef struct GCStats GCStats; |
Dmitriy Vyukov | a5dc779 | 2012-04-12 11:49:25 +0400 | [diff] [blame] | 82 | typedef struct LFNode LFNode; |
Dmitriy Vyukov | 9564364 | 2012-05-11 10:50:03 +0400 | [diff] [blame] | 83 | typedef struct ParFor ParFor; |
| 84 | typedef struct ParForThread ParForThread; |
Ian Lance Taylor | e9a3087 | 2012-11-10 11:19:06 -0800 | [diff] [blame] | 85 | typedef struct CgoMal CgoMal; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 86 | |
| 87 | /* |
Nigel Tao | 90ad6a2 | 2012-10-19 11:02:32 +1100 | [diff] [blame] | 88 | * Per-CPU declaration. |
| 89 | * |
Rob Pike | d08f006 | 2009-08-11 13:30:35 -0700 | [diff] [blame] | 90 | * "extern register" is a special storage class implemented by 6c, 8c, etc. |
Nigel Tao | 90ad6a2 | 2012-10-19 11:02:32 +1100 | [diff] [blame] | 91 | * On the ARM, it is an actual register; elsewhere it is a slot in thread- |
| 92 | * local storage indexed by a segment register. See zasmhdr in |
| 93 | * src/cmd/dist/buildruntime.c for details, and be aware that the linker may |
| 94 | * make further OS-specific changes to the compiler's output. For example, |
| 95 | * 6l/linux rewrites 0(GS) as -16(FS). |
Rob Pike | d08f006 | 2009-08-11 13:30:35 -0700 | [diff] [blame] | 96 | * |
Nigel Tao | 90ad6a2 | 2012-10-19 11:02:32 +1100 | [diff] [blame] | 97 | * Every C file linked into a Go program must include runtime.h so that the |
| 98 | * C compiler (6c, 8c, etc.) knows to avoid other uses of these dedicated |
| 99 | * registers. The Go compiler (6g, 8g, etc.) knows to avoid them. |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 100 | */ |
Rob Pike | d08f006 | 2009-08-11 13:30:35 -0700 | [diff] [blame] | 101 | extern register G* g; |
| 102 | extern register M* m; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 103 | |
| 104 | /* |
| 105 | * defined constants |
| 106 | */ |
| 107 | enum |
| 108 | { |
| 109 | // G status |
Russ Cox | 72157c3 | 2010-04-08 13:24:53 -0700 | [diff] [blame] | 110 | // |
| 111 | // If you add to this list, add to the list |
| 112 | // of "okay during garbage collection" status |
| 113 | // in mgc0.c too. |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 114 | Gidle, |
| 115 | Grunnable, |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 116 | Grunning, |
Russ Cox | 3f8aa66 | 2008-12-05 15:24:18 -0800 | [diff] [blame] | 117 | Gsyscall, |
Ken Thompson | 5262003 | 2008-07-14 14:33:39 -0700 | [diff] [blame] | 118 | Gwaiting, |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 119 | Gmoribund, |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 120 | Gdead, |
| 121 | }; |
| 122 | enum |
| 123 | { |
| 124 | true = 1, |
| 125 | false = 0, |
| 126 | }; |
Jan Ziak | 5419368 | 2012-09-17 17:18:21 -0400 | [diff] [blame] | 127 | enum |
| 128 | { |
| 129 | PtrSize = sizeof(void*), |
| 130 | }; |
Dmitriy Vyukov | f82db7d | 2013-01-10 09:57:06 +0400 | [diff] [blame] | 131 | enum |
| 132 | { |
| 133 | // Per-M stack segment cache size. |
| 134 | StackCacheSize = 32, |
| 135 | // Global <-> per-M stack segment cache transfer batch size. |
| 136 | StackCacheBatch = 16, |
| 137 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 138 | |
| 139 | /* |
| 140 | * structures |
| 141 | */ |
Dmitriy Vyukov | ee24bfc | 2011-11-02 16:42:01 +0300 | [diff] [blame] | 142 | union Lock |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 143 | { |
Dmitriy Vyukov | ee24bfc | 2011-11-02 16:42:01 +0300 | [diff] [blame] | 144 | uint32 key; // futex-based impl |
| 145 | M* waitm; // linked list of waiting M's (sema-based impl) |
Russ Cox | 5ff12f8 | 2008-09-24 10:25:28 -0700 | [diff] [blame] | 146 | }; |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 147 | union Note |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 148 | { |
Dmitriy Vyukov | ee24bfc | 2011-11-02 16:42:01 +0300 | [diff] [blame] | 149 | uint32 key; // futex-based impl |
| 150 | M* waitm; // waiting M (sema-based impl) |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 151 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 152 | struct String |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 153 | { |
Ken Thompson | 3657061 | 2009-04-09 18:16:21 -0700 | [diff] [blame] | 154 | byte* str; |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 155 | intgo len; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 156 | }; |
Russ Cox | c3077f7 | 2008-12-19 17:11:54 -0800 | [diff] [blame] | 157 | struct Iface |
| 158 | { |
Russ Cox | c7513ea | 2009-07-07 11:02:54 -0700 | [diff] [blame] | 159 | Itab* tab; |
Ken Thompson | 3657061 | 2009-04-09 18:16:21 -0700 | [diff] [blame] | 160 | void* data; |
Russ Cox | c3077f7 | 2008-12-19 17:11:54 -0800 | [diff] [blame] | 161 | }; |
Russ Cox | 2da5022 | 2009-05-20 14:57:55 -0700 | [diff] [blame] | 162 | struct Eface |
| 163 | { |
Russ Cox | c7513ea | 2009-07-07 11:02:54 -0700 | [diff] [blame] | 164 | Type* type; |
Russ Cox | 2da5022 | 2009-05-20 14:57:55 -0700 | [diff] [blame] | 165 | void* data; |
| 166 | }; |
Ken Thompson | f59cb49 | 2010-02-19 20:42:50 -0800 | [diff] [blame] | 167 | struct Complex64 |
| 168 | { |
| 169 | float32 real; |
| 170 | float32 imag; |
| 171 | }; |
| 172 | struct Complex128 |
| 173 | { |
| 174 | float64 real; |
| 175 | float64 imag; |
| 176 | }; |
Ken Thompson | 66a603c | 2008-08-27 17:28:30 -0700 | [diff] [blame] | 177 | |
Rob Pike | 87f2208 | 2009-08-25 15:54:25 -0700 | [diff] [blame] | 178 | struct Slice |
Ken Thompson | 66a603c | 2008-08-27 17:28:30 -0700 | [diff] [blame] | 179 | { // must not move anything |
| 180 | byte* array; // actual data |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 181 | uintgo len; // number of elements |
| 182 | uintgo cap; // allocated number of elements |
Ken Thompson | 66a603c | 2008-08-27 17:28:30 -0700 | [diff] [blame] | 183 | }; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 184 | struct Gobuf |
| 185 | { |
Russ Cox | 3802009 | 2009-06-17 16:31:02 -0700 | [diff] [blame] | 186 | // The offsets of these fields are known to (hard-coded in) libmach. |
Jan Ziak | 334bf95 | 2012-05-30 13:07:52 -0400 | [diff] [blame] | 187 | uintptr sp; |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 188 | byte* pc; |
| 189 | G* g; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 190 | }; |
Dmitriy Vyukov | d839a80 | 2012-04-05 20:48:28 +0400 | [diff] [blame] | 191 | struct GCStats |
| 192 | { |
| 193 | // the struct must consist of only uint64's, |
| 194 | // because it is casted to uint64[]. |
| 195 | uint64 nhandoff; |
| 196 | uint64 nhandoffcnt; |
| 197 | uint64 nprocyield; |
| 198 | uint64 nosyield; |
| 199 | uint64 nsleep; |
| 200 | }; |
Ken Thompson | 7b454bb | 2008-07-09 11:35:26 -0700 | [diff] [blame] | 201 | struct G |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 202 | { |
Jan Ziak | 334bf95 | 2012-05-30 13:07:52 -0400 | [diff] [blame] | 203 | uintptr stackguard; // cannot move - also known to linker, libmach, runtime/cgo |
| 204 | uintptr stackbase; // cannot move - also known to libmach, runtime/cgo |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 205 | Defer* defer; |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 206 | Panic* panic; |
| 207 | Gobuf sched; |
Jan Ziak | 334bf95 | 2012-05-30 13:07:52 -0400 | [diff] [blame] | 208 | uintptr gcstack; // if status==Gsyscall, gcstack = stackbase to use during gc |
| 209 | uintptr gcsp; // if status==Gsyscall, gcsp = sched.sp to use during gc |
| 210 | uintptr gcguard; // if status==Gsyscall, gcguard = stackguard to use during gc |
| 211 | uintptr stack0; |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 212 | byte* entry; // initial function |
Rob Pike | 3835e01 | 2008-07-28 11:29:41 -0700 | [diff] [blame] | 213 | G* alllink; // on allg |
Ken Thompson | e963cba | 2008-07-25 15:55:12 -0700 | [diff] [blame] | 214 | void* param; // passed parameter on wakeup |
| 215 | int16 status; |
Dmitriy Vyukov | 320df44 | 2012-10-26 10:13:06 +0400 | [diff] [blame] | 216 | int64 goid; |
Adam Langley | 50d6c81 | 2009-12-18 12:25:53 -0800 | [diff] [blame] | 217 | uint32 selgen; // valid sudog pointer |
Russ Cox | 03e9ea5 | 2011-08-22 23:26:39 -0400 | [diff] [blame] | 218 | int8* waitreason; // if status==Gwaiting |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 219 | G* schedlink; |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 220 | bool readyonstop; |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 221 | bool ispanic; |
Dmitriy Vyukov | 81221f5 | 2013-01-29 14:57:11 +0400 | [diff] [blame] | 222 | bool issystem; |
Dmitriy Vyukov | 2f6cbc7 | 2012-10-07 22:05:32 +0400 | [diff] [blame] | 223 | int8 raceignore; // ignore race detection events |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 224 | M* m; // for debuggers, but offset not hard-coded |
Russ Cox | 218c393 | 2009-07-13 17:28:39 -0700 | [diff] [blame] | 225 | M* lockedm; |
Russ Cox | 582fd17 | 2011-02-27 23:32:42 -0500 | [diff] [blame] | 226 | M* idlem; |
Russ Cox | 5963dba | 2010-04-08 18:15:30 -0700 | [diff] [blame] | 227 | int32 sig; |
Russ Cox | e4b02bf | 2012-02-22 21:45:01 -0500 | [diff] [blame] | 228 | int32 writenbuf; |
| 229 | byte* writebuf; |
Russ Cox | 0de7161 | 2012-12-22 14:54:39 -0500 | [diff] [blame] | 230 | DeferChunk *dchunk; |
| 231 | DeferChunk *dchunknext; |
Russ Cox | 5963dba | 2010-04-08 18:15:30 -0700 | [diff] [blame] | 232 | uintptr sigcode0; |
| 233 | uintptr sigcode1; |
Russ Cox | 1230700 | 2011-01-18 14:15:11 -0500 | [diff] [blame] | 234 | uintptr sigpc; |
Russ Cox | 324cc3d0 | 2011-03-02 13:42:02 -0500 | [diff] [blame] | 235 | uintptr gopc; // pc of go statement that created this goroutine |
Hector Chu | 9fd2687 | 2011-09-17 17:57:59 +1000 | [diff] [blame] | 236 | uintptr end[]; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 237 | }; |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 238 | struct M |
| 239 | { |
Russ Cox | 3802009 | 2009-06-17 16:31:02 -0700 | [diff] [blame] | 240 | // The offsets of these fields are known to (hard-coded in) libmach. |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 241 | G* g0; // goroutine with scheduling stack |
| 242 | void (*morepc)(void); |
Russ Cox | 141a4a1 | 2011-01-14 14:05:20 -0500 | [diff] [blame] | 243 | void* moreargp; // argument pointer for more stack |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 244 | Gobuf morebuf; // gobuf arg to morestack |
| 245 | |
Russ Cox | 3802009 | 2009-06-17 16:31:02 -0700 | [diff] [blame] | 246 | // Fields not known to debuggers. |
Russ Cox | 141a4a1 | 2011-01-14 14:05:20 -0500 | [diff] [blame] | 247 | uint32 moreframesize; // size arguments to morestack |
| 248 | uint32 moreargsize; |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 249 | uintptr cret; // return value from C |
| 250 | uint64 procid; // for debuggers, but offset not hard-coded |
| 251 | G* gsignal; // signal-handling G |
| 252 | uint32 tls[8]; // thread-local storage (for 386 extern register) |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 253 | G* curg; // current running goroutine |
Russ Cox | efc86a7 | 2008-11-25 16:48:10 -0800 | [diff] [blame] | 254 | int32 id; |
Russ Cox | da0a7d7 | 2008-12-19 03:13:39 -0800 | [diff] [blame] | 255 | int32 mallocing; |
Dmitriy Vyukov | 81221f5 | 2013-01-29 14:57:11 +0400 | [diff] [blame] | 256 | int32 throwing; |
Russ Cox | 8c357ce | 2009-06-15 21:31:56 -0700 | [diff] [blame] | 257 | int32 gcing; |
Russ Cox | 1ce1791 | 2009-01-26 17:37:05 -0800 | [diff] [blame] | 258 | int32 locks; |
Russ Cox | 6eb251f | 2010-03-24 09:40:09 -0700 | [diff] [blame] | 259 | int32 nomemprof; |
Russ Cox | 218c393 | 2009-07-13 17:28:39 -0700 | [diff] [blame] | 260 | int32 waitnextg; |
Russ Cox | 6779350 | 2011-02-16 13:21:13 -0500 | [diff] [blame] | 261 | int32 dying; |
Russ Cox | c19b373 | 2011-03-23 11:43:37 -0400 | [diff] [blame] | 262 | int32 profilehz; |
Russ Cox | d324f21 | 2011-09-30 09:40:01 -0400 | [diff] [blame] | 263 | int32 helpgc; |
Dmitriy Vyukov | 909f318 | 2011-07-12 01:23:58 -0400 | [diff] [blame] | 264 | uint32 fastrand; |
Ian Lance Taylor | e9a3087 | 2012-11-10 11:19:06 -0800 | [diff] [blame] | 265 | uint64 ncgocall; // number of cgo calls in total |
| 266 | int32 ncgo; // number of cgo calls currently in progress |
| 267 | CgoMal* cgomal; |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 268 | Note havenextg; |
| 269 | G* nextg; |
Russ Cox | 93689d8 | 2009-10-09 15:35:33 -0700 | [diff] [blame] | 270 | M* alllink; // on allm |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 271 | M* schedlink; |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 272 | uint32 machport; // Return address for Mach IPC (OS X) |
Russ Cox | e29ce17 | 2008-12-18 15:42:28 -0800 | [diff] [blame] | 273 | MCache *mcache; |
Dmitriy Vyukov | f82db7d | 2013-01-10 09:57:06 +0400 | [diff] [blame] | 274 | int32 stackinuse; |
| 275 | uint32 stackcachepos; |
| 276 | uint32 stackcachecnt; |
| 277 | void* stackcache[StackCacheSize]; |
Russ Cox | 218c393 | 2009-07-13 17:28:39 -0700 | [diff] [blame] | 278 | G* lockedg; |
Russ Cox | 582fd17 | 2011-02-27 23:32:42 -0500 | [diff] [blame] | 279 | G* idleg; |
Russ Cox | 5b93fc9 | 2012-02-08 10:33:54 -0500 | [diff] [blame] | 280 | uintptr createstack[32]; // Stack that created this thread. |
Ken Thompson | ae60526 | 2010-12-09 14:45:27 -0800 | [diff] [blame] | 281 | uint32 freglo[16]; // D[i] lsb and F[i] |
| 282 | uint32 freghi[16]; // D[i] msb and F[i+16] |
| 283 | uint32 fflag; // floating point compare flags |
Dmitriy Vyukov | ee24bfc | 2011-11-02 16:42:01 +0300 | [diff] [blame] | 284 | M* nextwaitm; // next M waiting for lock |
| 285 | uintptr waitsema; // semaphore for parking on locks |
| 286 | uint32 waitsemacount; |
| 287 | uint32 waitsemalock; |
Dmitriy Vyukov | d839a80 | 2012-04-05 20:48:28 +0400 | [diff] [blame] | 288 | GCStats gcstats; |
Dmitriy Vyukov | 2f6cbc7 | 2012-10-07 22:05:32 +0400 | [diff] [blame] | 289 | bool racecall; |
| 290 | void* racepc; |
Jan Ziak | 51b8edc | 2012-11-27 13:04:59 -0500 | [diff] [blame] | 291 | uint32 moreframesize_minalloc; |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 292 | |
Jan Ziak | f8c5837 | 2012-09-24 20:08:05 -0400 | [diff] [blame] | 293 | uintptr settype_buf[1024]; |
| 294 | uintptr settype_bufsize; |
| 295 | |
Russ Cox | 851f301 | 2011-12-16 15:33:58 -0500 | [diff] [blame] | 296 | #ifdef GOOS_windows |
Hector Chu | 9fd2687 | 2011-09-17 17:57:59 +1000 | [diff] [blame] | 297 | void* thread; // thread handle |
Hector Chu | 5c30325 | 2011-09-14 20:23:21 -0400 | [diff] [blame] | 298 | #endif |
Akshat Kumar | c74f3c4 | 2013-01-30 02:53:56 -0800 | [diff] [blame^] | 299 | #ifdef GOOS_plan9 |
| 300 | int8* notesig; |
| 301 | #endif |
Alex Brainman | afe0e97 | 2012-05-30 15:10:54 +1000 | [diff] [blame] | 302 | SEH* seh; |
Hector Chu | 9fd2687 | 2011-09-17 17:57:59 +1000 | [diff] [blame] | 303 | uintptr end[]; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 304 | }; |
Russ Cox | 370276a | 2011-04-27 23:21:12 -0400 | [diff] [blame] | 305 | |
Ken Thompson | 5262003 | 2008-07-14 14:33:39 -0700 | [diff] [blame] | 306 | struct Stktop |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 307 | { |
Russ Cox | 3802009 | 2009-06-17 16:31:02 -0700 | [diff] [blame] | 308 | // The offsets of these fields are known to (hard-coded in) libmach. |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 309 | uint8* stackguard; |
| 310 | uint8* stackbase; |
| 311 | Gobuf gobuf; |
Russ Cox | 141a4a1 | 2011-01-14 14:05:20 -0500 | [diff] [blame] | 312 | uint32 argsize; |
Russ Cox | bba278a | 2009-07-08 18:16:09 -0700 | [diff] [blame] | 313 | |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 314 | uint8* argp; // pointer to arguments in old frame |
| 315 | uintptr free; // if free>0, call stackfree using free as size |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 316 | bool panic; // is this frame the top of a panic? |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 317 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 318 | struct SigTab |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 319 | { |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 320 | int32 flags; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 321 | int8 *name; |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 322 | }; |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 323 | enum |
| 324 | { |
Russ Cox | 35586f7 | 2012-02-13 13:52:37 -0500 | [diff] [blame] | 325 | SigNotify = 1<<0, // let signal.Notify have signal, even if from kernel |
David Symonds | 3d8ebef | 2012-02-17 14:36:40 +1100 | [diff] [blame] | 326 | SigKill = 1<<1, // if signal.Notify doesn't take it, exit quietly |
| 327 | SigThrow = 1<<2, // if signal.Notify doesn't take it, exit loudly |
| 328 | SigPanic = 1<<3, // if the signal is from the kernel, panic |
| 329 | SigDefault = 1<<4, // if the signal isn't explicitly requested, don't monitor it |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 330 | }; |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 331 | |
Russ Cox | 6eb251f | 2010-03-24 09:40:09 -0700 | [diff] [blame] | 332 | // NOTE(rsc): keep in sync with extern.go:/type.Func. |
| 333 | // Eventually, the loaded symbol table should be closer to this form. |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 334 | struct Func |
| 335 | { |
Ken Thompson | 3657061 | 2009-04-09 18:16:21 -0700 | [diff] [blame] | 336 | String name; |
| 337 | String type; // go type string |
| 338 | String src; // src file name |
Rob Pike | 87f2208 | 2009-08-25 15:54:25 -0700 | [diff] [blame] | 339 | Slice pcln; // pc/ln tab for this func |
Russ Cox | 6eb251f | 2010-03-24 09:40:09 -0700 | [diff] [blame] | 340 | uintptr entry; // entry pc |
| 341 | uintptr pc0; // starting pc, ln for table |
Russ Cox | a543336 | 2008-11-25 09:23:36 -0800 | [diff] [blame] | 342 | int32 ln0; |
Russ Cox | 6eb251f | 2010-03-24 09:40:09 -0700 | [diff] [blame] | 343 | int32 frame; // stack frame size |
Russ Cox | efc86a7 | 2008-11-25 16:48:10 -0800 | [diff] [blame] | 344 | int32 args; // number of 32-bit in/out args |
| 345 | int32 locals; // number of 32-bit locals |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 346 | }; |
| 347 | |
Jan Ziak | 5c1422a | 2012-11-01 13:13:20 -0400 | [diff] [blame] | 348 | // layout of Itab known to compilers |
| 349 | struct Itab |
| 350 | { |
| 351 | InterfaceType* inter; |
| 352 | Type* type; |
| 353 | Itab* link; |
| 354 | int32 bad; |
| 355 | int32 unused; |
| 356 | void (*fun[])(void); |
| 357 | }; |
| 358 | |
Alex Brainman | 2a80882 | 2011-08-27 23:17:00 +1000 | [diff] [blame] | 359 | struct WinCall |
| 360 | { |
| 361 | void (*fn)(void*); |
| 362 | uintptr n; // number of parameters |
| 363 | void* args; // parameters |
Alex Brainman | 7406379 | 2011-09-14 16:19:45 +1000 | [diff] [blame] | 364 | uintptr r1; // return values |
| 365 | uintptr r2; |
Alex Brainman | 2a80882 | 2011-08-27 23:17:00 +1000 | [diff] [blame] | 366 | uintptr err; // error number |
| 367 | }; |
Alex Brainman | afe0e97 | 2012-05-30 15:10:54 +1000 | [diff] [blame] | 368 | struct SEH |
| 369 | { |
| 370 | void* prev; |
| 371 | void* handler; |
| 372 | }; |
Alex Brainman | 2a80882 | 2011-08-27 23:17:00 +1000 | [diff] [blame] | 373 | |
Russ Cox | 851f301 | 2011-12-16 15:33:58 -0500 | [diff] [blame] | 374 | #ifdef GOOS_windows |
Alex Brainman | f95a2f2 | 2010-09-12 11:45:16 +1000 | [diff] [blame] | 375 | enum { |
| 376 | Windows = 1 |
| 377 | }; |
| 378 | #else |
| 379 | enum { |
| 380 | Windows = 0 |
| 381 | }; |
| 382 | #endif |
| 383 | |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 384 | struct Timers |
| 385 | { |
| 386 | Lock; |
| 387 | G *timerproc; |
| 388 | bool sleeping; |
| 389 | bool rescheduling; |
| 390 | Note waitnote; |
| 391 | Timer **t; |
| 392 | int32 len; |
| 393 | int32 cap; |
| 394 | }; |
| 395 | |
| 396 | // Package time knows the layout of this structure. |
| 397 | // If this struct changes, adjust ../time/sleep.go:/runtimeTimer. |
| 398 | struct Timer |
| 399 | { |
| 400 | int32 i; // heap index |
| 401 | |
| 402 | // Timer wakes up at when, and then at when+period, ... (period > 0 only) |
| 403 | // each time calling f(now, arg) in the timer goroutine, so f must be |
| 404 | // a well-behaved function and not block. |
| 405 | int64 when; |
| 406 | int64 period; |
| 407 | void (*f)(int64, Eface); |
| 408 | Eface arg; |
| 409 | }; |
| 410 | |
Dmitriy Vyukov | a5dc779 | 2012-04-12 11:49:25 +0400 | [diff] [blame] | 411 | // Lock-free stack node. |
| 412 | struct LFNode |
| 413 | { |
| 414 | LFNode *next; |
| 415 | uintptr pushcnt; |
| 416 | }; |
| 417 | |
Dmitriy Vyukov | 9564364 | 2012-05-11 10:50:03 +0400 | [diff] [blame] | 418 | // Parallel for descriptor. |
| 419 | struct ParFor |
| 420 | { |
| 421 | void (*body)(ParFor*, uint32); // executed for each element |
| 422 | uint32 done; // number of idle threads |
| 423 | uint32 nthr; // total number of threads |
| 424 | uint32 nthrmax; // maximum number of threads |
| 425 | uint32 thrseq; // thread id sequencer |
| 426 | uint32 cnt; // iteration space [0, cnt) |
| 427 | void *ctx; // arbitrary user context |
| 428 | bool wait; // if true, wait while all threads finish processing, |
| 429 | // otherwise parfor may return while other threads are still working |
| 430 | ParForThread *thr; // array of thread descriptors |
| 431 | // stats |
| 432 | uint64 nsteal; |
| 433 | uint64 nstealcnt; |
| 434 | uint64 nprocyield; |
| 435 | uint64 nosyield; |
| 436 | uint64 nsleep; |
| 437 | }; |
| 438 | |
Ian Lance Taylor | e9a3087 | 2012-11-10 11:19:06 -0800 | [diff] [blame] | 439 | // Track memory allocated by code not written in Go during a cgo call, |
| 440 | // so that the garbage collector can see them. |
| 441 | struct CgoMal |
| 442 | { |
| 443 | CgoMal *next; |
| 444 | byte *alloc; |
| 445 | }; |
| 446 | |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 447 | /* |
| 448 | * defined macros |
Robert Hencke | 3fbd478 | 2011-05-30 18:02:59 +1000 | [diff] [blame] | 449 | * you need super-gopher-guru privilege |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 450 | * to add this list. |
| 451 | */ |
| 452 | #define nelem(x) (sizeof(x)/sizeof((x)[0])) |
| 453 | #define nil ((void*)0) |
Russ Cox | dc9a3b2 | 2010-12-13 16:22:19 -0500 | [diff] [blame] | 454 | #define offsetof(s,m) (uint32)(&(((s*)0)->m)) |
Russ Cox | 6dbaa20 | 2012-05-29 14:02:29 -0400 | [diff] [blame] | 455 | #define ROUND(x, n) (((x)+(n)-1)&~((n)-1)) /* all-caps to mark as macro: it evaluates n twice */ |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 456 | |
| 457 | /* |
Russ Cox | eee50ae | 2008-12-19 12:05:22 -0800 | [diff] [blame] | 458 | * known to compiler |
| 459 | */ |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 460 | enum { |
| 461 | Structrnd = sizeof(uintptr) |
| 462 | }; |
| 463 | |
| 464 | /* |
| 465 | * type algorithms - known to compiler |
| 466 | */ |
Russ Cox | eee50ae | 2008-12-19 12:05:22 -0800 | [diff] [blame] | 467 | enum |
| 468 | { |
Russ Cox | a7f6d40 | 2009-01-26 09:56:42 -0800 | [diff] [blame] | 469 | AMEM, |
Dmitriy Vyukov | 1ff1405 | 2012-01-20 10:32:55 +0400 | [diff] [blame] | 470 | AMEM0, |
Dmitriy Vyukov | 54e9406 | 2011-08-08 09:35:32 -0400 | [diff] [blame] | 471 | AMEM8, |
| 472 | AMEM16, |
| 473 | AMEM32, |
| 474 | AMEM64, |
| 475 | AMEM128, |
Russ Cox | 196b663 | 2011-12-12 22:22:09 -0500 | [diff] [blame] | 476 | ANOEQ, |
Dmitriy Vyukov | 1ff1405 | 2012-01-20 10:32:55 +0400 | [diff] [blame] | 477 | ANOEQ0, |
Dmitriy Vyukov | 54e9406 | 2011-08-08 09:35:32 -0400 | [diff] [blame] | 478 | ANOEQ8, |
| 479 | ANOEQ16, |
| 480 | ANOEQ32, |
| 481 | ANOEQ64, |
| 482 | ANOEQ128, |
Russ Cox | 196b663 | 2011-12-12 22:22:09 -0500 | [diff] [blame] | 483 | ASTRING, |
| 484 | AINTER, |
| 485 | ANILINTER, |
| 486 | ASLICE, |
Russ Cox | 408f0b1 | 2012-01-26 16:25:07 -0500 | [diff] [blame] | 487 | AFLOAT32, |
| 488 | AFLOAT64, |
| 489 | ACPLX64, |
| 490 | ACPLX128, |
Russ Cox | a7f6d40 | 2009-01-26 09:56:42 -0800 | [diff] [blame] | 491 | Amax |
Russ Cox | eee50ae | 2008-12-19 12:05:22 -0800 | [diff] [blame] | 492 | }; |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 493 | typedef struct Alg Alg; |
| 494 | struct Alg |
| 495 | { |
| 496 | void (*hash)(uintptr*, uintptr, void*); |
| 497 | void (*equal)(bool*, uintptr, void*, void*); |
| 498 | void (*print)(uintptr, void*); |
| 499 | void (*copy)(uintptr, void*, void*); |
Russ Cox | 29aa3ff | 2009-07-02 21:25:46 -0700 | [diff] [blame] | 500 | }; |
| 501 | |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 502 | extern Alg runtime·algarray[Amax]; |
| 503 | |
| 504 | void runtime·memhash(uintptr*, uintptr, void*); |
| 505 | void runtime·nohash(uintptr*, uintptr, void*); |
| 506 | void runtime·strhash(uintptr*, uintptr, void*); |
| 507 | void runtime·interhash(uintptr*, uintptr, void*); |
| 508 | void runtime·nilinterhash(uintptr*, uintptr, void*); |
| 509 | |
| 510 | void runtime·memequal(bool*, uintptr, void*, void*); |
| 511 | void runtime·noequal(bool*, uintptr, void*, void*); |
| 512 | void runtime·strequal(bool*, uintptr, void*, void*); |
| 513 | void runtime·interequal(bool*, uintptr, void*, void*); |
| 514 | void runtime·nilinterequal(bool*, uintptr, void*, void*); |
| 515 | |
| 516 | void runtime·memprint(uintptr, void*); |
| 517 | void runtime·strprint(uintptr, void*); |
| 518 | void runtime·interprint(uintptr, void*); |
| 519 | void runtime·nilinterprint(uintptr, void*); |
| 520 | |
| 521 | void runtime·memcopy(uintptr, void*, void*); |
| 522 | void runtime·memcopy8(uintptr, void*, void*); |
| 523 | void runtime·memcopy16(uintptr, void*, void*); |
| 524 | void runtime·memcopy32(uintptr, void*, void*); |
| 525 | void runtime·memcopy64(uintptr, void*, void*); |
| 526 | void runtime·memcopy128(uintptr, void*, void*); |
| 527 | void runtime·memcopy(uintptr, void*, void*); |
| 528 | void runtime·strcopy(uintptr, void*, void*); |
| 529 | void runtime·algslicecopy(uintptr, void*, void*); |
| 530 | void runtime·intercopy(uintptr, void*, void*); |
| 531 | void runtime·nilintercopy(uintptr, void*, void*); |
| 532 | |
Russ Cox | eee50ae | 2008-12-19 12:05:22 -0800 | [diff] [blame] | 533 | /* |
Ken Thompson | 47ab1c1 | 2009-01-27 13:23:28 -0800 | [diff] [blame] | 534 | * deferred subroutine calls |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 535 | */ |
| 536 | struct Defer |
| 537 | { |
| 538 | int32 siz; |
Russ Cox | 0de7161 | 2012-12-22 14:54:39 -0500 | [diff] [blame] | 539 | bool special; // not part of defer frame |
| 540 | bool free; // if special, free when done |
Russ Cox | 141a4a1 | 2011-01-14 14:05:20 -0500 | [diff] [blame] | 541 | byte* argp; // where args were copied from |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 542 | byte* pc; |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 543 | byte* fn; |
| 544 | Defer* link; |
Jan Ziak | 334bf95 | 2012-05-30 13:07:52 -0400 | [diff] [blame] | 545 | void* args[1]; // padded to actual size |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 546 | }; |
| 547 | |
Russ Cox | 0de7161 | 2012-12-22 14:54:39 -0500 | [diff] [blame] | 548 | struct DeferChunk |
| 549 | { |
| 550 | DeferChunk *prev; |
| 551 | uintptr off; |
| 552 | }; |
| 553 | |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 554 | /* |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 555 | * panics |
| 556 | */ |
| 557 | struct Panic |
| 558 | { |
| 559 | Eface arg; // argument to panic |
| 560 | byte* stackbase; // g->stackbase in panic |
| 561 | Panic* link; // link to earlier panic |
| 562 | bool recovered; // whether this panic is over |
| 563 | }; |
| 564 | |
| 565 | /* |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 566 | * external data |
| 567 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 568 | extern String runtime·emptystring; |
Jan Ziak | 4a191c2 | 2012-10-21 17:41:32 -0400 | [diff] [blame] | 569 | extern uintptr runtime·zerobase; |
Shenghou Ma | 4019d0e | 2013-01-26 09:57:06 +0800 | [diff] [blame] | 570 | extern G* runtime·allg; |
| 571 | extern G* runtime·lastg; |
| 572 | extern M* runtime·allm; |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 573 | extern int32 runtime·gomaxprocs; |
Dmitriy Vyukov | a2677cf | 2011-08-16 16:53:02 -0400 | [diff] [blame] | 574 | extern bool runtime·singleproc; |
Russ Cox | 6779350 | 2011-02-16 13:21:13 -0500 | [diff] [blame] | 575 | extern uint32 runtime·panicking; |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 576 | extern int32 runtime·gcwaiting; // gc is waiting to run |
Shenghou Ma | 4019d0e | 2013-01-26 09:57:06 +0800 | [diff] [blame] | 577 | extern int8* runtime·goos; |
| 578 | extern int32 runtime·ncpu; |
Russ Cox | 9042c2c | 2010-12-08 13:53:30 -0500 | [diff] [blame] | 579 | extern bool runtime·iscgo; |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 580 | extern void (*runtime·sysargs)(int32, uint8**); |
| 581 | extern uint32 runtime·maxstring; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 582 | |
| 583 | /* |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 584 | * common functions and data |
| 585 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 586 | int32 runtime·strcmp(byte*, byte*); |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 587 | byte* runtime·strstr(byte*, byte*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 588 | int32 runtime·findnull(byte*); |
Alex Brainman | a41d854 | 2011-01-12 11:48:15 +1100 | [diff] [blame] | 589 | int32 runtime·findnullw(uint16*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 590 | void runtime·dump(byte*, int32); |
| 591 | int32 runtime·runetochar(byte*, int32); |
| 592 | int32 runtime·charntorune(int32*, uint8*, int32); |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 593 | |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 594 | /* |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 595 | * very low level c-called |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 596 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 597 | #define FLUSH(x) USED(x) |
Russ Cox | 4e28cfe | 2010-03-26 14:15:30 -0700 | [diff] [blame] | 598 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 599 | void runtime·gogo(Gobuf*, uintptr); |
| 600 | void runtime·gogocall(Gobuf*, void(*)(void)); |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 601 | void runtime·gosave(Gobuf*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 602 | void runtime·lessstack(void); |
| 603 | void runtime·goargs(void); |
Alex Brainman | a41d854 | 2011-01-12 11:48:15 +1100 | [diff] [blame] | 604 | void runtime·goenvs(void); |
| 605 | void runtime·goenvs_unix(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 606 | void* runtime·getu(void); |
| 607 | void runtime·throw(int8*); |
| 608 | void runtime·panicstring(int8*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 609 | void runtime·prints(int8*); |
| 610 | void runtime·printf(int8*, ...); |
| 611 | byte* runtime·mchr(byte*, byte, byte*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 612 | int32 runtime·mcmp(byte*, byte*, uint32); |
| 613 | void runtime·memmove(void*, void*, uint32); |
| 614 | void* runtime·mal(uintptr); |
| 615 | String runtime·catstring(String, String); |
| 616 | String runtime·gostring(byte*); |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 617 | String runtime·gostringn(byte*, intgo); |
| 618 | Slice runtime·gobytes(byte*, intgo); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 619 | String runtime·gostringnocopy(byte*); |
Alex Brainman | a41d854 | 2011-01-12 11:48:15 +1100 | [diff] [blame] | 620 | String runtime·gostringw(uint16*); |
Russ Cox | 35586f7 | 2012-02-13 13:52:37 -0500 | [diff] [blame] | 621 | void runtime·initsig(void); |
David Symonds | 3d8ebef | 2012-02-17 14:36:40 +1100 | [diff] [blame] | 622 | void runtime·sigenable(uint32 sig); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 623 | int32 runtime·gotraceback(void); |
Russ Cox | 03e9ea5 | 2011-08-22 23:26:39 -0400 | [diff] [blame] | 624 | void runtime·goroutineheader(G*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 625 | void runtime·traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp); |
| 626 | void runtime·tracebackothers(G*); |
| 627 | int32 runtime·write(int32, void*, int32); |
Jonathan Mark | ddde52a | 2011-06-07 21:50:10 -0700 | [diff] [blame] | 628 | int32 runtime·mincore(void*, uintptr, byte*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 629 | bool runtime·cas(uint32*, uint32, uint32); |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 630 | bool runtime·cas64(uint64*, uint64*, uint64); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 631 | bool runtime·casp(void**, void*, void*); |
Dmitriy Vyukov | 997c00f | 2011-06-28 15:09:53 -0400 | [diff] [blame] | 632 | // Don't confuse with XADD x86 instruction, |
| 633 | // this one is actually 'addx', that is, add-and-fetch. |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 634 | uint32 runtime·xadd(uint32 volatile*, int32); |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 635 | uint64 runtime·xadd64(uint64 volatile*, int64); |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 636 | uint32 runtime·xchg(uint32 volatile*, uint32); |
Dmitriy Vyukov | 86a659c | 2011-07-13 11:22:41 -0700 | [diff] [blame] | 637 | uint32 runtime·atomicload(uint32 volatile*); |
Dmitriy Vyukov | 91f0f18 | 2011-07-29 13:47:24 -0400 | [diff] [blame] | 638 | void runtime·atomicstore(uint32 volatile*, uint32); |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 639 | void runtime·atomicstore64(uint64 volatile*, uint64); |
| 640 | uint64 runtime·atomicload64(uint64 volatile*); |
Dmitriy Vyukov | 86a659c | 2011-07-13 11:22:41 -0700 | [diff] [blame] | 641 | void* runtime·atomicloadp(void* volatile*); |
| 642 | void runtime·atomicstorep(void* volatile*, void*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 643 | void runtime·jmpdefer(byte*, void*); |
| 644 | void runtime·exit1(int32); |
| 645 | void runtime·ready(G*); |
| 646 | byte* runtime·getenv(int8*); |
| 647 | int32 runtime·atoi(byte*); |
Jingcheng Zhang | 70e967b | 2012-12-19 00:30:29 +0800 | [diff] [blame] | 648 | void runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void)); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 649 | void runtime·signalstack(byte*, int32); |
| 650 | G* runtime·malg(int32); |
Russ Cox | 1707a99 | 2012-02-14 01:23:15 -0500 | [diff] [blame] | 651 | void runtime·asminit(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 652 | void runtime·minit(void); |
| 653 | Func* runtime·findfunc(uintptr); |
Russ Cox | b287d7c | 2011-02-02 16:44:20 -0500 | [diff] [blame] | 654 | int32 runtime·funcline(Func*, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 655 | void* runtime·stackalloc(uint32); |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 656 | void runtime·stackfree(void*, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 657 | MCache* runtime·allocmcache(void); |
Dmitriy Vyukov | ed516df | 2012-07-01 13:10:01 +0400 | [diff] [blame] | 658 | void runtime·freemcache(MCache*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 659 | void runtime·mallocinit(void); |
| 660 | bool runtime·ifaceeq_c(Iface, Iface); |
| 661 | bool runtime·efaceeq_c(Eface, Eface); |
Ian Lance Taylor | 63bee95 | 2013-01-04 07:53:42 -0800 | [diff] [blame] | 662 | uintptr runtime·ifacehash(Iface, uintptr); |
| 663 | uintptr runtime·efacehash(Eface, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 664 | void* runtime·malloc(uintptr size); |
| 665 | void runtime·free(void *v); |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 666 | bool runtime·addfinalizer(void*, void(*fn)(void*), uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 667 | void runtime·runpanic(Panic*); |
| 668 | void* runtime·getcallersp(void*); |
Russ Cox | 4608feb | 2011-01-28 15:03:26 -0500 | [diff] [blame] | 669 | int32 runtime·mcount(void); |
Russ Cox | e4b02bf | 2012-02-22 21:45:01 -0500 | [diff] [blame] | 670 | int32 runtime·gcount(void); |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 671 | void runtime·mcall(void(*)(G*)); |
Dmitriy Vyukov | 909f318 | 2011-07-12 01:23:58 -0400 | [diff] [blame] | 672 | uint32 runtime·fastrand1(void); |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 673 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 674 | void runtime·exit(int32); |
| 675 | void runtime·breakpoint(void); |
| 676 | void runtime·gosched(void); |
Dmitriy Vyukov | f20fd87 | 2012-09-18 21:15:46 +0400 | [diff] [blame] | 677 | void runtime·park(void(*)(Lock*), Lock*, int8*); |
| 678 | void runtime·tsleep(int64, int8*); |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 679 | M* runtime·newm(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 680 | void runtime·goexit(void); |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 681 | void runtime·asmcgocall(void (*fn)(void*), void*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 682 | void runtime·entersyscall(void); |
| 683 | void runtime·exitsyscall(void); |
Russ Cox | 324cc3d0 | 2011-03-02 13:42:02 -0500 | [diff] [blame] | 684 | G* runtime·newproc1(byte*, byte*, int32, int32, void*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 685 | bool runtime·sigsend(int32 sig); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 686 | int32 runtime·callers(int32, uintptr*, int32); |
Russ Cox | c19b373 | 2011-03-23 11:43:37 -0400 | [diff] [blame] | 687 | int32 runtime·gentraceback(byte*, byte*, byte*, G*, int32, uintptr*, int32); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 688 | int64 runtime·nanotime(void); |
| 689 | void runtime·dopanic(int32); |
Russ Cox | 6779350 | 2011-02-16 13:21:13 -0500 | [diff] [blame] | 690 | void runtime·startpanic(void); |
Dmitriy Vyukov | a54f920b | 2012-07-04 14:52:51 +0400 | [diff] [blame] | 691 | void runtime·unwindstack(G*, byte*); |
Russ Cox | c19b373 | 2011-03-23 11:43:37 -0400 | [diff] [blame] | 692 | void runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp); |
| 693 | void runtime·resetcpuprofiler(int32); |
| 694 | void runtime·setcpuprofilerate(void(*)(uintptr*, int32), int32); |
Russ Cox | d324f21 | 2011-09-30 09:40:01 -0400 | [diff] [blame] | 695 | void runtime·usleep(uint32); |
Damian Gryski | 8e765da | 2012-02-02 14:09:27 -0500 | [diff] [blame] | 696 | int64 runtime·cputicks(void); |
Dmitriy Vyukov | 4cc7bf3 | 2012-10-06 12:56:04 +0400 | [diff] [blame] | 697 | int64 runtime·tickspersecond(void); |
| 698 | void runtime·blockevent(int64, int32); |
| 699 | extern int64 runtime·blockprofilerate; |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame] | 700 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 701 | #pragma varargck argpos runtime·printf 1 |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame] | 702 | #pragma varargck type "d" int32 |
| 703 | #pragma varargck type "d" uint32 |
| 704 | #pragma varargck type "D" int64 |
| 705 | #pragma varargck type "D" uint64 |
| 706 | #pragma varargck type "x" int32 |
| 707 | #pragma varargck type "x" uint32 |
| 708 | #pragma varargck type "X" int64 |
| 709 | #pragma varargck type "X" uint64 |
| 710 | #pragma varargck type "p" void* |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 711 | #pragma varargck type "p" uintptr |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame] | 712 | #pragma varargck type "s" int8* |
| 713 | #pragma varargck type "s" uint8* |
Ken Thompson | 3657061 | 2009-04-09 18:16:21 -0700 | [diff] [blame] | 714 | #pragma varargck type "S" String |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame] | 715 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 716 | void runtime·stoptheworld(void); |
Dmitriy Vyukov | 0182628 | 2012-05-15 19:10:16 +0400 | [diff] [blame] | 717 | void runtime·starttheworld(void); |
Russ Cox | e4b02bf | 2012-02-22 21:45:01 -0500 | [diff] [blame] | 718 | extern uint32 runtime·worldsema; |
Russ Cox | 3f8aa66 | 2008-12-05 15:24:18 -0800 | [diff] [blame] | 719 | |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 720 | /* |
| 721 | * mutual exclusion locks. in the uncontended case, |
| 722 | * as fast as spin locks (just a few user-level instructions), |
| 723 | * but on the contention path they sleep in the kernel. |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 724 | * a zeroed Lock is unlocked (no need to initialize each lock). |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 725 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 726 | void runtime·lock(Lock*); |
| 727 | void runtime·unlock(Lock*); |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 728 | |
| 729 | /* |
Russ Cox | a68592a | 2009-10-14 13:02:05 -0700 | [diff] [blame] | 730 | * sleep and wakeup on one-time events. |
Russ Cox | f7f6329 | 2008-08-05 14:21:42 -0700 | [diff] [blame] | 731 | * before any calls to notesleep or notewakeup, |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 732 | * must call noteclear to initialize the Note. |
Dmitriy Vyukov | a496c9e | 2011-08-03 15:51:55 -0400 | [diff] [blame] | 733 | * then, exactly one thread can call notesleep |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 734 | * and exactly one thread can call notewakeup (once). |
Dmitriy Vyukov | a496c9e | 2011-08-03 15:51:55 -0400 | [diff] [blame] | 735 | * once notewakeup has been called, the notesleep |
| 736 | * will return. future notesleep will return immediately. |
| 737 | * subsequent noteclear must be called only after |
| 738 | * previous notesleep has returned, e.g. it's disallowed |
| 739 | * to call noteclear straight after notewakeup. |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 740 | * |
| 741 | * notetsleep is like notesleep but wakes up after |
| 742 | * a given number of nanoseconds even if the event |
| 743 | * has not yet happened. if a goroutine uses notetsleep to |
| 744 | * wake up early, it must wait to call noteclear until it |
| 745 | * can be sure that no other goroutine is calling |
| 746 | * notewakeup. |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 747 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 748 | void runtime·noteclear(Note*); |
| 749 | void runtime·notesleep(Note*); |
| 750 | void runtime·notewakeup(Note*); |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 751 | void runtime·notetsleep(Note*, int64); |
| 752 | |
| 753 | /* |
| 754 | * low-level synchronization for implementing the above |
| 755 | */ |
| 756 | uintptr runtime·semacreate(void); |
| 757 | int32 runtime·semasleep(int64); |
| 758 | void runtime·semawakeup(M*); |
| 759 | // or |
| 760 | void runtime·futexsleep(uint32*, uint32, int64); |
| 761 | void runtime·futexwakeup(uint32*, uint32); |
Ian Lance Taylor | 9b8da82 | 2009-01-13 09:55:24 -0800 | [diff] [blame] | 762 | |
| 763 | /* |
Dmitriy Vyukov | a5dc779 | 2012-04-12 11:49:25 +0400 | [diff] [blame] | 764 | * Lock-free stack. |
| 765 | * Initialize uint64 head to 0, compare with 0 to test for emptiness. |
| 766 | * The stack does not keep pointers to nodes, |
| 767 | * so they can be garbage collected if there are no other pointers to nodes. |
| 768 | */ |
| 769 | void runtime·lfstackpush(uint64 *head, LFNode *node); |
| 770 | LFNode* runtime·lfstackpop(uint64 *head); |
| 771 | |
| 772 | /* |
Dmitriy Vyukov | 9564364 | 2012-05-11 10:50:03 +0400 | [diff] [blame] | 773 | * Parallel for over [0, n). |
| 774 | * body() is executed for each iteration. |
| 775 | * nthr - total number of worker threads. |
| 776 | * ctx - arbitrary user context. |
| 777 | * if wait=true, threads return from parfor() when all work is done; |
| 778 | * otherwise, threads can return while other threads are still finishing processing. |
| 779 | */ |
| 780 | ParFor* runtime·parforalloc(uint32 nthrmax); |
| 781 | void runtime·parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void (*body)(ParFor*, uint32)); |
| 782 | void runtime·parfordo(ParFor *desc); |
| 783 | |
| 784 | /* |
Adam Langley | 3f7a324 | 2009-11-13 10:08:51 -0800 | [diff] [blame] | 785 | * This is consistent across Linux and BSD. |
| 786 | * If a new OS is added that is different, move this to |
| 787 | * $GOOS/$GOARCH/defs.h. |
| 788 | */ |
| 789 | #define EACCES 13 |
| 790 | |
| 791 | /* |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 792 | * low level C-called |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 793 | */ |
Shenghou Ma | b151af1 | 2012-09-21 13:50:02 +0800 | [diff] [blame] | 794 | // for mmap, we only pass the lower 32 bits of file offset to the |
| 795 | // assembly routine; the higher bits (if required), should be provided |
| 796 | // by the assembly routine as 0. |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 797 | uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32); |
Russ Cox | e83cd7f | 2011-12-20 17:54:40 -0500 | [diff] [blame] | 798 | void runtime·munmap(byte*, uintptr); |
| 799 | void runtime·madvise(byte*, uintptr, int32); |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 800 | void runtime·memclr(byte*, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 801 | void runtime·setcallerpc(void*, void*); |
| 802 | void* runtime·getcallerpc(void*); |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 803 | |
| 804 | /* |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 805 | * runtime go-called |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 806 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 807 | void runtime·printbool(bool); |
| 808 | void runtime·printfloat(float64); |
| 809 | void runtime·printint(int64); |
| 810 | void runtime·printiface(Iface); |
| 811 | void runtime·printeface(Eface); |
| 812 | void runtime·printstring(String); |
| 813 | void runtime·printpc(void*); |
| 814 | void runtime·printpointer(void*); |
| 815 | void runtime·printuint(uint64); |
| 816 | void runtime·printhex(uint64); |
| 817 | void runtime·printslice(Slice); |
| 818 | void runtime·printcomplex(Complex128); |
Russ Cox | 4e28cfe | 2010-03-26 14:15:30 -0700 | [diff] [blame] | 819 | void reflect·call(byte*, byte*, uint32); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 820 | void runtime·panic(Eface); |
| 821 | void runtime·panicindex(void); |
| 822 | void runtime·panicslice(void); |
Russ Cox | 7c2b159 | 2010-10-25 17:55:50 -0700 | [diff] [blame] | 823 | |
Russ Cox | 63e878a | 2010-03-31 15:55:10 -0700 | [diff] [blame] | 824 | /* |
| 825 | * runtime c-called (but written in Go) |
| 826 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 827 | void runtime·printany(Eface); |
Russ Cox | 6a75ece | 2012-02-12 23:26:20 -0500 | [diff] [blame] | 828 | void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 829 | void runtime·newErrorString(String, Eface*); |
| 830 | void runtime·fadd64c(uint64, uint64, uint64*); |
| 831 | void runtime·fsub64c(uint64, uint64, uint64*); |
| 832 | void runtime·fmul64c(uint64, uint64, uint64*); |
| 833 | void runtime·fdiv64c(uint64, uint64, uint64*); |
| 834 | void runtime·fneg64c(uint64, uint64*); |
| 835 | void runtime·f32to64c(uint32, uint64*); |
| 836 | void runtime·f64to32c(uint64, uint32*); |
| 837 | void runtime·fcmp64c(uint64, uint64, int32*, bool*); |
| 838 | void runtime·fintto64c(int64, uint64*); |
| 839 | void runtime·f64tointc(uint64, int64*, bool*); |
Rob Pike | 6db99de | 2008-07-08 10:36:43 -0700 | [diff] [blame] | 840 | |
| 841 | /* |
Russ Cox | 1f8a40d | 2009-01-22 16:23:44 -0800 | [diff] [blame] | 842 | * wrapped for go users |
Rob Pike | 6db99de | 2008-07-08 10:36:43 -0700 | [diff] [blame] | 843 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 844 | float64 runtime·Inf(int32 sign); |
| 845 | float64 runtime·NaN(void); |
| 846 | float32 runtime·float32frombits(uint32 i); |
| 847 | uint32 runtime·float32tobits(float32 f); |
| 848 | float64 runtime·float64frombits(uint64 i); |
| 849 | uint64 runtime·float64tobits(float64 f); |
| 850 | float64 runtime·frexp(float64 d, int32 *ep); |
| 851 | bool runtime·isInf(float64 f, int32 sign); |
| 852 | bool runtime·isNaN(float64 f); |
| 853 | float64 runtime·ldexp(float64 d, int32 e); |
| 854 | float64 runtime·modf(float64 d, float64 *ip); |
| 855 | void runtime·semacquire(uint32*); |
| 856 | void runtime·semrelease(uint32*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 857 | int32 runtime·gomaxprocsfunc(int32 n); |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 858 | void runtime·procyield(uint32); |
| 859 | void runtime·osyield(void); |
Russ Cox | 6808da0 | 2011-10-27 18:04:12 -0700 | [diff] [blame] | 860 | void runtime·LockOSThread(void); |
| 861 | void runtime·UnlockOSThread(void); |
David Symonds | b586649 | 2009-12-15 18:21:29 -0800 | [diff] [blame] | 862 | |
Russ Cox | 65bde08 | 2011-08-17 14:56:27 -0400 | [diff] [blame] | 863 | void runtime·mapassign(MapType*, Hmap*, byte*, byte*); |
| 864 | void runtime·mapaccess(MapType*, Hmap*, byte*, byte*, bool*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 865 | void runtime·mapiternext(struct hash_iter*); |
| 866 | bool runtime·mapiterkey(struct hash_iter*, void*); |
| 867 | void runtime·mapiterkeyvalue(struct hash_iter*, void*, void*); |
Russ Cox | 65bde08 | 2011-08-17 14:56:27 -0400 | [diff] [blame] | 868 | Hmap* runtime·makemap_c(MapType*, int64); |
Russ Cox | 5ddaf9a | 2009-07-08 15:00:54 -0700 | [diff] [blame] | 869 | |
Russ Cox | 3770b0e | 2011-08-17 15:54:17 -0400 | [diff] [blame] | 870 | Hchan* runtime·makechan_c(ChanType*, int64); |
Dmitriy Vyukov | 2f6cbc7 | 2012-10-07 22:05:32 +0400 | [diff] [blame] | 871 | void runtime·chansend(ChanType*, Hchan*, byte*, bool*, void*); |
Russ Cox | 33e9d24 | 2011-08-23 13:13:27 -0400 | [diff] [blame] | 872 | void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*); |
Dmitriy Vyukov | 81221f5 | 2013-01-29 14:57:11 +0400 | [diff] [blame] | 873 | bool runtime·showframe(Func*, bool); |
Russ Cox | 5ddaf9a | 2009-07-08 15:00:54 -0700 | [diff] [blame] | 874 | |
Jan Ziak | 5c1422a | 2012-11-01 13:13:20 -0400 | [diff] [blame] | 875 | void runtime·ifaceE2I(InterfaceType*, Eface, Iface*); |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 876 | |
Russ Cox | 102274a | 2012-02-24 15:28:51 -0500 | [diff] [blame] | 877 | uintptr runtime·memlimit(void); |
Russ Cox | 6e2ae0a | 2012-02-28 16:18:24 -0500 | [diff] [blame] | 878 | |
| 879 | // If appropriate, ask the operating system to control whether this |
| 880 | // thread should receive profiling signals. This is only necessary on OS X. |
| 881 | // An operating system should not deliver a profiling signal to a |
| 882 | // thread that is not actually executing (what good is that?), but that's |
| 883 | // what OS X prefers to do. When profiling is turned on, we mask |
| 884 | // away the profiling signal when threads go to sleep, so that OS X |
| 885 | // is forced to deliver the signal to a thread that's actually running. |
| 886 | // This is a no-op on other systems. |
| 887 | void runtime·setprof(bool); |
Shenghou Ma | 0157c72 | 2012-08-07 23:45:50 +0800 | [diff] [blame] | 888 | |
| 889 | // float.c |
| 890 | extern float64 runtime·nan; |
| 891 | extern float64 runtime·posinf; |
| 892 | extern float64 runtime·neginf; |
| 893 | extern uint64 ·nan; |
| 894 | extern uint64 ·posinf; |
| 895 | extern uint64 ·neginf; |
| 896 | #define ISNAN(f) ((f) != (f)) |
Jan Ziak | f8c5837 | 2012-09-24 20:08:05 -0400 | [diff] [blame] | 897 | |
| 898 | enum |
| 899 | { |
| 900 | UseSpanType = 1, |
| 901 | }; |