blob: c63512db6adace41de860ba796021d46d83c9361 [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 Cox75647d22008-11-17 12:32:35 -080018typedef uint64 uintptr;
Ken Thompsonbbb20732008-06-05 19:38:39 -070019
20/*
21 * get rid of C types
Russ Cox3aa063d2008-11-23 17:08:55 -080022 * the / / / forces a syntax error immediately,
23 * which will show "last name: XXunsigned".
Ken Thompsonbbb20732008-06-05 19:38:39 -070024 */
Russ Cox3aa063d2008-11-23 17:08:55 -080025#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 Thompsonbbb20732008-06-05 19:38:39 -070033
34/*
35 * defined types
36 */
37typedef uint8 bool;
38typedef uint8 byte;
Ken Thompson594175d2008-07-13 14:29:46 -070039typedef struct Alg Alg;
Russ Cox3aa063d2008-11-23 17:08:55 -080040typedef struct Array Array;
41typedef struct Func Func;
42typedef struct G G;
43typedef struct Gobuf Gobuf;
Russ Coxd28acc42008-08-04 16:43:49 -070044typedef struct Lock Lock;
Russ Cox3aa063d2008-11-23 17:08:55 -080045typedef struct M M;
Russ Coxd28acc42008-08-04 16:43:49 -070046typedef struct Mem Mem;
Russ Cox3aa063d2008-11-23 17:08:55 -080047typedef union Note Note;
48typedef struct Stktop Stktop;
49typedef struct String *string;
50typedef struct Usema Usema;
Russ Coxc3077f72008-12-19 17:11:54 -080051typedef struct SigTab SigTab;
52typedef struct MCache MCache;
53typedef struct Iface Iface;
54typedef struct Itype Itype;
Ken Thompson1e1cc4e2009-01-27 12:03:53 -080055typedef struct Defer Defer;
Ken Thompson594175d2008-07-13 14:29:46 -070056
57/*
58 * per cpu declaration
59 */
60extern register G* g; // R15
61extern register M* m; // R14
62
63/*
64 * defined constants
65 */
66enum
67{
68 // G status
69 Gidle,
70 Grunnable,
Russ Coxd28acc42008-08-04 16:43:49 -070071 Grunning,
Russ Cox3f8aa662008-12-05 15:24:18 -080072 Gsyscall,
Ken Thompson52620032008-07-14 14:33:39 -070073 Gwaiting,
Russ Cox96824002008-08-05 14:18:47 -070074 Gmoribund,
Ken Thompson594175d2008-07-13 14:29:46 -070075 Gdead,
76};
77enum
78{
79 true = 1,
80 false = 0,
81};
82
83/*
84 * structures
85 */
Russ Coxd28acc42008-08-04 16:43:49 -070086struct Lock
87{
88 uint32 key;
Russ Cox376898c2008-09-09 11:50:14 -070089 uint32 sema; // for OS X
Russ Coxd28acc42008-08-04 16:43:49 -070090};
Russ Cox5ff12f82008-09-24 10:25:28 -070091struct Usema
92{
93 uint32 u;
94 uint32 k;
95};
Russ Cox376898c2008-09-09 11:50:14 -070096union Note
Russ Coxd28acc42008-08-04 16:43:49 -070097{
Russ Cox376898c2008-09-09 11:50:14 -070098 struct { // Linux
99 Lock lock;
100 };
101 struct { // OS X
102 int32 wakeup;
Russ Cox5ff12f82008-09-24 10:25:28 -0700103 Usema sema;
Russ Cox376898c2008-09-09 11:50:14 -0700104 };
Russ Coxd28acc42008-08-04 16:43:49 -0700105};
Ken Thompson594175d2008-07-13 14:29:46 -0700106struct String
Ken Thompsonbbb20732008-06-05 19:38:39 -0700107{
108 int32 len;
109 byte str[1];
Ken Thompson594175d2008-07-13 14:29:46 -0700110};
Russ Coxc3077f72008-12-19 17:11:54 -0800111struct Iface
112{
113 Itype *type;
Russ Cox484ba932009-01-09 00:17:46 -0800114 void *data;
Russ Coxc3077f72008-12-19 17:11:54 -0800115};
Ken Thompson66a603c2008-08-27 17:28:30 -0700116
117struct Array
118{ // must not move anything
119 byte* array; // actual data
120 uint32 nel; // number of elements
Russ Cox75647d22008-11-17 12:32:35 -0800121 uint32 cap; // allocated number of elements
Ken Thompson66a603c2008-08-27 17:28:30 -0700122};
Ken Thompson751ce3a2008-07-11 19:16:39 -0700123struct Gobuf
124{
125 byte* SP;
126 byte* PC;
127};
Ken Thompson7b454bb2008-07-09 11:35:26 -0700128struct G
Ken Thompson45288542008-07-08 17:19:17 -0700129{
130 byte* stackguard; // must not move
131 byte* stackbase; // must not move
Ken Thompson1e1cc4e2009-01-27 12:03:53 -0800132 Defer* defer; // must not move
Ken Thompsone7d549f2008-07-16 13:50:23 -0700133 byte* stack0; // first stack segment
Ken Thompson751ce3a2008-07-11 19:16:39 -0700134 Gobuf sched;
Rob Pike3835e012008-07-28 11:29:41 -0700135 G* alllink; // on allg
Ken Thompsone963cba2008-07-25 15:55:12 -0700136 void* param; // passed parameter on wakeup
137 int16 status;
Ken Thompson751ce3a2008-07-11 19:16:39 -0700138 int32 goid;
Ken Thompsone963cba2008-07-25 15:55:12 -0700139 int32 selgen; // valid sudog pointer
Russ Cox96824002008-08-05 14:18:47 -0700140 G* schedlink;
Ken Thompson1e1cc4e2009-01-27 12:03:53 -0800141 bool readyonstop;
142 M* m; // for debuggers
Russ Coxd28acc42008-08-04 16:43:49 -0700143};
144struct Mem
145{
146 uint8* hunk;
147 uint32 nhunk;
148 uint64 nmmap;
149 uint64 nmal;
Ken Thompson45288542008-07-08 17:19:17 -0700150};
Ken Thompson45288542008-07-08 17:19:17 -0700151struct M
152{
Ken Thompson751ce3a2008-07-11 19:16:39 -0700153 G* g0; // g0 w interrupt stack - must not move
154 uint64 morearg; // arg to morestack - must not move
Ken Thompsone7d549f2008-07-16 13:50:23 -0700155 uint64 cret; // return value from C - must not move
Ken Thompson1e1cc4e2009-01-27 12:03:53 -0800156 uint64 procid; // for debuggers - must not move
157 G* gsignal; // signal-handling G - must not move
Ken Thompson751ce3a2008-07-11 19:16:39 -0700158 G* curg; // current running goroutine
Ken Thompsone7d549f2008-07-16 13:50:23 -0700159 G* lastg; // last running goroutine - to emulate fifo
Ken Thompson751ce3a2008-07-11 19:16:39 -0700160 Gobuf sched;
161 Gobuf morestack;
162 byte* moresp;
163 int32 siz1;
164 int32 siz2;
Russ Coxefc86a72008-11-25 16:48:10 -0800165 int32 id;
Russ Coxda0a7d72008-12-19 03:13:39 -0800166 int32 mallocing;
Russ Cox1ce17912009-01-26 17:37:05 -0800167 int32 locks;
Russ Cox96824002008-08-05 14:18:47 -0700168 Note havenextg;
169 G* nextg;
170 M* schedlink;
Russ Coxd28acc42008-08-04 16:43:49 -0700171 Mem mem;
Russ Cox376898c2008-09-09 11:50:14 -0700172 uint32 machport; // Return address for Mach IPC (OS X)
Russ Coxe29ce172008-12-18 15:42:28 -0800173 MCache *mcache;
Ken Thompson751ce3a2008-07-11 19:16:39 -0700174};
Ken Thompson52620032008-07-14 14:33:39 -0700175struct Stktop
Ken Thompson594175d2008-07-13 14:29:46 -0700176{
Ken Thompson751ce3a2008-07-11 19:16:39 -0700177 uint8* oldbase;
178 uint8* oldsp;
179 uint64 magic;
180 uint8* oldguard;
Ken Thompson45288542008-07-08 17:19:17 -0700181};
Ken Thompson594175d2008-07-13 14:29:46 -0700182struct Alg
Ken Thompson751ce3a2008-07-11 19:16:39 -0700183{
Ken Thompson594175d2008-07-13 14:29:46 -0700184 uint64 (*hash)(uint32, void*);
185 uint32 (*equal)(uint32, void*, void*);
186 void (*print)(uint32, void*);
187 void (*copy)(uint32, void*, void*);
Ken Thompson751ce3a2008-07-11 19:16:39 -0700188};
Ken Thompson594175d2008-07-13 14:29:46 -0700189struct SigTab
Ken Thompsonbbb20732008-06-05 19:38:39 -0700190{
Russ Coxdfa58932008-12-03 14:21:28 -0800191 int32 flags;
Ken Thompson594175d2008-07-13 14:29:46 -0700192 int8 *name;
Ken Thompsonbbb20732008-06-05 19:38:39 -0700193};
Russ Coxdfa58932008-12-03 14:21:28 -0800194enum
195{
196 SigCatch = 1<<0,
197 SigIgnore = 1<<1,
198 SigRestart = 1<<2,
199};
Ken Thompsonbbb20732008-06-05 19:38:39 -0700200
Russ Cox3aa063d2008-11-23 17:08:55 -0800201// (will be) shared with go; edit ../cmd/6g/sys.go too.
202// should move out of sys.go eventually.
203// also eventually, the loaded symbol table should
204// be closer to this form.
205struct Func
206{
207 string name;
Russ Coxa5433362008-11-25 09:23:36 -0800208 string type; // go type string
209 string src; // src file name
210 uint64 entry; // entry pc
211 int64 frame; // stack frame size
212 Array pcln; // pc/ln tab for this func
213 int64 pc0; // starting pc, ln for table
214 int32 ln0;
Russ Coxefc86a72008-11-25 16:48:10 -0800215 int32 args; // number of 32-bit in/out args
216 int32 locals; // number of 32-bit locals
Russ Cox3aa063d2008-11-23 17:08:55 -0800217};
218
Ken Thompsonbbb20732008-06-05 19:38:39 -0700219/*
220 * defined macros
221 * you need super-goru privilege
222 * to add this list.
223 */
224#define nelem(x) (sizeof(x)/sizeof((x)[0]))
225#define nil ((void*)0)
226
227/*
Russ Coxeee50ae2008-12-19 12:05:22 -0800228 * known to compiler
229 */
230enum
231{
Russ Coxa7f6d402009-01-26 09:56:42 -0800232 AMEM,
233 ANOEQ,
Russ Coxeee50ae2008-12-19 12:05:22 -0800234 ASTRING,
Russ Coxeee50ae2008-12-19 12:05:22 -0800235 AINTER,
Russ Cox9b6d3852009-01-26 12:36:21 -0800236 AFAKE,
Russ Coxa7f6d402009-01-26 09:56:42 -0800237 Amax
Russ Coxeee50ae2008-12-19 12:05:22 -0800238};
239
240/*
Ken Thompson47ab1c12009-01-27 13:23:28 -0800241 * deferred subroutine calls
Ken Thompson1e1cc4e2009-01-27 12:03:53 -0800242 */
243struct Defer
244{
245 int32 siz;
246 byte* sp;
247 byte* fn;
248 Defer* link;
249 byte args[8]; // padded to actual size
250};
251
252/*
Ken Thompson594175d2008-07-13 14:29:46 -0700253 * external data
254 */
Russ Coxa7f6d402009-01-26 09:56:42 -0800255extern Alg algarray[Amax];
Ken Thompson594175d2008-07-13 14:29:46 -0700256extern string emptystring;
Ken Thompson594175d2008-07-13 14:29:46 -0700257G* allg;
258int32 goidgen;
Russ Coxd28acc42008-08-04 16:43:49 -0700259extern int32 gomaxprocs;
Rob Pike6e8dbc22008-09-12 09:44:41 -0700260extern int32 panicking;
Ken Thompson79fbbe32008-11-05 21:50:28 -0800261extern int32 maxround;
Ken Thompson594175d2008-07-13 14:29:46 -0700262
263/*
Rob Pike8e82a672008-06-30 11:50:36 -0700264 * common functions and data
265 */
Ken Thompson751ce3a2008-07-11 19:16:39 -0700266int32 strcmp(byte*, byte*);
Russ Cox3aa063d2008-11-23 17:08:55 -0800267int32 findnull(byte*);
Rob Pike8e82a672008-06-30 11:50:36 -0700268void dump(byte*, int32);
Ken Thompson751ce3a2008-07-11 19:16:39 -0700269int32 runetochar(byte*, int32);
Rob Pike8e82a672008-06-30 11:50:36 -0700270
Rob Pike8e82a672008-06-30 11:50:36 -0700271/*
Ken Thompson4e8142c2008-06-16 22:34:50 -0700272 * very low level c-called
Ken Thompsonbbb20732008-06-05 19:38:39 -0700273 */
Ken Thompson751ce3a2008-07-11 19:16:39 -0700274int32 gogo(Gobuf*);
275int32 gosave(Gobuf*);
Rob Pike2da97832008-07-12 11:30:53 -0700276int32 gogoret(Gobuf*, uint64);
277void retfromnewstack(void);
Russ Cox36096242009-01-16 14:58:14 -0800278void goargs(void);
Ken Thompson751ce3a2008-07-11 19:16:39 -0700279void setspgoto(byte*, void(*)(void), void(*)(void));
Ken Thompsonbbb20732008-06-05 19:38:39 -0700280void FLUSH(void*);
Rob Piked3204ef2008-06-30 14:39:47 -0700281void* getu(void);
Ken Thompson4e8142c2008-06-16 22:34:50 -0700282void throw(int8*);
Ken Thompson594175d2008-07-13 14:29:46 -0700283uint32 rnd(uint32, uint32);
Ken Thompsonbbb20732008-06-05 19:38:39 -0700284void prints(int8*);
Russ Coxefc86a72008-11-25 16:48:10 -0800285void printf(int8*, ...);
Russ Cox3aa063d2008-11-23 17:08:55 -0800286byte* mchr(byte*, byte, byte*);
Ken Thompsone1a06cc2008-06-15 20:24:30 -0700287void mcpy(byte*, byte*, uint32);
Russ Cox9b6d3852009-01-26 12:36:21 -0800288int32 mcmp(byte*, byte*, uint32);
Ken Thompsonbc0b4f02008-11-13 10:35:44 -0800289void mmov(byte*, byte*, uint32);
Ken Thompsone1a06cc2008-06-15 20:24:30 -0700290void* mal(uint32);
Ken Thompson4e8142c2008-06-16 22:34:50 -0700291uint32 cmpstring(string, string);
Russ Cox3aa063d2008-11-23 17:08:55 -0800292string gostring(byte*);
Rob Pikeaeb43982008-06-21 15:36:23 -0700293void initsig(void);
Russ Coxfb40f882008-09-22 13:47:53 -0700294int32 gotraceback(void);
Ken Thompson751ce3a2008-07-11 19:16:39 -0700295void traceback(uint8 *pc, uint8 *sp, G* gp);
Rob Pike3835e012008-07-28 11:29:41 -0700296void tracebackothers(G*);
Rob Pikec870ac22008-07-14 20:54:55 -0700297int32 open(byte*, int32, ...);
Rob Pike3e4e83a2008-06-26 14:09:26 -0700298int32 read(int32, void*, int32);
Rob Pikec870ac22008-07-14 20:54:55 -0700299int32 write(int32, void*, int32);
Rob Pike3e4e83a2008-06-26 14:09:26 -0700300void close(int32);
301int32 fstat(int32, void*);
Russ Coxd28acc42008-08-04 16:43:49 -0700302bool cas(uint32*, uint32, uint32);
Ken Thompson1e1cc4e2009-01-27 12:03:53 -0800303void jmpdefer(byte*);
Russ Coxd28acc42008-08-04 16:43:49 -0700304void exit1(int32);
305void ready(G*);
306byte* getenv(int8*);
307int32 atoi(byte*);
Russ Cox96824002008-08-05 14:18:47 -0700308void newosproc(M *m, G *g, void *stk, void (*fn)(void));
Russ Coxa67258f2008-09-18 15:56:46 -0700309void sigaltstack(void*, void*);
310void signalstack(byte*, int32);
311G* malg(int32);
312void minit(void);
Russ Cox3aa063d2008-11-23 17:08:55 -0800313Func* findfunc(uint64);
Russ Coxa5433362008-11-25 09:23:36 -0800314int32 funcline(Func*, uint64);
Russ Cox79e1db22008-12-04 08:30:54 -0800315void* stackalloc(uint32);
316void stackfree(void*);
Russ Coxe29ce172008-12-18 15:42:28 -0800317MCache* allocmcache(void);
318void mallocinit(void);
Russ Coxa7f6d402009-01-26 09:56:42 -0800319bool ifaceeq(Iface, Iface);
320uint64 ifacehash(Iface);
321uint64 nohash(uint32, void*);
322uint32 noequal(uint32, void*, void*);
Russ Cox1ce17912009-01-26 17:37:05 -0800323void* malloc(uintptr size);
324void* mallocgc(uintptr size);
325void free(void *v);
Russ Coxd28acc42008-08-04 16:43:49 -0700326
Russ Cox5bb0c4f2008-12-15 10:50:33 -0800327#pragma varargck argpos printf 1
328
329#pragma varargck type "d" int32
330#pragma varargck type "d" uint32
331#pragma varargck type "D" int64
332#pragma varargck type "D" uint64
333#pragma varargck type "x" int32
334#pragma varargck type "x" uint32
335#pragma varargck type "X" int64
336#pragma varargck type "X" uint64
337#pragma varargck type "p" void*
338#pragma varargck type "p" uint64
339#pragma varargck type "s" int8*
340#pragma varargck type "s" uint8*
341#pragma varargck type "S" string
342
Russ Cox3f8aa662008-12-05 15:24:18 -0800343// TODO(rsc): Remove. These are only temporary,
344// for the mark and sweep collector.
345void stoptheworld(void);
346void starttheworld(void);
347
Russ Coxd28acc42008-08-04 16:43:49 -0700348/*
349 * mutual exclusion locks. in the uncontended case,
350 * as fast as spin locks (just a few user-level instructions),
351 * but on the contention path they sleep in the kernel.
Russ Cox96824002008-08-05 14:18:47 -0700352 * a zeroed Lock is unlocked (no need to initialize each lock).
Russ Coxd28acc42008-08-04 16:43:49 -0700353 */
354void lock(Lock*);
355void unlock(Lock*);
Russ Coxd28acc42008-08-04 16:43:49 -0700356
357/*
Russ Cox96824002008-08-05 14:18:47 -0700358 * sleep and wakeup on one-time events.
Russ Coxf7f63292008-08-05 14:21:42 -0700359 * before any calls to notesleep or notewakeup,
Russ Cox96824002008-08-05 14:18:47 -0700360 * must call noteclear to initialize the Note.
361 * then, any number of threads can call notesleep
362 * and exactly one thread can call notewakeup (once).
363 * once notewakeup has been called, all the notesleeps
364 * will return. future notesleeps will return immediately.
Russ Coxd28acc42008-08-04 16:43:49 -0700365 */
Russ Cox96824002008-08-05 14:18:47 -0700366void noteclear(Note*);
367void notesleep(Note*);
368void notewakeup(Note*);
Ken Thompson4e8142c2008-06-16 22:34:50 -0700369
370/*
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800371 * Redefine methods for the benefit of gcc, which does not support
372 * UTF-8 characters in identifiers.
373 */
374#ifndef __GNUC__
Russ Cox36096242009-01-16 14:58:14 -0800375#define sys_Exit sys·Exit
376#define sys_Gosched sys·Gosched
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800377#define sys_memclr sys·memclr
378#define sys_write sys·write
Russ Cox36096242009-01-16 14:58:14 -0800379#define sys_Breakpoint sys·Breakpoint
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800380#define sys_catstring sys·catstring
381#define sys_cmpstring sys·cmpstring
382#define sys_getcallerpc sys·getcallerpc
Russ Cox36096242009-01-16 14:58:14 -0800383#define sys_Goexit sys·Goexit
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800384#define sys_indexstring sys·indexstring
385#define sys_intstring sys·intstring
386#define sys_mal sys·mal
387#define sys_mmap sys·mmap
388#define sys_printarray sys·printarray
389#define sys_printbool sys·printbool
390#define sys_printfloat sys·printfloat
391#define sys_printhex sys·printhex
392#define sys_printint sys·printint
Russ Coxa7f6d402009-01-26 09:56:42 -0800393#define sys_printinter sys·printinter
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800394#define sys_printpc sys·printpc
395#define sys_printpointer sys·printpointer
396#define sys_printstring sys·printstring
397#define sys_printuint sys·printuint
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800398#define sys_setcallerpc sys·setcallerpc
399#define sys_slicestring sys·slicestring
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800400#endif
401
402/*
Russ Cox1f8a40d2009-01-22 16:23:44 -0800403 * low level go-called
Ken Thompson4e8142c2008-06-16 22:34:50 -0700404 */
Russ Cox36096242009-01-16 14:58:14 -0800405void sys_Goexit(void);
406void sys_Gosched(void);
407void sys_Exit(int32);
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800408void sys_write(int32, void*, int32);
Russ Cox36096242009-01-16 14:58:14 -0800409void sys_Breakpoint(void);
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800410uint8* sys_mmap(byte*, uint32, int32, int32, int32, uint32);
411void sys_memclr(byte*, uint32);
412void sys_setcallerpc(void*, void*);
413void* sys_getcallerpc(void*);
Ken Thompsonbbb20732008-06-05 19:38:39 -0700414
415/*
Ken Thompson4e8142c2008-06-16 22:34:50 -0700416 * runtime go-called
Ken Thompsonbbb20732008-06-05 19:38:39 -0700417 */
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800418void sys_printbool(bool);
419void sys_printfloat(float64);
420void sys_printint(int64);
Russ Coxa7f6d402009-01-26 09:56:42 -0800421void sys_printinter(Iface);
Ian Lance Taylor9b8da822009-01-13 09:55:24 -0800422void sys_printstring(string);
423void sys_printpc(void*);
424void sys_printpointer(void*);
425void sys_printuint(uint64);
426void sys_printhex(uint64);
427void sys_printarray(Array);
428void sys_catstring(string, string, string);
429void sys_cmpstring(string, string, int32);
430void sys_slicestring(string, int32, int32, string);
431void sys_indexstring(string, int32, byte);
432void sys_intstring(int64, string);
Rob Pike6db99de2008-07-08 10:36:43 -0700433
434/*
Russ Cox1f8a40d2009-01-22 16:23:44 -0800435 * wrapped for go users
Rob Pike6db99de2008-07-08 10:36:43 -0700436 */
Russ Cox1f8a40d2009-01-22 16:23:44 -0800437float64 Inf(int32 sign);
438float64 NaN(void);
439float32 float32frombits(uint32 i);
440uint32 float32tobits(float32 f);
441float64 float64frombits(uint64 i);
442uint64 float64tobits(float64 f);
443float64 frexp(float64 d, int32 *ep);
444bool isInf(float64 f, int32 sign);
445bool isNaN(float64 f);
446float64 ldexp(float64 d, int32 e);
447float64 modf(float64 d, float64 *ip);
448void semacquire(uint32*);
449void semrelease(uint32*);