blob: 02226ede03bd55d1655519b36ff37b699e337429 [file] [log] [blame]
Ken Thompsonbbb20732008-06-05 19:38:39 -07001// 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 Thompsonbbb20732008-06-05 19:38:39 -07005/*
6 * basic types
7 */
8typedef signed char int8;
9typedef unsigned char uint8;
10typedef signed short int16;
11typedef unsigned short uint16;
12typedef signed int int32;
13typedef unsigned int uint32;
14typedef signed long long int int64;
15typedef unsigned long long int uint64;
16typedef float float32;
17typedef double float64;
Russ Cox0d3a0432009-03-30 00:01:07 -070018
19#ifdef _64BIT
Russ Cox75647d22008-11-17 12:32:35 -080020typedef uint64 uintptr;
Russ Cox0d3a0432009-03-30 00:01:07 -070021#else
22typedef uint32 uintptr;
23#endif
Ken Thompsonbbb20732008-06-05 19:38:39 -070024
25/*
26 * get rid of C types
Russ Cox3aa063d2008-11-23 17:08:55 -080027 * the / / / forces a syntax error immediately,
28 * which will show "last name: XXunsigned".
Ken Thompsonbbb20732008-06-05 19:38:39 -070029 */
Russ Cox3aa063d2008-11-23 17:08:55 -080030#define unsigned XXunsigned / / /
31#define signed XXsigned / / /
32#define char XXchar / / /
33#define short XXshort / / /
34#define int XXint / / /
35#define long XXlong / / /
36#define float XXfloat / / /
37#define double XXdouble / / /
Ken Thompsonbbb20732008-06-05 19:38:39 -070038
39/*
40 * defined types
41 */
42typedef uint8 bool;
43typedef uint8 byte;
Ken Thompson594175d2008-07-13 14:29:46 -070044typedef struct Alg Alg;
Russ Cox3aa063d2008-11-23 17:08:55 -080045typedef struct Array Array;
46typedef struct Func Func;
47typedef struct G G;
48typedef struct Gobuf Gobuf;
Russ Coxd28acc42008-08-04 16:43:49 -070049typedef struct Lock Lock;
Russ Cox3aa063d2008-11-23 17:08:55 -080050typedef struct M M;
Russ Coxd28acc42008-08-04 16:43:49 -070051typedef struct Mem Mem;
Russ Cox3aa063d2008-11-23 17:08:55 -080052typedef union Note Note;
53typedef struct Stktop Stktop;
Ken Thompson36570612009-04-09 18:16:21 -070054typedef struct String String;
Russ Cox3aa063d2008-11-23 17:08:55 -080055typedef struct Usema Usema;
Russ Coxc3077f72008-12-19 17:11:54 -080056typedef struct SigTab SigTab;
57typedef struct MCache MCache;
58typedef struct Iface Iface;
Russ Coxc7513ea2009-07-07 11:02:54 -070059typedef struct Itab Itab;
Russ Cox2da50222009-05-20 14:57:55 -070060typedef struct Eface Eface;
Russ Coxc7513ea2009-07-07 11:02:54 -070061typedef struct Type Type;
Ken Thompson1e1cc4e2009-01-27 12:03:53 -080062typedef struct Defer Defer;
Russ Cox764b6ec2009-07-08 13:55:57 -070063typedef struct hash Hmap;
Russ Cox5ddaf9a2009-07-08 15:00:54 -070064typedef struct Hchan Hchan;
Ken Thompson594175d2008-07-13 14:29:46 -070065
66/*
67 * per cpu declaration
68 */
69extern register G* g; // R15
70extern register M* m; // R14
71
72/*
73 * defined constants
74 */
75enum
76{
77 // G status
78 Gidle,
79 Grunnable,
Russ Coxd28acc42008-08-04 16:43:49 -070080 Grunning,
Russ Cox3f8aa662008-12-05 15:24:18 -080081 Gsyscall,
Ken Thompson52620032008-07-14 14:33:39 -070082 Gwaiting,
Russ Cox96824002008-08-05 14:18:47 -070083 Gmoribund,
Ken Thompson594175d2008-07-13 14:29:46 -070084 Gdead,
85};
86enum
87{
88 true = 1,
89 false = 0,
90};
91
92/*
93 * structures
94 */
Russ Coxd28acc42008-08-04 16:43:49 -070095struct Lock
96{
97 uint32 key;
Russ Cox376898c2008-09-09 11:50:14 -070098 uint32 sema; // for OS X
Russ Coxd28acc42008-08-04 16:43:49 -070099};
Russ Cox5ff12f82008-09-24 10:25:28 -0700100struct Usema
101{
102 uint32 u;
103 uint32 k;
104};
Russ Cox376898c2008-09-09 11:50:14 -0700105union Note
Russ Coxd28acc42008-08-04 16:43:49 -0700106{
Russ Cox376898c2008-09-09 11:50:14 -0700107 struct { // Linux
108 Lock lock;
109 };
110 struct { // OS X
111 int32 wakeup;
Russ Cox5ff12f82008-09-24 10:25:28 -0700112 Usema sema;
Russ Cox376898c2008-09-09 11:50:14 -0700113 };
Russ Coxd28acc42008-08-04 16:43:49 -0700114};
Ken Thompson594175d2008-07-13 14:29:46 -0700115struct String
Ken Thompsonbbb20732008-06-05 19:38:39 -0700116{
Ken Thompson36570612009-04-09 18:16:21 -0700117 byte* str;
Ken Thompsonbbb20732008-06-05 19:38:39 -0700118 int32 len;
Ken Thompson594175d2008-07-13 14:29:46 -0700119};
Russ Coxc3077f72008-12-19 17:11:54 -0800120struct Iface
121{
Russ Coxc7513ea2009-07-07 11:02:54 -0700122 Itab* tab;
Ken Thompson36570612009-04-09 18:16:21 -0700123 void* data;
Russ Coxc3077f72008-12-19 17:11:54 -0800124};
Russ Cox2da50222009-05-20 14:57:55 -0700125struct Eface
126{
Russ Coxc7513ea2009-07-07 11:02:54 -0700127 Type* type;
Russ Cox2da50222009-05-20 14:57:55 -0700128 void* data;
129};
Ken Thompson66a603c2008-08-27 17:28:30 -0700130
131struct Array
132{ // must not move anything
133 byte* array; // actual data
134 uint32 nel; // number of elements
Russ Cox75647d22008-11-17 12:32:35 -0800135 uint32 cap; // allocated number of elements
Ken Thompson66a603c2008-08-27 17:28:30 -0700136};
Ken Thompson751ce3a2008-07-11 19:16:39 -0700137struct Gobuf
138{
Russ Cox38020092009-06-17 16:31:02 -0700139 // The offsets of these fields are known to (hard-coded in) libmach.
Russ Cox7343e032009-06-17 15:12:16 -0700140 byte* sp;
141 byte* pc;
142 G* g;
Kai Backman111005d2009-06-25 11:26:10 -0700143 uintptr r0; // used on arm
Ken Thompson751ce3a2008-07-11 19:16:39 -0700144};
Ken Thompson7b454bb2008-07-09 11:35:26 -0700145struct G
Ken Thompson45288542008-07-08 17:19:17 -0700146{
Russ Cox38020092009-06-17 16:31:02 -0700147 byte* stackguard; // cannot move - also known to linker, libmach
148 byte* stackbase; // cannot move - also known to libmach
Russ Cox7343e032009-06-17 15:12:16 -0700149 Defer* defer;
Russ Cox38020092009-06-17 16:31:02 -0700150 Gobuf sched; // cannot move - also known to libmach
Ken Thompsone7d549f2008-07-16 13:50:23 -0700151 byte* stack0; // first stack segment
Russ Cox7343e032009-06-17 15:12:16 -0700152 byte* entry; // initial function
Rob Pike3835e012008-07-28 11:29:41 -0700153 G* alllink; // on allg
Ken Thompsone963cba2008-07-25 15:55:12 -0700154 void* param; // passed parameter on wakeup
155 int16 status;
Ken Thompson751ce3a2008-07-11 19:16:39 -0700156 int32 goid;
Ken Thompsone963cba2008-07-25 15:55:12 -0700157 int32 selgen; // valid sudog pointer
Russ Cox96824002008-08-05 14:18:47 -0700158 G* schedlink;
Ken Thompson1e1cc4e2009-01-27 12:03:53 -0800159 bool readyonstop;
Russ Cox7343e032009-06-17 15:12:16 -0700160 M* m; // for debuggers, but offset not hard-coded
Russ Coxd28acc42008-08-04 16:43:49 -0700161};
162struct Mem
163{
164 uint8* hunk;
165 uint32 nhunk;
166 uint64 nmmap;
167 uint64 nmal;
Ken Thompson45288542008-07-08 17:19:17 -0700168};
Ken Thompson45288542008-07-08 17:19:17 -0700169struct M
170{
Russ Cox38020092009-06-17 16:31:02 -0700171 // The offsets of these fields are known to (hard-coded in) libmach.
Russ Cox7343e032009-06-17 15:12:16 -0700172 G* g0; // goroutine with scheduling stack
173 void (*morepc)(void);
Russ Coxbba278a2009-07-08 18:16:09 -0700174 void* morefp; // frame pointer for more stack
Russ Cox7343e032009-06-17 15:12:16 -0700175 Gobuf morebuf; // gobuf arg to morestack
176
Russ Cox38020092009-06-17 16:31:02 -0700177 // Fields not known to debuggers.
Russ Cox7343e032009-06-17 15:12:16 -0700178 uint32 moreframe; // size arguments to morestack
179 uint32 moreargs;
180 uintptr cret; // return value from C
181 uint64 procid; // for debuggers, but offset not hard-coded
182 G* gsignal; // signal-handling G
183 uint32 tls[8]; // thread-local storage (for 386 extern register)
184 Gobuf sched; // scheduling stack
185 G* curg; // current running goroutine
Russ Coxefc86a72008-11-25 16:48:10 -0800186 int32 id;
Russ Coxda0a7d72008-12-19 03:13:39 -0800187 int32 mallocing;
Russ Cox8c357ce2009-06-15 21:31:56 -0700188 int32 gcing;
Russ Cox1ce17912009-01-26 17:37:05 -0800189 int32 locks;
Russ Cox96824002008-08-05 14:18:47 -0700190 Note havenextg;
191 G* nextg;
192 M* schedlink;
Russ Coxd28acc42008-08-04 16:43:49 -0700193 Mem mem;
Russ Cox376898c2008-09-09 11:50:14 -0700194 uint32 machport; // Return address for Mach IPC (OS X)
Russ Coxe29ce172008-12-18 15:42:28 -0800195 MCache *mcache;
Ken Thompson751ce3a2008-07-11 19:16:39 -0700196};
Ken Thompson52620032008-07-14 14:33:39 -0700197struct Stktop
Ken Thompson594175d2008-07-13 14:29:46 -0700198{
Russ Cox38020092009-06-17 16:31:02 -0700199 // The offsets of these fields are known to (hard-coded in) libmach.
Russ Cox7343e032009-06-17 15:12:16 -0700200 uint8* stackguard;
201 uint8* stackbase;
202 Gobuf gobuf;
203 uint32 args;
Russ Coxbba278a2009-07-08 18:16:09 -0700204
205 // Frame pointer: where args start in old frame.
206 // fp == gobuf.sp except in the case of a reflected
207 // function call, which uses an off-stack argument frame.
208 uint8* fp;
Ken Thompson45288542008-07-08 17:19:17 -0700209};
Ken Thompson594175d2008-07-13 14:29:46 -0700210struct Alg
Ken Thompson751ce3a2008-07-11 19:16:39 -0700211{
Russ Coxa52fb812009-06-04 21:09:06 -0700212 uintptr (*hash)(uint32, void*);
Ken Thompson594175d2008-07-13 14:29:46 -0700213 uint32 (*equal)(uint32, void*, void*);
214 void (*print)(uint32, void*);
215 void (*copy)(uint32, void*, void*);
Ken Thompson751ce3a2008-07-11 19:16:39 -0700216};
Ken Thompson594175d2008-07-13 14:29:46 -0700217struct SigTab
Ken Thompsonbbb20732008-06-05 19:38:39 -0700218{
Russ Coxdfa58932008-12-03 14:21:28 -0800219 int32 flags;
Ken Thompson594175d2008-07-13 14:29:46 -0700220 int8 *name;
Ken Thompsonbbb20732008-06-05 19:38:39 -0700221};
Russ Coxdfa58932008-12-03 14:21:28 -0800222enum
223{
224 SigCatch = 1<<0,
225 SigIgnore = 1<<1,
226 SigRestart = 1<<2,
227};
Ken Thompsonbbb20732008-06-05 19:38:39 -0700228
Russ Cox3aa063d2008-11-23 17:08:55 -0800229// (will be) shared with go; edit ../cmd/6g/sys.go too.
230// should move out of sys.go eventually.
231// also eventually, the loaded symbol table should
232// be closer to this form.
233struct Func
234{
Ken Thompson36570612009-04-09 18:16:21 -0700235 String name;
236 String type; // go type string
237 String src; // src file name
Russ Coxa5433362008-11-25 09:23:36 -0800238 uint64 entry; // entry pc
239 int64 frame; // stack frame size
240 Array pcln; // pc/ln tab for this func
241 int64 pc0; // starting pc, ln for table
242 int32 ln0;
Russ Coxefc86a72008-11-25 16:48:10 -0800243 int32 args; // number of 32-bit in/out args
244 int32 locals; // number of 32-bit locals
Russ Cox3aa063d2008-11-23 17:08:55 -0800245};
246
Ken Thompsonbbb20732008-06-05 19:38:39 -0700247/*
248 * defined macros
249 * you need super-goru privilege
250 * to add this list.
251 */
252#define nelem(x) (sizeof(x)/sizeof((x)[0]))
253#define nil ((void*)0)
254
255/*
Russ Coxeee50ae2008-12-19 12:05:22 -0800256 * known to compiler
257 */
258enum
259{
Russ Coxa7f6d402009-01-26 09:56:42 -0800260 AMEM,
261 ANOEQ,
Russ Coxeee50ae2008-12-19 12:05:22 -0800262 ASTRING,
Russ Coxeee50ae2008-12-19 12:05:22 -0800263 AINTER,
Russ Cox2da50222009-05-20 14:57:55 -0700264 ANILINTER,
Russ Cox9b6d3852009-01-26 12:36:21 -0800265 AFAKE,
Russ Coxa7f6d402009-01-26 09:56:42 -0800266 Amax
Russ Coxeee50ae2008-12-19 12:05:22 -0800267};
268
Russ Cox29aa3ff2009-07-02 21:25:46 -0700269
270enum {
271 Structrnd = sizeof(uintptr)
272};
273
Russ Coxeee50ae2008-12-19 12:05:22 -0800274/*
Ken Thompson47ab1c12009-01-27 13:23:28 -0800275 * deferred subroutine calls
Ken Thompson1e1cc4e2009-01-27 12:03:53 -0800276 */
277struct Defer
278{
279 int32 siz;
280 byte* sp;
281 byte* fn;
282 Defer* link;
283 byte args[8]; // padded to actual size
284};
285
286/*
Ken Thompson594175d2008-07-13 14:29:46 -0700287 * external data
288 */
Russ Coxa7f6d402009-01-26 09:56:42 -0800289extern Alg algarray[Amax];
Ken Thompson36570612009-04-09 18:16:21 -0700290extern String emptystring;
Ken Thompson594175d2008-07-13 14:29:46 -0700291G* allg;
292int32 goidgen;
Russ Coxd28acc42008-08-04 16:43:49 -0700293extern int32 gomaxprocs;
Rob Pike6e8dbc22008-09-12 09:44:41 -0700294extern int32 panicking;
Ken Thompson79fbbe32008-11-05 21:50:28 -0800295extern int32 maxround;
Ken Thompson594175d2008-07-13 14:29:46 -0700296
297/*
Rob Pike8e82a672008-06-30 11:50:36 -0700298 * common functions and data
299 */
Ken Thompson751ce3a2008-07-11 19:16:39 -0700300int32 strcmp(byte*, byte*);
Russ Cox3aa063d2008-11-23 17:08:55 -0800301int32 findnull(byte*);
Rob Pike8e82a672008-06-30 11:50:36 -0700302void dump(byte*, int32);
Ken Thompson751ce3a2008-07-11 19:16:39 -0700303int32 runetochar(byte*, int32);
Rob Pike54ec7192009-04-12 17:01:17 -0700304int32 charntorune(int32*, uint8*, int32);
Rob Pike8e82a672008-06-30 11:50:36 -0700305
Rob Pike8e82a672008-06-30 11:50:36 -0700306/*
Ken Thompson4e8142c2008-06-16 22:34:50 -0700307 * very low level c-called
Ken Thompsonbbb20732008-06-05 19:38:39 -0700308 */
Russ Cox7343e032009-06-17 15:12:16 -0700309void gogo(Gobuf*, uintptr);
310void gogocall(Gobuf*, void(*)(void));
311uintptr gosave(Gobuf*);
312void sys·lessstack(void);
Russ Cox36096242009-01-16 14:58:14 -0800313void goargs(void);
Ken Thompsonbbb20732008-06-05 19:38:39 -0700314void FLUSH(void*);
Rob Piked3204ef2008-06-30 14:39:47 -0700315void* getu(void);
Ken Thompson4e8142c2008-06-16 22:34:50 -0700316void throw(int8*);
Ken Thompson594175d2008-07-13 14:29:46 -0700317uint32 rnd(uint32, uint32);
Ken Thompsonbbb20732008-06-05 19:38:39 -0700318void prints(int8*);
Russ Coxefc86a72008-11-25 16:48:10 -0800319void printf(int8*, ...);
Russ Cox3aa063d2008-11-23 17:08:55 -0800320byte* mchr(byte*, byte, byte*);
Ken Thompsone1a06cc2008-06-15 20:24:30 -0700321void mcpy(byte*, byte*, uint32);
Russ Cox9b6d3852009-01-26 12:36:21 -0800322int32 mcmp(byte*, byte*, uint32);
Ken Thompsonbc0b4f02008-11-13 10:35:44 -0800323void mmov(byte*, byte*, uint32);
Ken Thompsone1a06cc2008-06-15 20:24:30 -0700324void* mal(uint32);
Ken Thompson36570612009-04-09 18:16:21 -0700325uint32 cmpstring(String, String);
326String gostring(byte*);
Rob Pikeaeb43982008-06-21 15:36:23 -0700327void initsig(void);
Russ Coxfb40f882008-09-22 13:47:53 -0700328int32 gotraceback(void);
Ken Thompson751ce3a2008-07-11 19:16:39 -0700329void traceback(uint8 *pc, uint8 *sp, G* gp);
Rob Pike3835e012008-07-28 11:29:41 -0700330void tracebackothers(G*);
Rob Pikec870ac22008-07-14 20:54:55 -0700331int32 open(byte*, int32, ...);
Rob Pikec870ac22008-07-14 20:54:55 -0700332int32 write(int32, void*, int32);
Russ Coxd28acc42008-08-04 16:43:49 -0700333bool cas(uint32*, uint32, uint32);
Russ Coxaa3222d82009-06-02 23:02:12 -0700334void jmpdefer(byte*, void*);
Russ Coxd28acc42008-08-04 16:43:49 -0700335void exit1(int32);
336void ready(G*);
337byte* getenv(int8*);
338int32 atoi(byte*);
Russ Cox96824002008-08-05 14:18:47 -0700339void newosproc(M *m, G *g, void *stk, void (*fn)(void));
Russ Coxa67258f2008-09-18 15:56:46 -0700340void sigaltstack(void*, void*);
341void signalstack(byte*, int32);
342G* malg(int32);
343void minit(void);
Russ Cox0d3a0432009-03-30 00:01:07 -0700344Func* findfunc(uintptr);
Russ Coxa5433362008-11-25 09:23:36 -0800345int32 funcline(Func*, uint64);
Russ Cox79e1db22008-12-04 08:30:54 -0800346void* stackalloc(uint32);
347void stackfree(void*);
Russ Coxe29ce172008-12-18 15:42:28 -0800348MCache* allocmcache(void);
349void mallocinit(void);
Russ Coxa7f6d402009-01-26 09:56:42 -0800350bool ifaceeq(Iface, Iface);
Russ Cox2da50222009-05-20 14:57:55 -0700351bool efaceeq(Eface, Eface);
Russ Coxa52fb812009-06-04 21:09:06 -0700352uintptr ifacehash(Iface);
353uintptr efacehash(Eface);
354uintptr nohash(uint32, void*);
Russ Coxa7f6d402009-01-26 09:56:42 -0800355uint32 noequal(uint32, void*, void*);
Russ Cox1ce17912009-01-26 17:37:05 -0800356void* malloc(uintptr size);
357void* mallocgc(uintptr size);
358void free(void *v);
Russ Cox918afd942009-05-08 15:21:41 -0700359void exit(int32);
360void breakpoint(void);
361void gosched(void);
362void goexit(void);
Russ Coxd28acc42008-08-04 16:43:49 -0700363
Russ Cox5bb0c4f2008-12-15 10:50:33 -0800364#pragma varargck argpos printf 1
365
366#pragma varargck type "d" int32
367#pragma varargck type "d" uint32
368#pragma varargck type "D" int64
369#pragma varargck type "D" uint64
370#pragma varargck type "x" int32
371#pragma varargck type "x" uint32
372#pragma varargck type "X" int64
373#pragma varargck type "X" uint64
374#pragma varargck type "p" void*
Russ Cox0d3a0432009-03-30 00:01:07 -0700375#pragma varargck type "p" uintptr
Russ Cox5bb0c4f2008-12-15 10:50:33 -0800376#pragma varargck type "s" int8*
377#pragma varargck type "s" uint8*
Ken Thompson36570612009-04-09 18:16:21 -0700378#pragma varargck type "S" String
Russ Cox5bb0c4f2008-12-15 10:50:33 -0800379
Russ Cox3f8aa662008-12-05 15:24:18 -0800380// TODO(rsc): Remove. These are only temporary,
381// for the mark and sweep collector.
382void stoptheworld(void);
383void starttheworld(void);
384
Russ Coxd28acc42008-08-04 16:43:49 -0700385/*
386 * mutual exclusion locks. in the uncontended case,
387 * as fast as spin locks (just a few user-level instructions),
388 * but on the contention path they sleep in the kernel.
Russ Cox96824002008-08-05 14:18:47 -0700389 * a zeroed Lock is unlocked (no need to initialize each lock).
Russ Coxd28acc42008-08-04 16:43:49 -0700390 */
391void lock(Lock*);
392void unlock(Lock*);
Russ Coxd28acc42008-08-04 16:43:49 -0700393
394/*
Russ Cox96824002008-08-05 14:18:47 -0700395 * sleep and wakeup on one-time events.
Russ Coxf7f63292008-08-05 14:21:42 -0700396 * before any calls to notesleep or notewakeup,
Russ Cox96824002008-08-05 14:18:47 -0700397 * must call noteclear to initialize the Note.
398 * then, any number of threads can call notesleep
399 * and exactly one thread can call notewakeup (once).
400 * once notewakeup has been called, all the notesleeps
401 * will return. future notesleeps will return immediately.
Russ Coxd28acc42008-08-04 16:43:49 -0700402 */
Russ Cox96824002008-08-05 14:18:47 -0700403void noteclear(Note*);
404void notesleep(Note*);
405void notewakeup(Note*);
Ken Thompson4e8142c2008-06-16 22:34:50 -0700406
407/*
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800408 * Redefine methods for the benefit of gcc, which does not support
409 * UTF-8 characters in identifiers.
410 */
411#ifndef __GNUC__
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800412#define sys_memclr sys·memclr
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800413#define sys_getcallerpc sys·getcallerpc
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800414#define sys_mmap sys·mmap
415#define sys_printarray sys·printarray
416#define sys_printbool sys·printbool
417#define sys_printfloat sys·printfloat
418#define sys_printhex sys·printhex
419#define sys_printint sys·printint
Russ Cox2da50222009-05-20 14:57:55 -0700420#define sys_printiface sys·printiface
421#define sys_printeface sys·printeface
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800422#define sys_printpc sys·printpc
423#define sys_printpointer sys·printpointer
424#define sys_printstring sys·printstring
425#define sys_printuint sys·printuint
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800426#define sys_setcallerpc sys·setcallerpc
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800427#endif
428
429/*
Russ Cox1f8a40d2009-01-22 16:23:44 -0800430 * low level go-called
Ken Thompson4e8142c2008-06-16 22:34:50 -0700431 */
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800432uint8* sys_mmap(byte*, uint32, int32, int32, int32, uint32);
433void sys_memclr(byte*, uint32);
434void sys_setcallerpc(void*, void*);
435void* sys_getcallerpc(void*);
Ken Thompsonbbb20732008-06-05 19:38:39 -0700436
437/*
Ken Thompson4e8142c2008-06-16 22:34:50 -0700438 * runtime go-called
Ken Thompsonbbb20732008-06-05 19:38:39 -0700439 */
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800440void sys_printbool(bool);
441void sys_printfloat(float64);
442void sys_printint(int64);
Russ Cox2da50222009-05-20 14:57:55 -0700443void sys_printiface(Iface);
444void sys_printeface(Eface);
Ken Thompson36570612009-04-09 18:16:21 -0700445void sys_printstring(String);
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800446void sys_printpc(void*);
447void sys_printpointer(void*);
448void sys_printuint(uint64);
449void sys_printhex(uint64);
450void sys_printarray(Array);
Rob Pike6db99de2008-07-08 10:36:43 -0700451
452/*
Russ Cox1f8a40d2009-01-22 16:23:44 -0800453 * wrapped for go users
Rob Pike6db99de2008-07-08 10:36:43 -0700454 */
Russ Cox1f8a40d2009-01-22 16:23:44 -0800455float64 Inf(int32 sign);
456float64 NaN(void);
457float32 float32frombits(uint32 i);
458uint32 float32tobits(float32 f);
459float64 float64frombits(uint64 i);
460uint64 float64tobits(float64 f);
461float64 frexp(float64 d, int32 *ep);
462bool isInf(float64 f, int32 sign);
463bool isNaN(float64 f);
464float64 ldexp(float64 d, int32 e);
465float64 modf(float64 d, float64 *ip);
466void semacquire(uint32*);
467void semrelease(uint32*);
Russ Cox5ddaf9a2009-07-08 15:00:54 -0700468
Russ Cox764b6ec2009-07-08 13:55:57 -0700469void mapassign(Hmap*, byte*, byte*);
470void mapaccess(Hmap*, byte*, byte*, bool*);
471struct hash_iter* mapiterinit(Hmap*);
472void mapiternext(struct hash_iter*);
473bool mapiterkey(struct hash_iter*, void*);
474void mapiterkeyvalue(struct hash_iter*, void*, void*);
475Hmap* makemap(uint32, uint32, uint32, uint32, uint32);
Russ Cox5ddaf9a2009-07-08 15:00:54 -0700476
477Hchan* makechan(uint32, uint32, uint32);
478void chansend(Hchan*, void*, bool*);
479void chanrecv(Hchan*, void*, bool*);