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 | 75647d2 | 2008-11-17 12:32:35 -0800 | [diff] [blame] | 18 | typedef uint64 uintptr; |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 19 | |
| 20 | /* |
| 21 | * get rid of C types |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 22 | * the / / / forces a syntax error immediately, |
| 23 | * which will show "last name: XXunsigned". |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 24 | */ |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 25 | #define unsigned XXunsigned / / / |
| 26 | #define signed XXsigned / / / |
| 27 | #define char XXchar / / / |
| 28 | #define short XXshort / / / |
| 29 | #define int XXint / / / |
| 30 | #define long XXlong / / / |
| 31 | #define float XXfloat / / / |
| 32 | #define double XXdouble / / / |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 33 | |
| 34 | /* |
| 35 | * defined types |
| 36 | */ |
| 37 | typedef uint8 bool; |
| 38 | typedef uint8 byte; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 39 | typedef struct Alg Alg; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 40 | typedef struct Array Array; |
| 41 | typedef struct Func Func; |
| 42 | typedef struct G G; |
| 43 | typedef struct Gobuf Gobuf; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 44 | typedef struct Lock Lock; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 45 | typedef struct M M; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 46 | typedef struct Mem Mem; |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 47 | typedef union Note Note; |
| 48 | typedef struct Stktop Stktop; |
| 49 | typedef struct String *string; |
| 50 | typedef struct Usema Usema; |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 51 | typedef struct SigTab SigTab; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 52 | |
| 53 | /* |
| 54 | * per cpu declaration |
| 55 | */ |
| 56 | extern register G* g; // R15 |
| 57 | extern register M* m; // R14 |
| 58 | |
| 59 | /* |
| 60 | * defined constants |
| 61 | */ |
| 62 | enum |
| 63 | { |
| 64 | // G status |
| 65 | Gidle, |
| 66 | Grunnable, |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 67 | Grunning, |
Russ Cox | 3f8aa66 | 2008-12-05 15:24:18 -0800 | [diff] [blame] | 68 | Gsyscall, |
Ken Thompson | 5262003 | 2008-07-14 14:33:39 -0700 | [diff] [blame] | 69 | Gwaiting, |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 70 | Gmoribund, |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 71 | Gdead, |
| 72 | }; |
| 73 | enum |
| 74 | { |
| 75 | true = 1, |
| 76 | false = 0, |
| 77 | }; |
Russ Cox | 75647d2 | 2008-11-17 12:32:35 -0800 | [diff] [blame] | 78 | enum |
| 79 | { |
| 80 | SmallFreeClasses = 168, // number of small free lists in malloc |
| 81 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 82 | |
| 83 | /* |
| 84 | * structures |
| 85 | */ |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 86 | struct Lock |
| 87 | { |
| 88 | uint32 key; |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 89 | uint32 sema; // for OS X |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 90 | }; |
Russ Cox | 5ff12f8 | 2008-09-24 10:25:28 -0700 | [diff] [blame] | 91 | struct Usema |
| 92 | { |
| 93 | uint32 u; |
| 94 | uint32 k; |
| 95 | }; |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 96 | union Note |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 97 | { |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 98 | struct { // Linux |
| 99 | Lock lock; |
| 100 | }; |
| 101 | struct { // OS X |
| 102 | int32 wakeup; |
Russ Cox | 5ff12f8 | 2008-09-24 10:25:28 -0700 | [diff] [blame] | 103 | Usema sema; |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 104 | }; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 105 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 106 | struct String |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 107 | { |
| 108 | int32 len; |
| 109 | byte str[1]; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 110 | }; |
Ken Thompson | 66a603c | 2008-08-27 17:28:30 -0700 | [diff] [blame] | 111 | |
| 112 | struct Array |
| 113 | { // must not move anything |
| 114 | byte* array; // actual data |
| 115 | uint32 nel; // number of elements |
Russ Cox | 75647d2 | 2008-11-17 12:32:35 -0800 | [diff] [blame] | 116 | uint32 cap; // allocated number of elements |
Ken Thompson | 66a603c | 2008-08-27 17:28:30 -0700 | [diff] [blame] | 117 | byte b[8]; // actual array - may not be contig |
| 118 | }; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 119 | struct Gobuf |
| 120 | { |
| 121 | byte* SP; |
| 122 | byte* PC; |
| 123 | }; |
Ken Thompson | 7b454bb | 2008-07-09 11:35:26 -0700 | [diff] [blame] | 124 | struct G |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 125 | { |
| 126 | byte* stackguard; // must not move |
| 127 | byte* stackbase; // must not move |
Ken Thompson | e7d549f | 2008-07-16 13:50:23 -0700 | [diff] [blame] | 128 | byte* stack0; // first stack segment |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 129 | Gobuf sched; |
Rob Pike | 3835e01 | 2008-07-28 11:29:41 -0700 | [diff] [blame] | 130 | G* alllink; // on allg |
Ken Thompson | e963cba | 2008-07-25 15:55:12 -0700 | [diff] [blame] | 131 | void* param; // passed parameter on wakeup |
| 132 | int16 status; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 133 | int32 goid; |
Ken Thompson | e963cba | 2008-07-25 15:55:12 -0700 | [diff] [blame] | 134 | int32 selgen; // valid sudog pointer |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 135 | G* schedlink; |
Russ Cox | a61bb95 | 2008-09-24 14:13:07 -0700 | [diff] [blame] | 136 | bool readyonstop; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 137 | M* m; // for debuggers |
| 138 | }; |
| 139 | struct Mem |
| 140 | { |
| 141 | uint8* hunk; |
| 142 | uint32 nhunk; |
| 143 | uint64 nmmap; |
| 144 | uint64 nmal; |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 145 | }; |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 146 | struct M |
| 147 | { |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 148 | G* g0; // g0 w interrupt stack - must not move |
| 149 | uint64 morearg; // arg to morestack - must not move |
Ken Thompson | e7d549f | 2008-07-16 13:50:23 -0700 | [diff] [blame] | 150 | uint64 cret; // return value from C - must not move |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 151 | uint64 procid; // for debuggers - must not move |
Russ Cox | a67258f | 2008-09-18 15:56:46 -0700 | [diff] [blame] | 152 | G* gsignal; // signal-handling G - must not move |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 153 | G* curg; // current running goroutine |
Ken Thompson | e7d549f | 2008-07-16 13:50:23 -0700 | [diff] [blame] | 154 | G* lastg; // last running goroutine - to emulate fifo |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 155 | Gobuf sched; |
| 156 | Gobuf morestack; |
| 157 | byte* moresp; |
| 158 | int32 siz1; |
| 159 | int32 siz2; |
Russ Cox | efc86a7 | 2008-11-25 16:48:10 -0800 | [diff] [blame] | 160 | int32 id; |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 161 | Note havenextg; |
| 162 | G* nextg; |
| 163 | M* schedlink; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 164 | Mem mem; |
Russ Cox | 376898c | 2008-09-09 11:50:14 -0700 | [diff] [blame] | 165 | uint32 machport; // Return address for Mach IPC (OS X) |
Russ Cox | 75647d2 | 2008-11-17 12:32:35 -0800 | [diff] [blame] | 166 | void* freelist[SmallFreeClasses]; |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 167 | }; |
Ken Thompson | 5262003 | 2008-07-14 14:33:39 -0700 | [diff] [blame] | 168 | struct Stktop |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 169 | { |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 170 | uint8* oldbase; |
| 171 | uint8* oldsp; |
| 172 | uint64 magic; |
| 173 | uint8* oldguard; |
Ken Thompson | 4528854 | 2008-07-08 17:19:17 -0700 | [diff] [blame] | 174 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 175 | struct Alg |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 176 | { |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 177 | uint64 (*hash)(uint32, void*); |
| 178 | uint32 (*equal)(uint32, void*, void*); |
| 179 | void (*print)(uint32, void*); |
| 180 | void (*copy)(uint32, void*, void*); |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 181 | }; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 182 | struct SigTab |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 183 | { |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 184 | int32 flags; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 185 | int8 *name; |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 186 | }; |
Russ Cox | dfa5893 | 2008-12-03 14:21:28 -0800 | [diff] [blame] | 187 | enum |
| 188 | { |
| 189 | SigCatch = 1<<0, |
| 190 | SigIgnore = 1<<1, |
| 191 | SigRestart = 1<<2, |
| 192 | }; |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 193 | |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 194 | // (will be) shared with go; edit ../cmd/6g/sys.go too. |
| 195 | // should move out of sys.go eventually. |
| 196 | // also eventually, the loaded symbol table should |
| 197 | // be closer to this form. |
| 198 | struct Func |
| 199 | { |
| 200 | string name; |
Russ Cox | a543336 | 2008-11-25 09:23:36 -0800 | [diff] [blame] | 201 | string type; // go type string |
| 202 | string src; // src file name |
| 203 | uint64 entry; // entry pc |
| 204 | int64 frame; // stack frame size |
| 205 | Array pcln; // pc/ln tab for this func |
| 206 | int64 pc0; // starting pc, ln for table |
| 207 | int32 ln0; |
Russ Cox | efc86a7 | 2008-11-25 16:48:10 -0800 | [diff] [blame] | 208 | int32 args; // number of 32-bit in/out args |
| 209 | int32 locals; // number of 32-bit locals |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 210 | }; |
| 211 | |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 212 | /* |
| 213 | * defined macros |
| 214 | * you need super-goru privilege |
| 215 | * to add this list. |
| 216 | */ |
| 217 | #define nelem(x) (sizeof(x)/sizeof((x)[0])) |
| 218 | #define nil ((void*)0) |
| 219 | |
| 220 | /* |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 221 | * external data |
| 222 | */ |
Russ Cox | 3935610 | 2008-12-09 16:16:07 -0800 | [diff] [blame] | 223 | extern Alg algarray[4]; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 224 | extern string emptystring; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 225 | G* allg; |
| 226 | int32 goidgen; |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 227 | extern int32 gomaxprocs; |
Rob Pike | 6e8dbc2 | 2008-09-12 09:44:41 -0700 | [diff] [blame] | 228 | extern int32 panicking; |
Ken Thompson | 79fbbe3 | 2008-11-05 21:50:28 -0800 | [diff] [blame] | 229 | extern int32 maxround; |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 230 | |
| 231 | /* |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 232 | * common functions and data |
| 233 | */ |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 234 | int32 strcmp(byte*, byte*); |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 235 | int32 findnull(byte*); |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 236 | void dump(byte*, int32); |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 237 | int32 runetochar(byte*, int32); |
| 238 | int32 chartorune(uint32*, byte*); |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 239 | |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 240 | /* |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 241 | * very low level c-called |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 242 | */ |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 243 | int32 gogo(Gobuf*); |
| 244 | int32 gosave(Gobuf*); |
Rob Pike | 2da9783 | 2008-07-12 11:30:53 -0700 | [diff] [blame] | 245 | int32 gogoret(Gobuf*, uint64); |
| 246 | void retfromnewstack(void); |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 247 | void setspgoto(byte*, void(*)(void), void(*)(void)); |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 248 | void FLUSH(void*); |
Rob Pike | d3204ef | 2008-06-30 14:39:47 -0700 | [diff] [blame] | 249 | void* getu(void); |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 250 | void throw(int8*); |
Ken Thompson | 594175d | 2008-07-13 14:29:46 -0700 | [diff] [blame] | 251 | uint32 rnd(uint32, uint32); |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 252 | void prints(int8*); |
Russ Cox | efc86a7 | 2008-11-25 16:48:10 -0800 | [diff] [blame] | 253 | void printf(int8*, ...); |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 254 | byte* mchr(byte*, byte, byte*); |
Ken Thompson | e1a06cc | 2008-06-15 20:24:30 -0700 | [diff] [blame] | 255 | void mcpy(byte*, byte*, uint32); |
Ken Thompson | bc0b4f0 | 2008-11-13 10:35:44 -0800 | [diff] [blame] | 256 | void mmov(byte*, byte*, uint32); |
Ken Thompson | e1a06cc | 2008-06-15 20:24:30 -0700 | [diff] [blame] | 257 | void* mal(uint32); |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 258 | uint32 cmpstring(string, string); |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 259 | string gostring(byte*); |
Rob Pike | aeb4398 | 2008-06-21 15:36:23 -0700 | [diff] [blame] | 260 | void initsig(void); |
Russ Cox | fb40f88 | 2008-09-22 13:47:53 -0700 | [diff] [blame] | 261 | int32 gotraceback(void); |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 262 | void traceback(uint8 *pc, uint8 *sp, G* gp); |
Rob Pike | 3835e01 | 2008-07-28 11:29:41 -0700 | [diff] [blame] | 263 | void tracebackothers(G*); |
Rob Pike | c870ac2 | 2008-07-14 20:54:55 -0700 | [diff] [blame] | 264 | int32 open(byte*, int32, ...); |
Rob Pike | 3e4e83a | 2008-06-26 14:09:26 -0700 | [diff] [blame] | 265 | int32 read(int32, void*, int32); |
Rob Pike | c870ac2 | 2008-07-14 20:54:55 -0700 | [diff] [blame] | 266 | int32 write(int32, void*, int32); |
Rob Pike | 3e4e83a | 2008-06-26 14:09:26 -0700 | [diff] [blame] | 267 | void close(int32); |
| 268 | int32 fstat(int32, void*); |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 269 | bool cas(uint32*, uint32, uint32); |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 270 | void exit1(int32); |
| 271 | void ready(G*); |
| 272 | byte* getenv(int8*); |
| 273 | int32 atoi(byte*); |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 274 | void newosproc(M *m, G *g, void *stk, void (*fn)(void)); |
Russ Cox | a67258f | 2008-09-18 15:56:46 -0700 | [diff] [blame] | 275 | void sigaltstack(void*, void*); |
| 276 | void signalstack(byte*, int32); |
| 277 | G* malg(int32); |
| 278 | void minit(void); |
Russ Cox | 3aa063d | 2008-11-23 17:08:55 -0800 | [diff] [blame] | 279 | Func* findfunc(uint64); |
Russ Cox | a543336 | 2008-11-25 09:23:36 -0800 | [diff] [blame] | 280 | int32 funcline(Func*, uint64); |
Russ Cox | 79e1db2 | 2008-12-04 08:30:54 -0800 | [diff] [blame] | 281 | void* stackalloc(uint32); |
| 282 | void stackfree(void*); |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 283 | |
Russ Cox | 5bb0c4f | 2008-12-15 10:50:33 -0800 | [diff] [blame^] | 284 | #pragma varargck argpos printf 1 |
| 285 | |
| 286 | #pragma varargck type "d" int32 |
| 287 | #pragma varargck type "d" uint32 |
| 288 | #pragma varargck type "D" int64 |
| 289 | #pragma varargck type "D" uint64 |
| 290 | #pragma varargck type "x" int32 |
| 291 | #pragma varargck type "x" uint32 |
| 292 | #pragma varargck type "X" int64 |
| 293 | #pragma varargck type "X" uint64 |
| 294 | #pragma varargck type "p" void* |
| 295 | #pragma varargck type "p" uint64 |
| 296 | #pragma varargck type "s" int8* |
| 297 | #pragma varargck type "s" uint8* |
| 298 | #pragma varargck type "S" string |
| 299 | |
Russ Cox | 3f8aa66 | 2008-12-05 15:24:18 -0800 | [diff] [blame] | 300 | // TODO(rsc): Remove. These are only temporary, |
| 301 | // for the mark and sweep collector. |
| 302 | void stoptheworld(void); |
| 303 | void starttheworld(void); |
| 304 | |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 305 | /* |
| 306 | * mutual exclusion locks. in the uncontended case, |
| 307 | * as fast as spin locks (just a few user-level instructions), |
| 308 | * but on the contention path they sleep in the kernel. |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 309 | * a zeroed Lock is unlocked (no need to initialize each lock). |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 310 | */ |
| 311 | void lock(Lock*); |
| 312 | void unlock(Lock*); |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 313 | |
| 314 | /* |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 315 | * sleep and wakeup on one-time events. |
Russ Cox | f7f6329 | 2008-08-05 14:21:42 -0700 | [diff] [blame] | 316 | * before any calls to notesleep or notewakeup, |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 317 | * must call noteclear to initialize the Note. |
| 318 | * then, any number of threads can call notesleep |
| 319 | * and exactly one thread can call notewakeup (once). |
| 320 | * once notewakeup has been called, all the notesleeps |
| 321 | * will return. future notesleeps will return immediately. |
Russ Cox | d28acc4 | 2008-08-04 16:43:49 -0700 | [diff] [blame] | 322 | */ |
Russ Cox | 9682400 | 2008-08-05 14:18:47 -0700 | [diff] [blame] | 323 | void noteclear(Note*); |
| 324 | void notesleep(Note*); |
| 325 | void notewakeup(Note*); |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 326 | |
| 327 | /* |
| 328 | * low level go -called |
| 329 | */ |
Ken Thompson | 751ce3a | 2008-07-11 19:16:39 -0700 | [diff] [blame] | 330 | void sys·goexit(void); |
| 331 | void sys·gosched(void); |
Ken Thompson | 7d11924 | 2008-06-24 17:16:06 -0700 | [diff] [blame] | 332 | void sys·exit(int32); |
| 333 | void sys·write(int32, void*, int32); |
| 334 | void sys·breakpoint(void); |
| 335 | uint8* sys·mmap(byte*, uint32, int32, int32, int32, uint32); |
| 336 | void sys·memclr(byte*, uint32); |
Ken Thompson | cb9b103 | 2008-07-24 15:57:30 -0700 | [diff] [blame] | 337 | void sys·setcallerpc(void*, void*); |
Ken Thompson | 7d11924 | 2008-06-24 17:16:06 -0700 | [diff] [blame] | 338 | void* sys·getcallerpc(void*); |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 339 | |
| 340 | /* |
Ken Thompson | 4e8142c | 2008-06-16 22:34:50 -0700 | [diff] [blame] | 341 | * runtime go-called |
Ken Thompson | bbb2073 | 2008-06-05 19:38:39 -0700 | [diff] [blame] | 342 | */ |
Ken Thompson | 7d11924 | 2008-06-24 17:16:06 -0700 | [diff] [blame] | 343 | void sys·printbool(bool); |
| 344 | void sys·printfloat(float64); |
| 345 | void sys·printint(int64); |
| 346 | void sys·printstring(string); |
Rob Pike | 8e82a67 | 2008-06-30 11:50:36 -0700 | [diff] [blame] | 347 | void sys·printpc(void*); |
Ken Thompson | 7d11924 | 2008-06-24 17:16:06 -0700 | [diff] [blame] | 348 | void sys·printpointer(void*); |
Russ Cox | efc86a7 | 2008-11-25 16:48:10 -0800 | [diff] [blame] | 349 | void sys·printuint(uint64); |
| 350 | void sys·printhex(uint64); |
Ken Thompson | 7d11924 | 2008-06-24 17:16:06 -0700 | [diff] [blame] | 351 | void sys·catstring(string, string, string); |
| 352 | void sys·cmpstring(string, string, int32); |
| 353 | void sys·slicestring(string, int32, int32, string); |
| 354 | void sys·indexstring(string, int32, byte); |
| 355 | void sys·intstring(int64, string); |
Russ Cox | e876635 | 2008-11-10 14:54:10 -0800 | [diff] [blame] | 356 | bool isInf(float64, int32); |
| 357 | bool isNaN(float64); |
Rob Pike | 6db99de | 2008-07-08 10:36:43 -0700 | [diff] [blame] | 358 | |
| 359 | /* |
| 360 | * User go-called |
| 361 | */ |
Rob Pike | 3e4e83a | 2008-06-26 14:09:26 -0700 | [diff] [blame] | 362 | void sys·readfile(string, string, bool); |
Rob Pike | 6db99de | 2008-07-08 10:36:43 -0700 | [diff] [blame] | 363 | void sys·bytestorune(byte*, int32, int32, int32, int32); |
Rob Pike | 7ee60b1 | 2008-10-07 10:03:34 -0700 | [diff] [blame] | 364 | void sys·stringtorune(string, int32, int32, int32); |
Russ Cox | 3f8aa66 | 2008-12-05 15:24:18 -0800 | [diff] [blame] | 365 | void sys·semacquire(uint32*); |
| 366 | void sys·semrelease(uint32*); |