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 | d617454 | 2013-04-06 20:07:07 -0700 | [diff] [blame] | 53 | typedef struct Lock Lock; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 54 | typedef struct M M; |
Russ Cox | c5f694a | 2013-03-01 08:30:11 -0500 | [diff] [blame] | 55 | typedef struct P P; |
Dmitriy Vyukov | 58030c5 | 2013-04-06 20:09:02 -0700 | [diff] [blame] | 56 | typedef struct 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 | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 60 | typedef struct FuncVal FuncVal; |
Russ Cox | c3077f7 | 2008-12-19 17:11:54 -0800 | [diff] [blame] | 61 | typedef struct SigTab SigTab; |
| 62 | typedef struct MCache MCache; |
Russ Cox | d324f21 | 2011-09-30 09:40:01 -0400 | [diff] [blame] | 63 | typedef struct FixAlloc FixAlloc; |
Russ Cox | c3077f7 | 2008-12-19 17:11:54 -0800 | [diff] [blame] | 64 | typedef struct Iface Iface; |
Russ Cox | c7513ea | 2009-07-07 11:02:54 -0700 | [diff] [blame] | 65 | typedef struct Itab Itab; |
Jan Ziak | 5c1422a | 2012-11-01 13:13:20 -0400 | [diff] [blame] | 66 | typedef struct InterfaceType InterfaceType; |
Ken Thompson | f59cb49 | 2010-02-19 20:42:50 -0800 | [diff] [blame] | 67 | typedef struct Eface Eface; |
Russ Cox | c7513ea | 2009-07-07 11:02:54 -0700 | [diff] [blame] | 68 | typedef struct Type Type; |
Russ Cox | 3770b0e | 2011-08-17 15:54:17 -0400 | [diff] [blame] | 69 | typedef struct ChanType ChanType; |
Russ Cox | 65bde08 | 2011-08-17 14:56:27 -0400 | [diff] [blame] | 70 | typedef struct MapType MapType; |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 71 | typedef struct Defer Defer; |
Russ Cox | 0de7161 | 2012-12-22 14:54:39 -0500 | [diff] [blame] | 72 | typedef struct DeferChunk DeferChunk; |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 73 | typedef struct Panic Panic; |
Luuk van Dijk | 7400be8 | 2011-01-31 12:27:28 +0100 | [diff] [blame] | 74 | typedef struct Hmap Hmap; |
Russ Cox | 5ddaf9a | 2009-07-08 15:00:54 -0700 | [diff] [blame] | 75 | typedef struct Hchan Hchan; |
Ken Thompson | f59cb49 | 2010-02-19 20:42:50 -0800 | [diff] [blame] | 76 | typedef struct Complex64 Complex64; |
| 77 | typedef struct Complex128 Complex128; |
Alex Brainman | 2a80882 | 2011-08-27 23:17:00 +1000 | [diff] [blame] | 78 | typedef struct WinCall WinCall; |
Alex Brainman | afe0e97 | 2012-05-30 15:10:54 +1000 | [diff] [blame] | 79 | typedef struct SEH SEH; |
Alex Brainman | 05a5de3 | 2013-06-24 17:17:45 +1000 | [diff] [blame] | 80 | typedef struct WinCallbackContext WinCallbackContext; |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 81 | typedef struct Timers Timers; |
| 82 | typedef struct Timer Timer; |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 83 | typedef struct GCStats GCStats; |
| 84 | typedef struct LFNode LFNode; |
| 85 | typedef struct ParFor ParFor; |
| 86 | typedef struct ParForThread ParForThread; |
| 87 | typedef struct CgoMal CgoMal; |
Dmitriy Vyukov | 0bee99a | 2013-03-14 10:38:37 +0400 | [diff] [blame] | 88 | typedef struct PollDesc PollDesc; |
Dmitriy Vyukov | 4b536a5 | 2013-06-28 18:37:06 +0400 | [diff] [blame] | 89 | typedef struct DebugVars DebugVars; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 90 | |
| 91 | /* |
Nigel Tao | 90ad6a2 | 2012-10-19 11:02:32 +1100 | [diff] [blame] | 92 | * Per-CPU declaration. |
| 93 | * |
Rob Pike | d08f006 | 2009-08-11 13:30:35 -0700 | [diff] [blame] | 94 | * "extern register" is a special storage class implemented by 6c, 8c, etc. |
Nigel Tao | 90ad6a2 | 2012-10-19 11:02:32 +1100 | [diff] [blame] | 95 | * On the ARM, it is an actual register; elsewhere it is a slot in thread- |
| 96 | * local storage indexed by a segment register. See zasmhdr in |
| 97 | * src/cmd/dist/buildruntime.c for details, and be aware that the linker may |
| 98 | * make further OS-specific changes to the compiler's output. For example, |
| 99 | * 6l/linux rewrites 0(GS) as -16(FS). |
Rob Pike | d08f006 | 2009-08-11 13:30:35 -0700 | [diff] [blame] | 100 | * |
Nigel Tao | 90ad6a2 | 2012-10-19 11:02:32 +1100 | [diff] [blame] | 101 | * Every C file linked into a Go program must include runtime.h so that the |
| 102 | * C compiler (6c, 8c, etc.) knows to avoid other uses of these dedicated |
| 103 | * registers. The Go compiler (6g, 8g, etc.) knows to avoid them. |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 104 | */ |
Rob Pike | d08f006 | 2009-08-11 13:30:35 -0700 | [diff] [blame] | 105 | extern register G* g; |
| 106 | extern register M* m; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 107 | |
| 108 | /* |
| 109 | * defined constants |
| 110 | */ |
| 111 | enum |
| 112 | { |
| 113 | // G status |
Russ Cox | 72157c3 | 2010-04-08 13:24:53 -0700 | [diff] [blame] | 114 | // |
| 115 | // If you add to this list, add to the list |
| 116 | // of "okay during garbage collection" status |
| 117 | // in mgc0.c too. |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 118 | Gidle, |
| 119 | Grunnable, |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 120 | Grunning, |
Russ Cox | 3f8aa66 | 2008-12-05 15:24:18 -0800 | [diff] [blame] | 121 | Gsyscall, |
Ken Thompson | 5262003 | 2008-07-14 14:33:39 -0700 | [diff] [blame] | 122 | Gwaiting, |
Dmitriy Vyukov | 779c45a | 2013-03-01 13:49:16 +0200 | [diff] [blame] | 123 | Gmoribund_unused, // currently unused, but hardcoded in gdb scripts |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 124 | Gdead, |
| 125 | }; |
| 126 | enum |
| 127 | { |
Dmitriy Vyukov | 779c45a | 2013-03-01 13:49:16 +0200 | [diff] [blame] | 128 | // P status |
| 129 | Pidle, |
| 130 | Prunning, |
| 131 | Psyscall, |
| 132 | Pgcstop, |
| 133 | Pdead, |
| 134 | }; |
| 135 | enum |
| 136 | { |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 137 | true = 1, |
| 138 | false = 0, |
| 139 | }; |
Jan Ziak | 5419368 | 2012-09-17 17:18:21 -0400 | [diff] [blame] | 140 | enum |
| 141 | { |
| 142 | PtrSize = sizeof(void*), |
| 143 | }; |
Dmitriy Vyukov | f82db7d | 2013-01-10 09:57:06 +0400 | [diff] [blame] | 144 | enum |
| 145 | { |
| 146 | // Per-M stack segment cache size. |
| 147 | StackCacheSize = 32, |
| 148 | // Global <-> per-M stack segment cache transfer batch size. |
| 149 | StackCacheBatch = 16, |
| 150 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 151 | /* |
| 152 | * structures |
| 153 | */ |
Dmitriy Vyukov | d617454 | 2013-04-06 20:07:07 -0700 | [diff] [blame] | 154 | struct Lock |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 155 | { |
Dmitriy Vyukov | d617454 | 2013-04-06 20:07:07 -0700 | [diff] [blame] | 156 | // Futex-based impl treats it as uint32 key, |
| 157 | // while sema-based impl as M* waitm. |
| 158 | // Used to be a union, but unions break precise GC. |
| 159 | uintptr key; |
Russ Cox | 5ff12f8 | 2008-09-24 10:25:28 -0700 | [diff] [blame] | 160 | }; |
Dmitriy Vyukov | 58030c5 | 2013-04-06 20:09:02 -0700 | [diff] [blame] | 161 | struct Note |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 162 | { |
Dmitriy Vyukov | 58030c5 | 2013-04-06 20:09:02 -0700 | [diff] [blame] | 163 | // Futex-based impl treats it as uint32 key, |
| 164 | // while sema-based impl as M* waitm. |
| 165 | // Used to be a union, but unions break precise GC. |
| 166 | uintptr key; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 167 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 168 | struct String |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 169 | { |
Ken Thompson | 3657061 | 2009-04-09 18:16:21 -0700 | [diff] [blame] | 170 | byte* str; |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 171 | intgo len; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 172 | }; |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 173 | struct FuncVal |
| 174 | { |
| 175 | void (*fn)(void); |
| 176 | // variable-size, fn-specific data here |
| 177 | }; |
Russ Cox | c3077f7 | 2008-12-19 17:11:54 -0800 | [diff] [blame] | 178 | struct Iface |
| 179 | { |
Russ Cox | c7513ea | 2009-07-07 11:02:54 -0700 | [diff] [blame] | 180 | Itab* tab; |
Ken Thompson | 3657061 | 2009-04-09 18:16:21 -0700 | [diff] [blame] | 181 | void* data; |
Russ Cox | c3077f7 | 2008-12-19 17:11:54 -0800 | [diff] [blame] | 182 | }; |
Russ Cox | 2da5022 | 2009-05-20 14:57:55 -0700 | [diff] [blame] | 183 | struct Eface |
| 184 | { |
Russ Cox | c7513ea | 2009-07-07 11:02:54 -0700 | [diff] [blame] | 185 | Type* type; |
Russ Cox | 2da5022 | 2009-05-20 14:57:55 -0700 | [diff] [blame] | 186 | void* data; |
| 187 | }; |
Ken Thompson | f59cb49 | 2010-02-19 20:42:50 -0800 | [diff] [blame] | 188 | struct Complex64 |
| 189 | { |
| 190 | float32 real; |
| 191 | float32 imag; |
| 192 | }; |
| 193 | struct Complex128 |
| 194 | { |
| 195 | float64 real; |
| 196 | float64 imag; |
| 197 | }; |
Ken Thompson | 66a603c | 2008-08-27 17:28:30 -0700 | [diff] [blame] | 198 | |
Rob Pike | 87f2208 | 2009-08-25 15:54:25 -0700 | [diff] [blame] | 199 | struct Slice |
Ken Thompson | 66a603c | 2008-08-27 17:28:30 -0700 | [diff] [blame] | 200 | { // must not move anything |
| 201 | byte* array; // actual data |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 202 | uintgo len; // number of elements |
| 203 | uintgo cap; // allocated number of elements |
Ken Thompson | 66a603c | 2008-08-27 17:28:30 -0700 | [diff] [blame] | 204 | }; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 205 | struct Gobuf |
| 206 | { |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 207 | // The offsets of sp, pc, and g are known to (hard-coded in) libmach. |
Jan Ziak | 334bf95 | 2012-05-30 13:07:52 -0400 | [diff] [blame] | 208 | uintptr sp; |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 209 | uintptr pc; |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 210 | G* g; |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 211 | uintptr ret; |
| 212 | void* ctxt; |
| 213 | uintptr lr; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 214 | }; |
Dmitriy Vyukov | d839a80 | 2012-04-05 20:48:28 +0400 | [diff] [blame] | 215 | struct GCStats |
| 216 | { |
| 217 | // the struct must consist of only uint64's, |
| 218 | // because it is casted to uint64[]. |
| 219 | uint64 nhandoff; |
| 220 | uint64 nhandoffcnt; |
| 221 | uint64 nprocyield; |
| 222 | uint64 nosyield; |
| 223 | uint64 nsleep; |
| 224 | }; |
Dmitriy Vyukov | e84d9e1 | 2013-07-29 22:22:34 +0400 | [diff] [blame] | 225 | |
| 226 | struct WinCall |
| 227 | { |
| 228 | void (*fn)(void*); |
| 229 | uintptr n; // number of parameters |
| 230 | void* args; // parameters |
| 231 | uintptr r1; // return values |
| 232 | uintptr r2; |
| 233 | uintptr err; // error number |
| 234 | }; |
| 235 | struct SEH |
| 236 | { |
| 237 | void* prev; |
| 238 | void* handler; |
| 239 | }; |
| 240 | // describes how to handle callback |
| 241 | struct WinCallbackContext |
| 242 | { |
| 243 | void* gobody; // Go function to call |
| 244 | uintptr argsize; // callback arguments size (in bytes) |
| 245 | uintptr restorestack; // adjust stack on return by (in bytes) (386 only) |
| 246 | }; |
| 247 | |
Ken Thompson | 7b454bb | 2008-07-09 11:35:26 -0700 | [diff] [blame] | 248 | struct G |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 249 | { |
Dmitriy Vyukov | f5becf4 | 2013-06-03 12:28:24 +0400 | [diff] [blame] | 250 | // stackguard0 can be set to StackPreempt as opposed to stackguard |
| 251 | uintptr stackguard0; // cannot move - also known to linker, libmach, runtime/cgo |
Jan Ziak | 334bf95 | 2012-05-30 13:07:52 -0400 | [diff] [blame] | 252 | uintptr stackbase; // cannot move - also known to libmach, runtime/cgo |
Russ Cox | 7276c02 | 2013-09-12 14:00:16 -0400 | [diff] [blame] | 253 | uint32 panicwrap; // cannot move - also known to linker |
| 254 | uint32 selgen; // valid sudog pointer |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 255 | Defer* defer; |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 256 | Panic* panic; |
| 257 | Gobuf sched; |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 258 | uintptr syscallstack; // if status==Gsyscall, syscallstack = stackbase to use during gc |
| 259 | uintptr syscallsp; // if status==Gsyscall, syscallsp = sched.sp to use during gc |
| 260 | uintptr syscallpc; // if status==Gsyscall, syscallpc = sched.pc to use during gc |
| 261 | uintptr syscallguard; // if status==Gsyscall, syscallguard = stackguard to use during gc |
Dmitriy Vyukov | f5becf4 | 2013-06-03 12:28:24 +0400 | [diff] [blame] | 262 | uintptr stackguard; // same as stackguard0, but not set to StackPreempt |
Jan Ziak | 334bf95 | 2012-05-30 13:07:52 -0400 | [diff] [blame] | 263 | uintptr stack0; |
Russ Cox | 757e0de | 2013-08-15 22:34:06 -0400 | [diff] [blame] | 264 | uintptr stacksize; |
Rob Pike | 3835e01 | 2008-07-28 11:29:41 -0700 | [diff] [blame] | 265 | G* alllink; // on allg |
Ken Thompson | e963cba | 2008-07-25 15:55:12 -0700 | [diff] [blame] | 266 | void* param; // passed parameter on wakeup |
| 267 | int16 status; |
Dmitriy Vyukov | 320df44 | 2012-10-26 10:13:06 +0400 | [diff] [blame] | 268 | int64 goid; |
Russ Cox | 03e9ea5 | 2011-08-22 23:26:39 -0400 | [diff] [blame] | 269 | int8* waitreason; // if status==Gwaiting |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 270 | G* schedlink; |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 271 | bool ispanic; |
Dmitriy Vyukov | 6ee739d | 2013-03-12 17:21:44 +0400 | [diff] [blame] | 272 | bool issystem; // do not output in stack dump |
| 273 | bool isbackground; // ignore in deadlock detector |
Dmitriy Vyukov | 5887f14 | 2013-07-17 12:52:37 -0400 | [diff] [blame] | 274 | bool preempt; // preemption signal, duplicates stackguard0 = StackPreempt |
Dmitriy Vyukov | 6ee739d | 2013-03-12 17:21:44 +0400 | [diff] [blame] | 275 | int8 raceignore; // ignore race detection events |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 276 | M* m; // for debuggers, but offset not hard-coded |
Russ Cox | 218c393 | 2009-07-13 17:28:39 -0700 | [diff] [blame] | 277 | M* lockedm; |
Russ Cox | 5963dba | 2010-04-08 18:15:30 -0700 | [diff] [blame] | 278 | int32 sig; |
Russ Cox | e4b02bf | 2012-02-22 21:45:01 -0500 | [diff] [blame] | 279 | int32 writenbuf; |
| 280 | byte* writebuf; |
Dmitriy Vyukov | 3d6bce4 | 2013-07-30 23:48:18 +0400 | [diff] [blame] | 281 | DeferChunk* dchunk; |
| 282 | DeferChunk* dchunknext; |
Russ Cox | 5963dba | 2010-04-08 18:15:30 -0700 | [diff] [blame] | 283 | uintptr sigcode0; |
| 284 | uintptr sigcode1; |
Russ Cox | 1230700 | 2011-01-18 14:15:11 -0500 | [diff] [blame] | 285 | uintptr sigpc; |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 286 | uintptr gopc; // pc of go statement that created this goroutine |
Dmitriy Vyukov | 0a40cd2 | 2013-02-06 11:40:54 +0400 | [diff] [blame] | 287 | uintptr racectx; |
Hector Chu | 9fd2687 | 2011-09-17 17:57:59 +1000 | [diff] [blame] | 288 | uintptr end[]; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 289 | }; |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 290 | struct M |
| 291 | { |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 292 | G* g0; // goroutine with scheduling stack |
Russ Cox | 141a4a1 | 2011-01-14 14:05:20 -0500 | [diff] [blame] | 293 | void* moreargp; // argument pointer for more stack |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 294 | Gobuf morebuf; // gobuf arg to morestack |
| 295 | |
Russ Cox | 3802009 | 2009-06-17 16:31:02 -0700 | [diff] [blame] | 296 | // Fields not known to debuggers. |
Russ Cox | 141a4a1 | 2011-01-14 14:05:20 -0500 | [diff] [blame] | 297 | uint32 moreframesize; // size arguments to morestack |
| 298 | uint32 moreargsize; |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 299 | uintptr cret; // return value from C |
| 300 | uint64 procid; // for debuggers, but offset not hard-coded |
| 301 | G* gsignal; // signal-handling G |
Russ Cox | d0d7416 | 2013-03-01 09:24:17 -0500 | [diff] [blame] | 302 | uintptr tls[4]; // thread-local storage (for x86 extern register) |
| 303 | void (*mstartfn)(void); |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 304 | G* curg; // current running goroutine |
Russ Cox | 6fa3c89 | 2013-06-27 11:32:01 -0400 | [diff] [blame] | 305 | G* caughtsig; // goroutine running during fatal signal |
Dmitriy Vyukov | 779c45a | 2013-03-01 13:49:16 +0200 | [diff] [blame] | 306 | P* p; // attached P for executing Go code (nil if not executing Go code) |
| 307 | P* nextp; |
Russ Cox | efc86a7 | 2008-11-25 16:48:10 -0800 | [diff] [blame] | 308 | int32 id; |
Russ Cox | da0a7d7 | 2008-12-19 03:13:39 -0800 | [diff] [blame] | 309 | int32 mallocing; |
Dmitriy Vyukov | 81221f5 | 2013-01-29 14:57:11 +0400 | [diff] [blame] | 310 | int32 throwing; |
Russ Cox | 8c357ce | 2009-06-15 21:31:56 -0700 | [diff] [blame] | 311 | int32 gcing; |
Russ Cox | 1ce1791 | 2009-01-26 17:37:05 -0800 | [diff] [blame] | 312 | int32 locks; |
Russ Cox | 6eb251f | 2010-03-24 09:40:09 -0700 | [diff] [blame] | 313 | int32 nomemprof; |
Russ Cox | 6779350 | 2011-02-16 13:21:13 -0500 | [diff] [blame] | 314 | int32 dying; |
Russ Cox | c19b373 | 2011-03-23 11:43:37 -0400 | [diff] [blame] | 315 | int32 profilehz; |
Russ Cox | d324f21 | 2011-09-30 09:40:01 -0400 | [diff] [blame] | 316 | int32 helpgc; |
Dmitriy Vyukov | 779c45a | 2013-03-01 13:49:16 +0200 | [diff] [blame] | 317 | bool spinning; |
Dmitriy Vyukov | 909f318 | 2011-07-12 01:23:58 -0400 | [diff] [blame] | 318 | uint32 fastrand; |
Ian Lance Taylor | e9a3087 | 2012-11-10 11:19:06 -0800 | [diff] [blame] | 319 | uint64 ncgocall; // number of cgo calls in total |
| 320 | int32 ncgo; // number of cgo calls currently in progress |
| 321 | CgoMal* cgomal; |
Dmitriy Vyukov | 779c45a | 2013-03-01 13:49:16 +0200 | [diff] [blame] | 322 | Note park; |
Russ Cox | 93689d8 | 2009-10-09 15:35:33 -0700 | [diff] [blame] | 323 | M* alllink; // on allm |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 324 | M* schedlink; |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 325 | uint32 machport; // Return address for Mach IPC (OS X) |
Dmitriy Vyukov | 3d6bce4 | 2013-07-30 23:48:18 +0400 | [diff] [blame] | 326 | MCache* mcache; |
Dmitriy Vyukov | f82db7d | 2013-01-10 09:57:06 +0400 | [diff] [blame] | 327 | int32 stackinuse; |
| 328 | uint32 stackcachepos; |
| 329 | uint32 stackcachecnt; |
| 330 | void* stackcache[StackCacheSize]; |
Russ Cox | 218c393 | 2009-07-13 17:28:39 -0700 | [diff] [blame] | 331 | G* lockedg; |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 332 | uintptr createstack[32];// Stack that created this thread. |
Ken Thompson | ae60526 | 2010-12-09 14:45:27 -0800 | [diff] [blame] | 333 | uint32 freglo[16]; // D[i] lsb and F[i] |
| 334 | uint32 freghi[16]; // D[i] msb and F[i+16] |
| 335 | uint32 fflag; // floating point compare flags |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 336 | uint32 locked; // tracking for LockOSThread |
Dmitriy Vyukov | ee24bfc | 2011-11-02 16:42:01 +0300 | [diff] [blame] | 337 | M* nextwaitm; // next M waiting for lock |
| 338 | uintptr waitsema; // semaphore for parking on locks |
| 339 | uint32 waitsemacount; |
| 340 | uint32 waitsemalock; |
Dmitriy Vyukov | d839a80 | 2012-04-05 20:48:28 +0400 | [diff] [blame] | 341 | GCStats gcstats; |
Dmitriy Vyukov | 2f6cbc7 | 2012-10-07 22:05:32 +0400 | [diff] [blame] | 342 | bool racecall; |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 343 | bool needextram; |
Dmitriy Vyukov | 779c45a | 2013-03-01 13:49:16 +0200 | [diff] [blame] | 344 | void (*waitunlockf)(Lock*); |
Dmitriy Vyukov | 54340bf | 2013-04-06 20:01:28 -0700 | [diff] [blame] | 345 | void* waitlock; |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 346 | |
Jan Ziak | f8c5837 | 2012-09-24 20:08:05 -0400 | [diff] [blame] | 347 | uintptr settype_buf[1024]; |
| 348 | uintptr settype_bufsize; |
| 349 | |
Russ Cox | 851f301 | 2011-12-16 15:33:58 -0500 | [diff] [blame] | 350 | #ifdef GOOS_windows |
Hector Chu | 9fd2687 | 2011-09-17 17:57:59 +1000 | [diff] [blame] | 351 | void* thread; // thread handle |
Dmitriy Vyukov | e84d9e1 | 2013-07-29 22:22:34 +0400 | [diff] [blame] | 352 | WinCall wincall; |
Hector Chu | 5c30325 | 2011-09-14 20:23:21 -0400 | [diff] [blame] | 353 | #endif |
Akshat Kumar | c74f3c4 | 2013-01-30 02:53:56 -0800 | [diff] [blame] | 354 | #ifdef GOOS_plan9 |
Dmitriy Vyukov | 3d6bce4 | 2013-07-30 23:48:18 +0400 | [diff] [blame] | 355 | int8* notesig; |
Akshat Kumar | a566dea | 2013-03-08 00:54:44 +0100 | [diff] [blame] | 356 | byte* errstr; |
Akshat Kumar | c74f3c4 | 2013-01-30 02:53:56 -0800 | [diff] [blame] | 357 | #endif |
Alex Brainman | afe0e97 | 2012-05-30 15:10:54 +1000 | [diff] [blame] | 358 | SEH* seh; |
Hector Chu | 9fd2687 | 2011-09-17 17:57:59 +1000 | [diff] [blame] | 359 | uintptr end[]; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 360 | }; |
Russ Cox | 370276a | 2011-04-27 23:21:12 -0400 | [diff] [blame] | 361 | |
Dmitriy Vyukov | 353ce60 | 2013-02-23 08:48:02 +0400 | [diff] [blame] | 362 | struct P |
| 363 | { |
| 364 | Lock; |
| 365 | |
Dmitriy Vyukov | 4f2e382 | 2013-08-14 00:30:55 +0400 | [diff] [blame] | 366 | int32 id; |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 367 | uint32 status; // one of Pidle/Prunning/... |
Dmitriy Vyukov | 6cdfb00 | 2013-02-27 21:17:53 +0200 | [diff] [blame] | 368 | P* link; |
Dmitriy Vyukov | f9066fe | 2013-08-13 22:14:04 +0400 | [diff] [blame] | 369 | uint32 schedtick; // incremented on every scheduler call |
| 370 | uint32 syscalltick; // incremented on every system call |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 371 | M* m; // back-link to associated M (nil if idle) |
Dmitriy Vyukov | 779c45a | 2013-03-01 13:49:16 +0200 | [diff] [blame] | 372 | MCache* mcache; |
Dmitriy Vyukov | 6cdfb00 | 2013-02-27 21:17:53 +0200 | [diff] [blame] | 373 | |
Dmitriy Vyukov | 353ce60 | 2013-02-23 08:48:02 +0400 | [diff] [blame] | 374 | // Queue of runnable goroutines. |
| 375 | G** runq; |
| 376 | int32 runqhead; |
| 377 | int32 runqtail; |
| 378 | int32 runqsize; |
Dmitriy Vyukov | 6cdfb00 | 2013-02-27 21:17:53 +0200 | [diff] [blame] | 379 | |
| 380 | // Available G's (status == Gdead) |
| 381 | G* gfree; |
| 382 | int32 gfreecnt; |
| 383 | |
| 384 | byte pad[64]; |
Dmitriy Vyukov | 353ce60 | 2013-02-23 08:48:02 +0400 | [diff] [blame] | 385 | }; |
| 386 | |
Dmitriy Vyukov | 2713456 | 2013-07-22 16:37:31 +0400 | [diff] [blame] | 387 | // The m->locked word holds two pieces of state counting active calls to LockOSThread/lockOSThread. |
| 388 | // The low bit (LockExternal) is a boolean reporting whether any LockOSThread call is active. |
| 389 | // External locks are not recursive; a second lock is silently ignored. |
| 390 | // The upper bits of m->lockedcount record the nesting depth of calls to lockOSThread |
| 391 | // (counting up by LockInternal), popped by unlockOSThread (counting down by LockInternal). |
| 392 | // Internal locks can be recursive. For instance, a lock for cgo can occur while the main |
| 393 | // goroutine is holding the lock during the initialization phase. |
Russ Cox | b0a29f3 | 2013-02-01 08:34:41 -0800 | [diff] [blame] | 394 | enum |
| 395 | { |
| 396 | LockExternal = 1, |
| 397 | LockInternal = 2, |
| 398 | }; |
| 399 | |
Ken Thompson | 5262003 | 2008-07-14 14:33:39 -0700 | [diff] [blame] | 400 | struct Stktop |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 401 | { |
Russ Cox | 3802009 | 2009-06-17 16:31:02 -0700 | [diff] [blame] | 402 | // The offsets of these fields are known to (hard-coded in) libmach. |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 403 | uintptr stackguard; |
| 404 | uintptr stackbase; |
Russ Cox | 7343e03 | 2009-06-17 15:12:16 -0700 | [diff] [blame] | 405 | Gobuf gobuf; |
Russ Cox | 141a4a1 | 2011-01-14 14:05:20 -0500 | [diff] [blame] | 406 | uint32 argsize; |
Russ Cox | 7276c02 | 2013-09-12 14:00:16 -0400 | [diff] [blame] | 407 | uint32 panicwrap; |
Russ Cox | bba278a | 2009-07-08 18:16:09 -0700 | [diff] [blame] | 408 | |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 409 | uint8* argp; // pointer to arguments in old frame |
| 410 | uintptr free; // if free>0, call stackfree using free as size |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 411 | bool panic; // is this frame the top of a panic? |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 412 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 413 | struct SigTab |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 414 | { |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 415 | int32 flags; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 416 | int8 *name; |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 417 | }; |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 418 | enum |
| 419 | { |
Russ Cox | 35586f7 | 2012-02-13 13:52:37 -0500 | [diff] [blame] | 420 | SigNotify = 1<<0, // let signal.Notify have signal, even if from kernel |
David Symonds | 3d8ebef | 2012-02-17 14:36:40 +1100 | [diff] [blame] | 421 | SigKill = 1<<1, // if signal.Notify doesn't take it, exit quietly |
| 422 | SigThrow = 1<<2, // if signal.Notify doesn't take it, exit loudly |
| 423 | SigPanic = 1<<3, // if the signal is from the kernel, panic |
| 424 | SigDefault = 1<<4, // if the signal isn't explicitly requested, don't monitor it |
Russ Cox | cb4428e | 2013-03-15 00:00:02 -0400 | [diff] [blame] | 425 | SigHandling = 1<<5, // our signal handler is registered |
| 426 | SigIgnored = 1<<6, // the signal was ignored before we registered for it |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 427 | }; |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 428 | |
Russ Cox | c3de91b | 2013-07-18 10:43:22 -0400 | [diff] [blame] | 429 | // Layout of in-memory per-function information prepared by linker |
Russ Cox | 5d363c6 | 2013-07-16 09:41:38 -0400 | [diff] [blame] | 430 | // See http://golang.org/s/go12symtab. |
Russ Cox | c3de91b | 2013-07-18 10:43:22 -0400 | [diff] [blame] | 431 | // Keep in sync with linker and with ../../libmach/sym.c |
| 432 | // and with package debug/gosym. |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 433 | struct Func |
| 434 | { |
Russ Cox | 5d363c6 | 2013-07-16 09:41:38 -0400 | [diff] [blame] | 435 | uintptr entry; // start pc |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 436 | int32 nameoff;// function name |
Russ Cox | 5d363c6 | 2013-07-16 09:41:38 -0400 | [diff] [blame] | 437 | |
Carl Shapiro | f466617 | 2013-02-21 12:52:26 -0800 | [diff] [blame] | 438 | int32 args; // in/out args size |
Russ Cox | 5d363c6 | 2013-07-16 09:41:38 -0400 | [diff] [blame] | 439 | int32 frame; // legacy frame size; use pcsp if possible |
Russ Cox | 5d363c6 | 2013-07-16 09:41:38 -0400 | [diff] [blame] | 440 | |
| 441 | int32 pcsp; |
| 442 | int32 pcfile; |
| 443 | int32 pcln; |
| 444 | int32 npcdata; |
| 445 | int32 nfuncdata; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 446 | }; |
| 447 | |
Jan Ziak | 5c1422a | 2012-11-01 13:13:20 -0400 | [diff] [blame] | 448 | // layout of Itab known to compilers |
Dmitriy Vyukov | b36f2db | 2013-06-09 21:58:35 +0400 | [diff] [blame] | 449 | // allocated in non-garbage-collected memory |
Jan Ziak | 5c1422a | 2012-11-01 13:13:20 -0400 | [diff] [blame] | 450 | struct Itab |
| 451 | { |
| 452 | InterfaceType* inter; |
| 453 | Type* type; |
| 454 | Itab* link; |
| 455 | int32 bad; |
| 456 | int32 unused; |
| 457 | void (*fun[])(void); |
| 458 | }; |
| 459 | |
Russ Cox | 851f301 | 2011-12-16 15:33:58 -0500 | [diff] [blame] | 460 | #ifdef GOOS_windows |
Alex Brainman | f95a2f2 | 2010-09-12 11:45:16 +1000 | [diff] [blame] | 461 | enum { |
| 462 | Windows = 1 |
| 463 | }; |
| 464 | #else |
| 465 | enum { |
| 466 | Windows = 0 |
| 467 | }; |
| 468 | #endif |
| 469 | |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 470 | struct Timers |
| 471 | { |
| 472 | Lock; |
| 473 | G *timerproc; |
| 474 | bool sleeping; |
| 475 | bool rescheduling; |
| 476 | Note waitnote; |
| 477 | Timer **t; |
| 478 | int32 len; |
| 479 | int32 cap; |
| 480 | }; |
| 481 | |
| 482 | // Package time knows the layout of this structure. |
| 483 | // If this struct changes, adjust ../time/sleep.go:/runtimeTimer. |
| 484 | struct Timer |
| 485 | { |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 486 | int32 i; // heap index |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 487 | |
| 488 | // Timer wakes up at when, and then at when+period, ... (period > 0 only) |
| 489 | // each time calling f(now, arg) in the timer goroutine, so f must be |
| 490 | // a well-behaved function and not block. |
| 491 | int64 when; |
| 492 | int64 period; |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 493 | FuncVal *fv; |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 494 | Eface arg; |
| 495 | }; |
| 496 | |
Dmitriy Vyukov | a5dc779 | 2012-04-12 11:49:25 +0400 | [diff] [blame] | 497 | // Lock-free stack node. |
| 498 | struct LFNode |
| 499 | { |
| 500 | LFNode *next; |
| 501 | uintptr pushcnt; |
| 502 | }; |
| 503 | |
Dmitriy Vyukov | 9564364 | 2012-05-11 10:50:03 +0400 | [diff] [blame] | 504 | // Parallel for descriptor. |
| 505 | struct ParFor |
| 506 | { |
| 507 | void (*body)(ParFor*, uint32); // executed for each element |
| 508 | uint32 done; // number of idle threads |
| 509 | uint32 nthr; // total number of threads |
| 510 | uint32 nthrmax; // maximum number of threads |
| 511 | uint32 thrseq; // thread id sequencer |
| 512 | uint32 cnt; // iteration space [0, cnt) |
| 513 | void *ctx; // arbitrary user context |
| 514 | bool wait; // if true, wait while all threads finish processing, |
| 515 | // otherwise parfor may return while other threads are still working |
| 516 | ParForThread *thr; // array of thread descriptors |
Dmitriy Vyukov | 433824d | 2013-03-10 20:46:11 +0400 | [diff] [blame] | 517 | uint32 pad; // to align ParForThread.pos for 64-bit atomic operations |
Dmitriy Vyukov | 9564364 | 2012-05-11 10:50:03 +0400 | [diff] [blame] | 518 | // stats |
| 519 | uint64 nsteal; |
| 520 | uint64 nstealcnt; |
| 521 | uint64 nprocyield; |
| 522 | uint64 nosyield; |
| 523 | uint64 nsleep; |
| 524 | }; |
| 525 | |
Ian Lance Taylor | e9a3087 | 2012-11-10 11:19:06 -0800 | [diff] [blame] | 526 | // Track memory allocated by code not written in Go during a cgo call, |
| 527 | // so that the garbage collector can see them. |
| 528 | struct CgoMal |
| 529 | { |
| 530 | CgoMal *next; |
Ian Lance Taylor | 6732ad9 | 2013-04-06 20:18:15 -0700 | [diff] [blame] | 531 | void *alloc; |
Ian Lance Taylor | e9a3087 | 2012-11-10 11:19:06 -0800 | [diff] [blame] | 532 | }; |
| 533 | |
Dmitriy Vyukov | 4b536a5 | 2013-06-28 18:37:06 +0400 | [diff] [blame] | 534 | // Holds variables parsed from GODEBUG env var. |
| 535 | struct DebugVars |
| 536 | { |
| 537 | int32 gctrace; |
Dmitriy Vyukov | 4f2e382 | 2013-08-14 00:30:55 +0400 | [diff] [blame] | 538 | int32 schedtrace; |
| 539 | int32 scheddetail; |
Dmitriy Vyukov | 4b536a5 | 2013-06-28 18:37:06 +0400 | [diff] [blame] | 540 | }; |
| 541 | |
Russ Cox | 30ecb4c | 2013-09-16 20:26:10 -0400 | [diff] [blame] | 542 | extern bool runtime·precisestack; |
| 543 | |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 544 | /* |
| 545 | * defined macros |
Robert Hencke | 3fbd478 | 2011-05-30 18:02:59 +1000 | [diff] [blame] | 546 | * you need super-gopher-guru privilege |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 547 | * to add this list. |
| 548 | */ |
| 549 | #define nelem(x) (sizeof(x)/sizeof((x)[0])) |
| 550 | #define nil ((void*)0) |
Russ Cox | dc9a3b2 | 2010-12-13 16:22:19 -0500 | [diff] [blame] | 551 | #define offsetof(s,m) (uint32)(&(((s*)0)->m)) |
Russ Cox | 6dbaa20 | 2012-05-29 14:02:29 -0400 | [diff] [blame] | 552 | #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] | 553 | |
| 554 | /* |
Russ Cox | eee50ae | 2008-12-19 12:05:22 -0800 | [diff] [blame] | 555 | * known to compiler |
| 556 | */ |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 557 | enum { |
| 558 | Structrnd = sizeof(uintptr) |
| 559 | }; |
| 560 | |
| 561 | /* |
| 562 | * type algorithms - known to compiler |
| 563 | */ |
Russ Cox | eee50ae | 2008-12-19 12:05:22 -0800 | [diff] [blame] | 564 | enum |
| 565 | { |
Russ Cox | a7f6d40 | 2009-01-26 09:56:42 -0800 | [diff] [blame] | 566 | AMEM, |
Dmitriy Vyukov | 1ff1405 | 2012-01-20 10:32:55 +0400 | [diff] [blame] | 567 | AMEM0, |
Dmitriy Vyukov | 54e9406 | 2011-08-08 09:35:32 -0400 | [diff] [blame] | 568 | AMEM8, |
| 569 | AMEM16, |
| 570 | AMEM32, |
| 571 | AMEM64, |
| 572 | AMEM128, |
Russ Cox | 196b663 | 2011-12-12 22:22:09 -0500 | [diff] [blame] | 573 | ANOEQ, |
Dmitriy Vyukov | 1ff1405 | 2012-01-20 10:32:55 +0400 | [diff] [blame] | 574 | ANOEQ0, |
Dmitriy Vyukov | 54e9406 | 2011-08-08 09:35:32 -0400 | [diff] [blame] | 575 | ANOEQ8, |
| 576 | ANOEQ16, |
| 577 | ANOEQ32, |
| 578 | ANOEQ64, |
| 579 | ANOEQ128, |
Russ Cox | 196b663 | 2011-12-12 22:22:09 -0500 | [diff] [blame] | 580 | ASTRING, |
| 581 | AINTER, |
| 582 | ANILINTER, |
| 583 | ASLICE, |
Russ Cox | 408f0b1 | 2012-01-26 16:25:07 -0500 | [diff] [blame] | 584 | AFLOAT32, |
| 585 | AFLOAT64, |
| 586 | ACPLX64, |
| 587 | ACPLX128, |
Russ Cox | a7f6d40 | 2009-01-26 09:56:42 -0800 | [diff] [blame] | 588 | Amax |
Russ Cox | eee50ae | 2008-12-19 12:05:22 -0800 | [diff] [blame] | 589 | }; |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 590 | typedef struct Alg Alg; |
| 591 | struct Alg |
| 592 | { |
| 593 | void (*hash)(uintptr*, uintptr, void*); |
| 594 | void (*equal)(bool*, uintptr, void*, void*); |
| 595 | void (*print)(uintptr, void*); |
| 596 | void (*copy)(uintptr, void*, void*); |
Russ Cox | 29aa3ff | 2009-07-02 21:25:46 -0700 | [diff] [blame] | 597 | }; |
| 598 | |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 599 | extern Alg runtime·algarray[Amax]; |
| 600 | |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 601 | byte* runtime·startup_random_data; |
| 602 | uint32 runtime·startup_random_data_len; |
| 603 | void runtime·get_random_data(byte**, int32*); |
| 604 | |
| 605 | enum { |
| 606 | // hashinit wants this many random bytes |
| 607 | HashRandomBytes = 32 |
| 608 | }; |
| 609 | void runtime·hashinit(void); |
| 610 | |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 611 | void runtime·memhash(uintptr*, uintptr, void*); |
| 612 | void runtime·nohash(uintptr*, uintptr, void*); |
| 613 | void runtime·strhash(uintptr*, uintptr, void*); |
| 614 | void runtime·interhash(uintptr*, uintptr, void*); |
| 615 | void runtime·nilinterhash(uintptr*, uintptr, void*); |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 616 | void runtime·aeshash(uintptr*, uintptr, void*); |
| 617 | void runtime·aeshash32(uintptr*, uintptr, void*); |
| 618 | void runtime·aeshash64(uintptr*, uintptr, void*); |
| 619 | void runtime·aeshashstr(uintptr*, uintptr, void*); |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 620 | |
| 621 | void runtime·memequal(bool*, uintptr, void*, void*); |
| 622 | void runtime·noequal(bool*, uintptr, void*, void*); |
| 623 | void runtime·strequal(bool*, uintptr, void*, void*); |
| 624 | void runtime·interequal(bool*, uintptr, void*, void*); |
| 625 | void runtime·nilinterequal(bool*, uintptr, void*, void*); |
| 626 | |
Keith Randall | 3d5daa2 | 2013-04-02 16:26:15 -0700 | [diff] [blame] | 627 | bool runtime·memeq(void*, void*, uintptr); |
| 628 | |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 629 | void runtime·memprint(uintptr, void*); |
| 630 | void runtime·strprint(uintptr, void*); |
| 631 | void runtime·interprint(uintptr, void*); |
| 632 | void runtime·nilinterprint(uintptr, void*); |
| 633 | |
| 634 | void runtime·memcopy(uintptr, void*, void*); |
| 635 | void runtime·memcopy8(uintptr, void*, void*); |
| 636 | void runtime·memcopy16(uintptr, void*, void*); |
| 637 | void runtime·memcopy32(uintptr, void*, void*); |
| 638 | void runtime·memcopy64(uintptr, void*, void*); |
| 639 | void runtime·memcopy128(uintptr, void*, void*); |
Russ Cox | b9ccd07 | 2011-12-05 09:40:22 -0500 | [diff] [blame] | 640 | void runtime·strcopy(uintptr, void*, void*); |
| 641 | void runtime·algslicecopy(uintptr, void*, void*); |
| 642 | void runtime·intercopy(uintptr, void*, void*); |
| 643 | void runtime·nilintercopy(uintptr, void*, void*); |
| 644 | |
Russ Cox | eee50ae | 2008-12-19 12:05:22 -0800 | [diff] [blame] | 645 | /* |
Ken Thompson | 47ab1c1 | 2009-01-27 13:23:28 -0800 | [diff] [blame] | 646 | * deferred subroutine calls |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 647 | */ |
| 648 | struct Defer |
| 649 | { |
| 650 | int32 siz; |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 651 | bool special; // not part of defer frame |
| 652 | bool free; // if special, free when done |
| 653 | byte* argp; // where args were copied from |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 654 | byte* pc; |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 655 | FuncVal* fn; |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 656 | Defer* link; |
Jan Ziak | 334bf95 | 2012-05-30 13:07:52 -0400 | [diff] [blame] | 657 | void* args[1]; // padded to actual size |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 658 | }; |
| 659 | |
Russ Cox | 0de7161 | 2012-12-22 14:54:39 -0500 | [diff] [blame] | 660 | struct DeferChunk |
| 661 | { |
| 662 | DeferChunk *prev; |
| 663 | uintptr off; |
| 664 | }; |
| 665 | |
Ken Thompson | 1e1cc4e | 2009-01-27 12:03:53 -0800 | [diff] [blame] | 666 | /* |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 667 | * panics |
| 668 | */ |
| 669 | struct Panic |
| 670 | { |
| 671 | Eface arg; // argument to panic |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 672 | uintptr stackbase; // g->stackbase in panic |
Russ Cox | 9b1507b | 2010-03-31 11:46:01 -0700 | [diff] [blame] | 673 | Panic* link; // link to earlier panic |
| 674 | bool recovered; // whether this panic is over |
| 675 | }; |
| 676 | |
| 677 | /* |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 678 | * stack traces |
| 679 | */ |
| 680 | typedef struct Stkframe Stkframe; |
| 681 | struct Stkframe |
| 682 | { |
| 683 | Func* fn; // function being run |
| 684 | uintptr pc; // program counter within fn |
| 685 | uintptr lr; // program counter at caller aka link register |
| 686 | uintptr sp; // stack pointer at pc |
| 687 | uintptr fp; // stack pointer at caller aka frame pointer |
Keith Randall | 4487054 | 2013-09-10 09:02:22 -0700 | [diff] [blame] | 688 | byte* varp; // top of local variables |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 689 | byte* argp; // pointer to function arguments |
| 690 | uintptr arglen; // number of bytes at argp |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 691 | }; |
| 692 | |
Russ Cox | 6fa3c89 | 2013-06-27 11:32:01 -0400 | [diff] [blame] | 693 | int32 runtime·gentraceback(uintptr, uintptr, uintptr, G*, int32, uintptr*, int32, void(*)(Stkframe*, void*), void*, bool); |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 694 | void runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G* gp); |
| 695 | void runtime·tracebackothers(G*); |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 696 | bool runtime·haszeroargs(uintptr pc); |
Russ Cox | a837485 | 2013-07-17 12:47:18 -0400 | [diff] [blame] | 697 | bool runtime·topofstack(Func*); |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 698 | |
| 699 | /* |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 700 | * external data |
| 701 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 702 | extern String runtime·emptystring; |
Jan Ziak | 4a191c2 | 2012-10-21 17:41:32 -0400 | [diff] [blame] | 703 | extern uintptr runtime·zerobase; |
Shenghou Ma | 4019d0e | 2013-01-26 09:57:06 +0800 | [diff] [blame] | 704 | extern G* runtime·allg; |
| 705 | extern G* runtime·lastg; |
| 706 | extern M* runtime·allm; |
Dmitriy Vyukov | 779c45a | 2013-03-01 13:49:16 +0200 | [diff] [blame] | 707 | extern P** runtime·allp; |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 708 | extern int32 runtime·gomaxprocs; |
Dmitriy Vyukov | 34c67eb | 2013-05-22 22:57:47 +0400 | [diff] [blame] | 709 | extern uint32 runtime·needextram; |
Russ Cox | 6779350 | 2011-02-16 13:21:13 -0500 | [diff] [blame] | 710 | extern uint32 runtime·panicking; |
Shenghou Ma | 4019d0e | 2013-01-26 09:57:06 +0800 | [diff] [blame] | 711 | extern int8* runtime·goos; |
| 712 | extern int32 runtime·ncpu; |
Russ Cox | 9042c2c | 2010-12-08 13:53:30 -0500 | [diff] [blame] | 713 | extern bool runtime·iscgo; |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 714 | extern void (*runtime·sysargs)(int32, uint8**); |
Rob Pike | 98a80b9 | 2013-08-07 06:49:11 +1000 | [diff] [blame] | 715 | extern uintptr runtime·maxstring; |
Jan Ziak | a656f82 | 2013-02-25 15:58:23 -0500 | [diff] [blame] | 716 | extern uint32 runtime·Hchansize; |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 717 | extern uint32 runtime·cpuid_ecx; |
| 718 | extern uint32 runtime·cpuid_edx; |
Dmitriy Vyukov | 4b536a5 | 2013-06-28 18:37:06 +0400 | [diff] [blame] | 719 | extern DebugVars runtime·debug; |
Russ Cox | 757e0de | 2013-08-15 22:34:06 -0400 | [diff] [blame] | 720 | extern uintptr runtime·maxstacksize; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 721 | |
| 722 | /* |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 723 | * common functions and data |
| 724 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 725 | int32 runtime·strcmp(byte*, byte*); |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 726 | byte* runtime·strstr(byte*, byte*); |
Rob Pike | 82f5ca1 | 2013-08-06 21:49:03 +1000 | [diff] [blame] | 727 | intgo runtime·findnull(byte*); |
| 728 | intgo runtime·findnullw(uint16*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 729 | void runtime·dump(byte*, int32); |
| 730 | int32 runtime·runetochar(byte*, int32); |
| 731 | int32 runtime·charntorune(int32*, uint8*, int32); |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 732 | |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 733 | /* |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 734 | * very low level c-called |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 735 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 736 | #define FLUSH(x) USED(x) |
Russ Cox | 4e28cfe | 2010-03-26 14:15:30 -0700 | [diff] [blame] | 737 | |
Russ Cox | d67e7e3 | 2013-06-12 15:22:26 -0400 | [diff] [blame] | 738 | void runtime·gogo(Gobuf*); |
| 739 | void runtime·gostartcall(Gobuf*, void(*)(void), void*); |
| 740 | void runtime·gostartcallfn(Gobuf*, FuncVal*); |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 741 | void runtime·gosave(Gobuf*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 742 | void runtime·lessstack(void); |
| 743 | void runtime·goargs(void); |
Alex Brainman | a41d854 | 2011-01-12 11:48:15 +1100 | [diff] [blame] | 744 | void runtime·goenvs(void); |
| 745 | void runtime·goenvs_unix(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 746 | void* runtime·getu(void); |
| 747 | void runtime·throw(int8*); |
| 748 | void runtime·panicstring(int8*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 749 | void runtime·prints(int8*); |
| 750 | void runtime·printf(int8*, ...); |
| 751 | byte* runtime·mchr(byte*, byte, byte*); |
Keith Randall | 00224a3 | 2013-03-20 13:51:29 -0700 | [diff] [blame] | 752 | int32 runtime·mcmp(byte*, byte*, uintptr); |
Rémy Oudompheng | 1b8f51c | 2013-03-09 00:41:03 +0100 | [diff] [blame] | 753 | void runtime·memmove(void*, void*, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 754 | void* runtime·mal(uintptr); |
| 755 | String runtime·catstring(String, String); |
| 756 | String runtime·gostring(byte*); |
Russ Cox | 0b08c94 | 2012-09-24 14:58:34 -0400 | [diff] [blame] | 757 | String runtime·gostringn(byte*, intgo); |
| 758 | Slice runtime·gobytes(byte*, intgo); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 759 | String runtime·gostringnocopy(byte*); |
Alex Brainman | a41d854 | 2011-01-12 11:48:15 +1100 | [diff] [blame] | 760 | String runtime·gostringw(uint16*); |
Russ Cox | 35586f7 | 2012-02-13 13:52:37 -0500 | [diff] [blame] | 761 | void runtime·initsig(void); |
David Symonds | 3d8ebef | 2012-02-17 14:36:40 +1100 | [diff] [blame] | 762 | void runtime·sigenable(uint32 sig); |
Russ Cox | cb4428e | 2013-03-15 00:00:02 -0400 | [diff] [blame] | 763 | void runtime·sigdisable(uint32 sig); |
Russ Cox | 5146a93 | 2013-03-15 01:11:03 -0400 | [diff] [blame] | 764 | int32 runtime·gotraceback(bool *crash); |
Russ Cox | 03e9ea5 | 2011-08-22 23:26:39 -0400 | [diff] [blame] | 765 | void runtime·goroutineheader(G*); |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 766 | int32 runtime·open(int8*, int32, int32); |
| 767 | int32 runtime·read(int32, void*, int32); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 768 | int32 runtime·write(int32, void*, int32); |
Keith Randall | a5d4024 | 2013-03-12 10:47:44 -0700 | [diff] [blame] | 769 | int32 runtime·close(int32); |
Jonathan Mark | ddde52a | 2011-06-07 21:50:10 -0700 | [diff] [blame] | 770 | int32 runtime·mincore(void*, uintptr, byte*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 771 | bool runtime·cas(uint32*, uint32, uint32); |
Russ Cox | fb63e4f | 2013-07-12 00:03:32 -0400 | [diff] [blame] | 772 | bool runtime·cas64(uint64*, uint64, uint64); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 773 | bool runtime·casp(void**, void*, void*); |
Dmitriy Vyukov | 997c00f | 2011-06-28 15:09:53 -0400 | [diff] [blame] | 774 | // Don't confuse with XADD x86 instruction, |
| 775 | // this one is actually 'addx', that is, add-and-fetch. |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 776 | uint32 runtime·xadd(uint32 volatile*, int32); |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 777 | uint64 runtime·xadd64(uint64 volatile*, int64); |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 778 | uint32 runtime·xchg(uint32 volatile*, uint32); |
Dmitriy Vyukov | add3349 | 2013-03-05 09:46:52 +0200 | [diff] [blame] | 779 | uint64 runtime·xchg64(uint64 volatile*, uint64); |
Dmitriy Vyukov | 86a659c | 2011-07-13 11:22:41 -0700 | [diff] [blame] | 780 | uint32 runtime·atomicload(uint32 volatile*); |
Dmitriy Vyukov | 91f0f18 | 2011-07-29 13:47:24 -0400 | [diff] [blame] | 781 | void runtime·atomicstore(uint32 volatile*, uint32); |
Dmitriy Vyukov | 4667571 | 2012-04-05 18:47:43 +0400 | [diff] [blame] | 782 | void runtime·atomicstore64(uint64 volatile*, uint64); |
| 783 | uint64 runtime·atomicload64(uint64 volatile*); |
Dmitriy Vyukov | 86a659c | 2011-07-13 11:22:41 -0700 | [diff] [blame] | 784 | void* runtime·atomicloadp(void* volatile*); |
| 785 | void runtime·atomicstorep(void* volatile*, void*); |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 786 | void runtime·jmpdefer(FuncVal*, void*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 787 | void runtime·exit1(int32); |
| 788 | void runtime·ready(G*); |
| 789 | byte* runtime·getenv(int8*); |
| 790 | int32 runtime·atoi(byte*); |
Russ Cox | e6a3e22 | 2013-03-01 11:44:43 -0500 | [diff] [blame] | 791 | void runtime·newosproc(M *mp, void *stk); |
| 792 | void runtime·mstart(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 793 | G* runtime·malg(int32); |
Russ Cox | 1707a99 | 2012-02-14 01:23:15 -0500 | [diff] [blame] | 794 | void runtime·asminit(void); |
Dmitriy Vyukov | a0955a2 | 2013-02-21 16:24:38 +0400 | [diff] [blame] | 795 | void runtime·mpreinit(M*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 796 | void runtime·minit(void); |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 797 | void runtime·unminit(void); |
| 798 | void runtime·signalstack(byte*, int32); |
Dmitriy Vyukov | 081129e | 2013-05-28 21:10:10 +0400 | [diff] [blame] | 799 | void runtime·symtabinit(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 800 | Func* runtime·findfunc(uintptr); |
Russ Cox | 5d363c6 | 2013-07-16 09:41:38 -0400 | [diff] [blame] | 801 | int32 runtime·funcline(Func*, uintptr, String*); |
| 802 | int32 runtime·funcarglen(Func*, uintptr); |
| 803 | int32 runtime·funcspdelta(Func*, uintptr); |
Russ Cox | c3de91b | 2013-07-18 10:43:22 -0400 | [diff] [blame] | 804 | int8* runtime·funcname(Func*); |
Carl Shapiro | 16d6b6c | 2013-09-16 19:03:19 -0700 | [diff] [blame] | 805 | int32 runtime·pcdatavalue(Func*, int32, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 806 | void* runtime·stackalloc(uint32); |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 807 | void runtime·stackfree(void*, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 808 | MCache* runtime·allocmcache(void); |
Dmitriy Vyukov | ed516df | 2012-07-01 13:10:01 +0400 | [diff] [blame] | 809 | void runtime·freemcache(MCache*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 810 | void runtime·mallocinit(void); |
Jan Ziak | 4da6b36 | 2013-01-30 09:01:31 -0800 | [diff] [blame] | 811 | void runtime·mprofinit(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 812 | bool runtime·ifaceeq_c(Iface, Iface); |
| 813 | bool runtime·efaceeq_c(Eface, Eface); |
Ian Lance Taylor | 63bee95 | 2013-01-04 07:53:42 -0800 | [diff] [blame] | 814 | uintptr runtime·ifacehash(Iface, uintptr); |
| 815 | uintptr runtime·efacehash(Eface, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 816 | void* runtime·malloc(uintptr size); |
| 817 | void runtime·free(void *v); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 818 | void runtime·runpanic(Panic*); |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 819 | uintptr runtime·getcallersp(void*); |
Russ Cox | 4608feb | 2011-01-28 15:03:26 -0500 | [diff] [blame] | 820 | int32 runtime·mcount(void); |
Russ Cox | e4b02bf | 2012-02-22 21:45:01 -0500 | [diff] [blame] | 821 | int32 runtime·gcount(void); |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 822 | void runtime·mcall(void(*)(G*)); |
Dmitriy Vyukov | 909f318 | 2011-07-12 01:23:58 -0400 | [diff] [blame] | 823 | uint32 runtime·fastrand1(void); |
Russ Cox | 6fa3c89 | 2013-06-27 11:32:01 -0400 | [diff] [blame] | 824 | void runtime·rewindmorestack(Gobuf*); |
Dmitriy Vyukov | e84d9e1 | 2013-07-29 22:22:34 +0400 | [diff] [blame] | 825 | int32 runtime·timediv(int64, int32, int32*); |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 826 | |
Russ Cox | 6c97639 | 2013-02-20 17:48:23 -0500 | [diff] [blame] | 827 | void runtime·setmg(M*, G*); |
| 828 | void runtime·newextram(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 829 | void runtime·exit(int32); |
| 830 | void runtime·breakpoint(void); |
| 831 | void runtime·gosched(void); |
Dmitriy Vyukov | 1e112cd | 2013-06-28 17:52:17 +0400 | [diff] [blame] | 832 | void runtime·gosched0(G*); |
Dmitriy Vyukov | 4f2e382 | 2013-08-14 00:30:55 +0400 | [diff] [blame] | 833 | void runtime·schedtrace(bool); |
Dmitriy Vyukov | f20fd87 | 2012-09-18 21:15:46 +0400 | [diff] [blame] | 834 | void runtime·park(void(*)(Lock*), Lock*, int8*); |
| 835 | void runtime·tsleep(int64, int8*); |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 836 | M* runtime·newm(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 837 | void runtime·goexit(void); |
Russ Cox | f9ca3b5 | 2011-03-07 10:37:42 -0500 | [diff] [blame] | 838 | void runtime·asmcgocall(void (*fn)(void*), void*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 839 | void runtime·entersyscall(void); |
Dmitriy Vyukov | e25f19a | 2013-02-20 20:21:45 +0400 | [diff] [blame] | 840 | void runtime·entersyscallblock(void); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 841 | void runtime·exitsyscall(void); |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 842 | G* runtime·newproc1(FuncVal*, byte*, int32, int32, void*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 843 | bool runtime·sigsend(int32 sig); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 844 | int32 runtime·callers(int32, uintptr*, int32); |
| 845 | int64 runtime·nanotime(void); |
| 846 | void runtime·dopanic(int32); |
Russ Cox | 6779350 | 2011-02-16 13:21:13 -0500 | [diff] [blame] | 847 | void runtime·startpanic(void); |
Dmitriy Vyukov | 01f1e3d | 2013-08-09 12:53:35 +0400 | [diff] [blame] | 848 | void runtime·freezetheworld(void); |
Dmitriy Vyukov | a54f920b | 2012-07-04 14:52:51 +0400 | [diff] [blame] | 849 | void runtime·unwindstack(G*, byte*); |
Russ Cox | c19b373 | 2011-03-23 11:43:37 -0400 | [diff] [blame] | 850 | void runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp); |
| 851 | void runtime·resetcpuprofiler(int32); |
| 852 | void runtime·setcpuprofilerate(void(*)(uintptr*, int32), int32); |
Russ Cox | d324f21 | 2011-09-30 09:40:01 -0400 | [diff] [blame] | 853 | void runtime·usleep(uint32); |
Damian Gryski | 8e765da | 2012-02-02 14:09:27 -0500 | [diff] [blame] | 854 | int64 runtime·cputicks(void); |
Dmitriy Vyukov | 4cc7bf3 | 2012-10-06 12:56:04 +0400 | [diff] [blame] | 855 | int64 runtime·tickspersecond(void); |
| 856 | void runtime·blockevent(int64, int32); |
| 857 | extern int64 runtime·blockprofilerate; |
Dmitriy Vyukov | d0c11d2 | 2013-03-05 09:38:15 +0200 | [diff] [blame] | 858 | void runtime·addtimer(Timer*); |
| 859 | bool runtime·deltimer(Timer*); |
Dmitriy Vyukov | c211884 | 2013-03-12 21:14:26 +0400 | [diff] [blame] | 860 | G* runtime·netpoll(bool); |
Dmitriy Vyukov | 0bee99a | 2013-03-14 10:38:37 +0400 | [diff] [blame] | 861 | void runtime·netpollinit(void); |
Alex Brainman | 38abb09 | 2013-05-20 12:55:50 +1000 | [diff] [blame] | 862 | int32 runtime·netpollopen(uintptr, PollDesc*); |
| 863 | int32 runtime·netpollclose(uintptr); |
Dmitriy Vyukov | 0bee99a | 2013-03-14 10:38:37 +0400 | [diff] [blame] | 864 | void runtime·netpollready(G**, PollDesc*, int32); |
Dmitriy Vyukov | 6583468 | 2013-08-08 17:41:57 +0400 | [diff] [blame] | 865 | uintptr runtime·netpollfd(PollDesc*); |
Russ Cox | 5146a93 | 2013-03-15 01:11:03 -0400 | [diff] [blame] | 866 | void runtime·crash(void); |
Dmitriy Vyukov | 4b536a5 | 2013-06-28 18:37:06 +0400 | [diff] [blame] | 867 | void runtime·parsedebugvars(void); |
Russ Cox | e58f798 | 2013-06-12 08:49:38 -0400 | [diff] [blame] | 868 | void _rt0_go(void); |
Russ Cox | 48769bf | 2013-07-19 16:04:09 -0400 | [diff] [blame] | 869 | void* runtime·funcdata(Func*, int32); |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame] | 870 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 871 | #pragma varargck argpos runtime·printf 1 |
Carl Shapiro | 4e0a51c | 2013-05-28 17:59:10 -0700 | [diff] [blame] | 872 | #pragma varargck type "c" int32 |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame] | 873 | #pragma varargck type "d" int32 |
| 874 | #pragma varargck type "d" uint32 |
| 875 | #pragma varargck type "D" int64 |
| 876 | #pragma varargck type "D" uint64 |
| 877 | #pragma varargck type "x" int32 |
| 878 | #pragma varargck type "x" uint32 |
| 879 | #pragma varargck type "X" int64 |
| 880 | #pragma varargck type "X" uint64 |
| 881 | #pragma varargck type "p" void* |
Russ Cox | 0d3a043 | 2009-03-30 00:01:07 -0700 | [diff] [blame] | 882 | #pragma varargck type "p" uintptr |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame] | 883 | #pragma varargck type "s" int8* |
| 884 | #pragma varargck type "s" uint8* |
Ken Thompson | 3657061 | 2009-04-09 18:16:21 -0700 | [diff] [blame] | 885 | #pragma varargck type "S" String |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame] | 886 | |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 887 | void runtime·stoptheworld(void); |
Dmitriy Vyukov | 0182628 | 2012-05-15 19:10:16 +0400 | [diff] [blame] | 888 | void runtime·starttheworld(void); |
Russ Cox | e4b02bf | 2012-02-22 21:45:01 -0500 | [diff] [blame] | 889 | extern uint32 runtime·worldsema; |
Russ Cox | 3f8aa66 | 2008-12-05 15:24:18 -0800 | [diff] [blame] | 890 | |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 891 | /* |
| 892 | * mutual exclusion locks. in the uncontended case, |
| 893 | * as fast as spin locks (just a few user-level instructions), |
| 894 | * but on the contention path they sleep in the kernel. |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 895 | * a zeroed Lock is unlocked (no need to initialize each lock). |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 896 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 897 | void runtime·lock(Lock*); |
| 898 | void runtime·unlock(Lock*); |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 899 | |
| 900 | /* |
Russ Cox | a68592a | 2009-10-14 13:02:05 -0700 | [diff] [blame] | 901 | * sleep and wakeup on one-time events. |
Russ Cox | f7f6329 | 2008-08-05 14:21:42 -0700 | [diff] [blame] | 902 | * before any calls to notesleep or notewakeup, |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 903 | * must call noteclear to initialize the Note. |
Dmitriy Vyukov | a496c9e | 2011-08-03 15:51:55 -0400 | [diff] [blame] | 904 | * then, exactly one thread can call notesleep |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 905 | * and exactly one thread can call notewakeup (once). |
Dmitriy Vyukov | a496c9e | 2011-08-03 15:51:55 -0400 | [diff] [blame] | 906 | * once notewakeup has been called, the notesleep |
| 907 | * will return. future notesleep will return immediately. |
| 908 | * subsequent noteclear must be called only after |
| 909 | * previous notesleep has returned, e.g. it's disallowed |
| 910 | * to call noteclear straight after notewakeup. |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 911 | * |
| 912 | * notetsleep is like notesleep but wakes up after |
| 913 | * a given number of nanoseconds even if the event |
| 914 | * has not yet happened. if a goroutine uses notetsleep to |
| 915 | * wake up early, it must wait to call noteclear until it |
| 916 | * can be sure that no other goroutine is calling |
| 917 | * notewakeup. |
Dmitriy Vyukov | e97d677 | 2013-07-22 23:02:27 +0400 | [diff] [blame] | 918 | * |
| 919 | * notesleep/notetsleep are generally called on g0, |
| 920 | * notetsleepg is similar to notetsleep but is called on user g. |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 921 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 922 | void runtime·noteclear(Note*); |
| 923 | void runtime·notesleep(Note*); |
| 924 | void runtime·notewakeup(Note*); |
Dmitriy Vyukov | e932c20 | 2013-05-29 11:49:45 +0400 | [diff] [blame] | 925 | bool runtime·notetsleep(Note*, int64); // false - timeout |
Dmitriy Vyukov | e97d677 | 2013-07-22 23:02:27 +0400 | [diff] [blame] | 926 | bool runtime·notetsleepg(Note*, int64); // false - timeout |
Russ Cox | 3b86026 | 2011-11-09 15:17:05 -0500 | [diff] [blame] | 927 | |
| 928 | /* |
| 929 | * low-level synchronization for implementing the above |
| 930 | */ |
| 931 | uintptr runtime·semacreate(void); |
| 932 | int32 runtime·semasleep(int64); |
| 933 | void runtime·semawakeup(M*); |
| 934 | // or |
| 935 | void runtime·futexsleep(uint32*, uint32, int64); |
| 936 | void runtime·futexwakeup(uint32*, uint32); |
Ian Lance Taylor | 9b8da82 | 2009-01-13 09:55:24 -0800 | [diff] [blame] | 937 | |
| 938 | /* |
Dmitriy Vyukov | a5dc779 | 2012-04-12 11:49:25 +0400 | [diff] [blame] | 939 | * Lock-free stack. |
| 940 | * Initialize uint64 head to 0, compare with 0 to test for emptiness. |
| 941 | * The stack does not keep pointers to nodes, |
| 942 | * so they can be garbage collected if there are no other pointers to nodes. |
| 943 | */ |
| 944 | void runtime·lfstackpush(uint64 *head, LFNode *node); |
| 945 | LFNode* runtime·lfstackpop(uint64 *head); |
| 946 | |
| 947 | /* |
Dmitriy Vyukov | 9564364 | 2012-05-11 10:50:03 +0400 | [diff] [blame] | 948 | * Parallel for over [0, n). |
| 949 | * body() is executed for each iteration. |
| 950 | * nthr - total number of worker threads. |
| 951 | * ctx - arbitrary user context. |
| 952 | * if wait=true, threads return from parfor() when all work is done; |
| 953 | * otherwise, threads can return while other threads are still finishing processing. |
| 954 | */ |
| 955 | ParFor* runtime·parforalloc(uint32 nthrmax); |
| 956 | void runtime·parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void (*body)(ParFor*, uint32)); |
| 957 | void runtime·parfordo(ParFor *desc); |
| 958 | |
| 959 | /* |
Adam Langley | 3f7a324 | 2009-11-13 10:08:51 -0800 | [diff] [blame] | 960 | * This is consistent across Linux and BSD. |
| 961 | * If a new OS is added that is different, move this to |
| 962 | * $GOOS/$GOARCH/defs.h. |
| 963 | */ |
| 964 | #define EACCES 13 |
| 965 | |
| 966 | /* |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 967 | * low level C-called |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 968 | */ |
Shenghou Ma | b151af1 | 2012-09-21 13:50:02 +0800 | [diff] [blame] | 969 | // for mmap, we only pass the lower 32 bits of file offset to the |
| 970 | // assembly routine; the higher bits (if required), should be provided |
| 971 | // by the assembly routine as 0. |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 972 | uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32); |
Russ Cox | e83cd7f | 2011-12-20 17:54:40 -0500 | [diff] [blame] | 973 | void runtime·munmap(byte*, uintptr); |
| 974 | void runtime·madvise(byte*, uintptr, int32); |
Russ Cox | afc6928 | 2011-01-25 16:35:36 -0500 | [diff] [blame] | 975 | void runtime·memclr(byte*, uintptr); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 976 | void runtime·setcallerpc(void*, void*); |
| 977 | void* runtime·getcallerpc(void*); |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 978 | |
| 979 | /* |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 980 | * runtime go-called |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 981 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 982 | void runtime·printbool(bool); |
Carl Shapiro | 7f9c02a | 2013-02-19 18:05:44 -0800 | [diff] [blame] | 983 | void runtime·printbyte(int8); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 984 | void runtime·printfloat(float64); |
| 985 | void runtime·printint(int64); |
| 986 | void runtime·printiface(Iface); |
| 987 | void runtime·printeface(Eface); |
| 988 | void runtime·printstring(String); |
| 989 | void runtime·printpc(void*); |
| 990 | void runtime·printpointer(void*); |
| 991 | void runtime·printuint(uint64); |
| 992 | void runtime·printhex(uint64); |
| 993 | void runtime·printslice(Slice); |
| 994 | void runtime·printcomplex(Complex128); |
Keith Randall | 9cd5706 | 2013-08-02 13:03:14 -0700 | [diff] [blame] | 995 | void runtime·newstackcall(FuncVal*, byte*, uint32); |
Russ Cox | 1903ad7 | 2013-02-21 17:01:13 -0500 | [diff] [blame] | 996 | void reflect·call(FuncVal*, byte*, uint32); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 997 | void runtime·panic(Eface); |
| 998 | void runtime·panicindex(void); |
| 999 | void runtime·panicslice(void); |
Russ Cox | 7c2b159 | 2010-10-25 17:55:50 -0700 | [diff] [blame] | 1000 | |
Russ Cox | 63e878a | 2010-03-31 15:55:10 -0700 | [diff] [blame] | 1001 | /* |
| 1002 | * runtime c-called (but written in Go) |
| 1003 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 1004 | void runtime·printany(Eface); |
Russ Cox | 6a75ece | 2012-02-12 23:26:20 -0500 | [diff] [blame] | 1005 | void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 1006 | void runtime·newErrorString(String, Eface*); |
| 1007 | void runtime·fadd64c(uint64, uint64, uint64*); |
| 1008 | void runtime·fsub64c(uint64, uint64, uint64*); |
| 1009 | void runtime·fmul64c(uint64, uint64, uint64*); |
| 1010 | void runtime·fdiv64c(uint64, uint64, uint64*); |
| 1011 | void runtime·fneg64c(uint64, uint64*); |
| 1012 | void runtime·f32to64c(uint32, uint64*); |
| 1013 | void runtime·f64to32c(uint64, uint32*); |
| 1014 | void runtime·fcmp64c(uint64, uint64, int32*, bool*); |
| 1015 | void runtime·fintto64c(int64, uint64*); |
| 1016 | void runtime·f64tointc(uint64, int64*, bool*); |
Rob Pike | 6db99de | 2008-07-08 10:36:43 -0700 | [diff] [blame] | 1017 | |
| 1018 | /* |
Russ Cox | 1f8a40d | 2009-01-22 16:23:44 -0800 | [diff] [blame] | 1019 | * wrapped for go users |
Rob Pike | 6db99de | 2008-07-08 10:36:43 -0700 | [diff] [blame] | 1020 | */ |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 1021 | float64 runtime·Inf(int32 sign); |
| 1022 | float64 runtime·NaN(void); |
| 1023 | float32 runtime·float32frombits(uint32 i); |
| 1024 | uint32 runtime·float32tobits(float32 f); |
| 1025 | float64 runtime·float64frombits(uint64 i); |
| 1026 | uint64 runtime·float64tobits(float64 f); |
| 1027 | float64 runtime·frexp(float64 d, int32 *ep); |
| 1028 | bool runtime·isInf(float64 f, int32 sign); |
| 1029 | bool runtime·isNaN(float64 f); |
| 1030 | float64 runtime·ldexp(float64 d, int32 e); |
| 1031 | float64 runtime·modf(float64 d, float64 *ip); |
Dmitriy Vyukov | 23e15f7 | 2013-08-09 21:43:00 +0400 | [diff] [blame] | 1032 | void runtime·semacquire(uint32*, bool); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 1033 | void runtime·semrelease(uint32*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 1034 | int32 runtime·gomaxprocsfunc(int32 n); |
Dmitriy Vyukov | 4e5086b | 2011-07-29 12:44:06 -0400 | [diff] [blame] | 1035 | void runtime·procyield(uint32); |
| 1036 | void runtime·osyield(void); |
Russ Cox | b0a29f3 | 2013-02-01 08:34:41 -0800 | [diff] [blame] | 1037 | void runtime·lockOSThread(void); |
| 1038 | void runtime·unlockOSThread(void); |
David Symonds | b586649 | 2009-12-15 18:21:29 -0800 | [diff] [blame] | 1039 | |
Russ Cox | 65bde08 | 2011-08-17 14:56:27 -0400 | [diff] [blame] | 1040 | void runtime·mapassign(MapType*, Hmap*, byte*, byte*); |
| 1041 | void runtime·mapaccess(MapType*, Hmap*, byte*, byte*, bool*); |
Russ Cox | 68b4255 | 2010-11-04 14:00:19 -0400 | [diff] [blame] | 1042 | void runtime·mapiternext(struct hash_iter*); |
| 1043 | bool runtime·mapiterkey(struct hash_iter*, void*); |
Russ Cox | 65bde08 | 2011-08-17 14:56:27 -0400 | [diff] [blame] | 1044 | Hmap* runtime·makemap_c(MapType*, int64); |
Russ Cox | 5ddaf9a | 2009-07-08 15:00:54 -0700 | [diff] [blame] | 1045 | |
Russ Cox | 3770b0e | 2011-08-17 15:54:17 -0400 | [diff] [blame] | 1046 | Hchan* runtime·makechan_c(ChanType*, int64); |
Dmitriy Vyukov | 2f6cbc7 | 2012-10-07 22:05:32 +0400 | [diff] [blame] | 1047 | void runtime·chansend(ChanType*, Hchan*, byte*, bool*, void*); |
Russ Cox | 33e9d24 | 2011-08-23 13:13:27 -0400 | [diff] [blame] | 1048 | void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*); |
Russ Cox | 6fa3c89 | 2013-06-27 11:32:01 -0400 | [diff] [blame] | 1049 | bool runtime·showframe(Func*, G*); |
Dmitriy Vyukov | c33d490 | 2013-08-01 19:28:38 +0400 | [diff] [blame] | 1050 | void runtime·printcreatedby(G*); |
Russ Cox | 5ddaf9a | 2009-07-08 15:00:54 -0700 | [diff] [blame] | 1051 | |
Jan Ziak | 5c1422a | 2012-11-01 13:13:20 -0400 | [diff] [blame] | 1052 | void runtime·ifaceE2I(InterfaceType*, Eface, Iface*); |
Russ Cox | 5822e78 | 2013-08-14 14:54:31 -0400 | [diff] [blame] | 1053 | bool runtime·ifaceE2I2(InterfaceType*, Eface, Iface*); |
Russ Cox | 102274a | 2012-02-24 15:28:51 -0500 | [diff] [blame] | 1054 | uintptr runtime·memlimit(void); |
Russ Cox | 6e2ae0a | 2012-02-28 16:18:24 -0500 | [diff] [blame] | 1055 | |
Shenghou Ma | 0157c72 | 2012-08-07 23:45:50 +0800 | [diff] [blame] | 1056 | // float.c |
| 1057 | extern float64 runtime·nan; |
| 1058 | extern float64 runtime·posinf; |
| 1059 | extern float64 runtime·neginf; |
| 1060 | extern uint64 ·nan; |
| 1061 | extern uint64 ·posinf; |
| 1062 | extern uint64 ·neginf; |
| 1063 | #define ISNAN(f) ((f) != (f)) |
Jan Ziak | f8c5837 | 2012-09-24 20:08:05 -0400 | [diff] [blame] | 1064 | |
| 1065 | enum |
| 1066 | { |
Dmitriy Vyukov | 5b79aa8 | 2013-03-14 13:48:19 +0400 | [diff] [blame] | 1067 | UseSpanType = 1, |
Jan Ziak | f8c5837 | 2012-09-24 20:08:05 -0400 | [diff] [blame] | 1068 | }; |