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