Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(54)

Delta Between Two Patch Sets: src/pkg/runtime/runtime.h

Issue 834045: code review 834045: Library support for cgo export. (Closed)
Left Patch Set: code review 834045: Library support for cgo export. Created 14 years, 11 months ago
Right Patch Set: code review 834045: Library support for cgo export. Created 14 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/proc.c ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 /* 5 /*
6 * basic types 6 * basic types
7 */ 7 */
8 typedef signed char int8; 8 typedef signed char int8;
9 typedef unsigned char uint8; 9 typedef unsigned char uint8;
10 typedef signed short int16; 10 typedef signed short int16;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 typedef struct Stktop Stktop; 55 typedef struct Stktop Stktop;
56 typedef struct String String; 56 typedef struct String String;
57 typedef struct Usema Usema; 57 typedef struct Usema Usema;
58 typedef struct SigTab SigTab; 58 typedef struct SigTab SigTab;
59 typedef struct MCache MCache; 59 typedef struct MCache MCache;
60 typedef struct Iface Iface; 60 typedef struct Iface Iface;
61 typedef struct Itab Itab; 61 typedef struct Itab Itab;
62 typedef struct Eface Eface; 62 typedef struct Eface Eface;
63 typedef struct Type Type; 63 typedef struct Type Type;
64 typedef struct Defer Defer; 64 typedef struct Defer Defer;
65 typedef struct Panic Panic;
65 typedef struct hash Hmap; 66 typedef struct hash Hmap;
66 typedef struct Hchan Hchan; 67 typedef struct Hchan Hchan;
67 typedef struct Complex64 Complex64; 68 typedef struct Complex64 Complex64;
68 typedef struct Complex128 Complex128; 69 typedef struct Complex128 Complex128;
69 70
70 /* 71 /*
71 * per-cpu declaration. 72 * per-cpu declaration.
72 * "extern register" is a special storage class implemented by 6c, 8c, etc. 73 * "extern register" is a special storage class implemented by 6c, 8c, etc.
73 * on machines with lots of registers, it allocates a register that will not be 74 * on machines with lots of registers, it allocates a register that will not be
74 * used in generated code. on the x86, it allocates a slot indexed by a 75 * used in generated code. on the x86, it allocates a slot indexed by a
75 * segment register. 76 * segment register.
76 * 77 *
77 * amd64: allocated downwards from R15 78 * amd64: allocated downwards from R15
78 * x86: allocated upwards from 0(FS) 79 * x86: allocated upwards from 0(FS)
79 * arm: allocated downwards from R10 80 * arm: allocated downwards from R10
80 * 81 *
81 * every C file linked into a Go program must include runtime.h 82 * every C file linked into a Go program must include runtime.h
82 * so that the C compiler knows to avoid other uses of these registers. 83 * so that the C compiler knows to avoid other uses of these registers.
83 * the Go compilers know to avoid them. 84 * the Go compilers know to avoid them.
84 */ 85 */
85 extern register G* g; 86 extern register G* g;
86 extern register M* m; 87 extern register M* m;
87 88
88 /* 89 /*
89 * defined constants 90 * defined constants
90 */ 91 */
91 enum 92 enum
92 { 93 {
93 // G status 94 // G status
95 //
96 // If you add to this list, add to the list
97 // of "okay during garbage collection" status
98 // in mgc0.c too.
94 Gidle, 99 Gidle,
95 Grunnable, 100 Grunnable,
96 Grunning, 101 Grunning,
97 Gsyscall, 102 Gsyscall,
98 Gwaiting, 103 Gwaiting,
99 Gmoribund, 104 Gmoribund,
100 Gdead, 105 Gdead,
106 Grecovery,
101 }; 107 };
102 enum 108 enum
103 { 109 {
104 true = 1, 110 true = 1,
105 false = 0, 111 false = 0,
106 }; 112 };
107 113
108 /* 114 /*
109 * structures 115 * structures
110 */ 116 */
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // The offsets of these fields are known to (hard-coded in) libmach. 175 // The offsets of these fields are known to (hard-coded in) libmach.
170 byte* sp; 176 byte* sp;
171 byte* pc; 177 byte* pc;
172 G* g; 178 G* g;
173 }; 179 };
174 struct G 180 struct G
175 { 181 {
176 byte* stackguard; // cannot move - also known to linker, libmach, libcgo 182 byte* stackguard; // cannot move - also known to linker, libmach, libcgo
177 byte* stackbase; // cannot move - also known to libmach, libcgo 183 byte* stackbase; // cannot move - also known to libmach, libcgo
178 Defer* defer; 184 Defer* defer;
179 » Gobuf» sched;» » // cannot move - also known to libmach 185 » Panic*» panic;
186 » Gobuf» sched;
180 byte* stack0; 187 byte* stack0;
181 byte* entry; // initial function 188 byte* entry; // initial function
182 G* alllink; // on allg 189 G* alllink; // on allg
183 void* param; // passed parameter on wakeup 190 void* param; // passed parameter on wakeup
184 int16 status; 191 int16 status;
185 int32 goid; 192 int32 goid;
186 uint32 selgen; // valid sudog pointer 193 uint32 selgen; // valid sudog pointer
187 G* schedlink; 194 G* schedlink;
188 bool readyonstop; 195 bool readyonstop;
196 bool ispanic;
189 M* m; // for debuggers, but offset not hard-coded 197 M* m; // for debuggers, but offset not hard-coded
190 M* lockedm; 198 M* lockedm;
199 int32 sig;
200 uintptr sigcode0;
201 uintptr sigcode1;
191 }; 202 };
192 struct M 203 struct M
193 { 204 {
194 // The offsets of these fields are known to (hard-coded in) libmach. 205 // The offsets of these fields are known to (hard-coded in) libmach.
195 G* g0; // goroutine with scheduling stack 206 G* g0; // goroutine with scheduling stack
196 void (*morepc)(void); 207 void (*morepc)(void);
197 void* morefp; // frame pointer for more stack 208 void* morefp; // frame pointer for more stack
198 Gobuf morebuf; // gobuf arg to morestack 209 Gobuf morebuf; // gobuf arg to morestack
199 210
200 // Fields not known to debuggers. 211 // Fields not known to debuggers.
(...skipping 29 matching lines...) Expand all
230 // The offsets of these fields are known to (hard-coded in) libmach. 241 // The offsets of these fields are known to (hard-coded in) libmach.
231 uint8* stackguard; 242 uint8* stackguard;
232 uint8* stackbase; 243 uint8* stackbase;
233 Gobuf gobuf; 244 Gobuf gobuf;
234 uint32 args; 245 uint32 args;
235 246
236 // Frame pointer: where args start in old frame. 247 // Frame pointer: where args start in old frame.
237 // fp == gobuf.sp except in the case of a reflected 248 // fp == gobuf.sp except in the case of a reflected
238 // function call, which uses an off-stack argument frame. 249 // function call, which uses an off-stack argument frame.
239 uint8* fp; 250 uint8* fp;
251 bool free; // call stackfree for this frame?
252 bool panic; // is this frame the top of a panic?
240 }; 253 };
241 struct Alg 254 struct Alg
242 { 255 {
243 uintptr (*hash)(uint32, void*); 256 uintptr (*hash)(uint32, void*);
244 uint32 (*equal)(uint32, void*, void*); 257 uint32 (*equal)(uint32, void*, void*);
245 void (*print)(uint32, void*); 258 void (*print)(uint32, void*);
246 void (*copy)(uint32, void*, void*); 259 void (*copy)(uint32, void*, void*);
247 }; 260 };
248 struct SigTab 261 struct SigTab
249 { 262 {
250 int32 flags; 263 int32 flags;
251 int8 *name; 264 int8 *name;
252 }; 265 };
253 enum 266 enum
254 { 267 {
255 SigCatch = 1<<0, 268 SigCatch = 1<<0,
256 SigIgnore = 1<<1, 269 SigIgnore = 1<<1,
257 SigRestart = 1<<2, 270 SigRestart = 1<<2,
258 SigQueue = 1<<3, 271 SigQueue = 1<<3,
272 SigPanic = 1<<4,
259 }; 273 };
260 274
261 // NOTE(rsc): keep in sync with extern.go:/type.Func. 275 // NOTE(rsc): keep in sync with extern.go:/type.Func.
262 // Eventually, the loaded symbol table should be closer to this form. 276 // Eventually, the loaded symbol table should be closer to this form.
263 struct Func 277 struct Func
264 { 278 {
265 String name; 279 String name;
266 String type; // go type string 280 String type; // go type string
267 String src; // src file name 281 String src; // src file name
268 Slice pcln; // pc/ln tab for this func 282 Slice pcln; // pc/ln tab for this func
(...skipping 16 matching lines...) Expand all
285 /* 299 /*
286 * known to compiler 300 * known to compiler
287 */ 301 */
288 enum 302 enum
289 { 303 {
290 AMEM, 304 AMEM,
291 ANOEQ, 305 ANOEQ,
292 ASTRING, 306 ASTRING,
293 AINTER, 307 AINTER,
294 ANILINTER, 308 ANILINTER,
295 AFAKE,
296 Amax 309 Amax
297 }; 310 };
298 311
299 312
300 enum { 313 enum {
301 Structrnd = sizeof(uintptr) 314 Structrnd = sizeof(uintptr)
302 }; 315 };
303 316
304 /* 317 /*
305 * deferred subroutine calls 318 * deferred subroutine calls
306 */ 319 */
307 struct Defer 320 struct Defer
308 { 321 {
309 int32 siz; 322 int32 siz;
310 byte* sp; 323 byte* sp;
324 byte* pc;
311 byte* fn; 325 byte* fn;
312 Defer* link; 326 Defer* link;
313 byte args[8]; // padded to actual size 327 byte args[8]; // padded to actual size
328 };
329
330 /*
331 * panics
332 */
333 struct Panic
334 {
335 Eface arg; // argument to panic
336 byte* stackbase; // g->stackbase in panic
337 Panic* link; // link to earlier panic
338 bool recovered; // whether this panic is over
314 }; 339 };
315 340
316 /* 341 /*
317 * external data 342 * external data
318 */ 343 */
319 extern Alg algarray[Amax]; 344 extern Alg algarray[Amax];
320 extern String emptystring; 345 extern String emptystring;
321 G* allg; 346 G* allg;
322 M* allm; 347 M* allm;
323 int32 goidgen; 348 int32 goidgen;
(...skipping 18 matching lines...) Expand all
342 * very low level c-called 367 * very low level c-called
343 */ 368 */
344 void gogo(Gobuf*, uintptr); 369 void gogo(Gobuf*, uintptr);
345 void gogocall(Gobuf*, void(*)(void)); 370 void gogocall(Gobuf*, void(*)(void));
346 uintptr gosave(Gobuf*); 371 uintptr gosave(Gobuf*);
347 void ·lessstack(void); 372 void ·lessstack(void);
348 void goargs(void); 373 void goargs(void);
349 void FLUSH(void*); 374 void FLUSH(void*);
350 void* getu(void); 375 void* getu(void);
351 void throw(int8*); 376 void throw(int8*);
377 void panicstring(int8*);
352 uint32 rnd(uint32, uint32); 378 uint32 rnd(uint32, uint32);
353 void prints(int8*); 379 void prints(int8*);
354 void printf(int8*, ...); 380 void printf(int8*, ...);
355 byte* mchr(byte*, byte, byte*); 381 byte* mchr(byte*, byte, byte*);
356 void mcpy(byte*, byte*, uint32); 382 void mcpy(byte*, byte*, uint32);
357 int32 mcmp(byte*, byte*, uint32); 383 int32 mcmp(byte*, byte*, uint32);
358 void memmove(void*, void*, uint32); 384 void memmove(void*, void*, uint32);
359 void* mal(uintptr); 385 void* mal(uintptr);
360 void* malx(uintptr size, int32 skip_delta); 386 void* malx(uintptr size, int32 skip_delta);
361 uint32 cmpstring(String, String); 387 uint32 cmpstring(String, String);
388 String catstring(String, String);
362 String gostring(byte*); 389 String gostring(byte*);
363 String gostringw(uint16*); 390 String gostringw(uint16*);
364 void initsig(void); 391 void initsig(void);
365 int32 gotraceback(void); 392 int32 gotraceback(void);
366 void» traceback(uint8 *pc, uint8 *sp, G* gp); 393 void» traceback(uint8 *pc, uint8 *sp, uint8 *lr, G* gp);
367 void tracebackothers(G*); 394 void tracebackothers(G*);
368 int32 open(byte*, int32, ...); 395 int32 open(byte*, int32, ...);
369 int32 write(int32, void*, int32); 396 int32 write(int32, void*, int32);
370 bool cas(uint32*, uint32, uint32); 397 bool cas(uint32*, uint32, uint32);
371 bool casp(void**, void*, void*); 398 bool casp(void**, void*, void*);
372 uint32 xadd(uint32 volatile*, int32); 399 uint32 xadd(uint32 volatile*, int32);
373 void jmpdefer(byte*, void*); 400 void jmpdefer(byte*, void*);
374 void exit1(int32); 401 void exit1(int32);
375 void ready(G*); 402 void ready(G*);
376 byte* getenv(int8*); 403 byte* getenv(int8*);
(...skipping 11 matching lines...) Expand all
388 bool ifaceeq(Iface, Iface); 415 bool ifaceeq(Iface, Iface);
389 bool efaceeq(Eface, Eface); 416 bool efaceeq(Eface, Eface);
390 uintptr ifacehash(Iface); 417 uintptr ifacehash(Iface);
391 uintptr efacehash(Eface); 418 uintptr efacehash(Eface);
392 uintptr nohash(uint32, void*); 419 uintptr nohash(uint32, void*);
393 uint32 noequal(uint32, void*, void*); 420 uint32 noequal(uint32, void*, void*);
394 void* malloc(uintptr size); 421 void* malloc(uintptr size);
395 void free(void *v); 422 void free(void *v);
396 void addfinalizer(void*, void(*fn)(void*), int32); 423 void addfinalizer(void*, void(*fn)(void*), int32);
397 void walkfintab(void (*fn)(void*)); 424 void walkfintab(void (*fn)(void*));
425 void runpanic(Panic*);
426 void* getcallersp(void*);
398 427
399 void exit(int32); 428 void exit(int32);
400 void breakpoint(void); 429 void breakpoint(void);
401 void gosched(void); 430 void gosched(void);
402 void goexit(void); 431 void goexit(void);
403 void runcgo(void (*fn)(void*), void*); 432 void runcgo(void (*fn)(void*), void*);
404 void» runcgocallback(void*, void (*fn)()); 433 void» runcgocallback(G*, void*, void (*fn)());
405 void ·entersyscall(void); 434 void ·entersyscall(void);
406 void ·exitsyscall(void); 435 void ·exitsyscall(void);
407 void» startcgocallback(void); 436 void» startcgocallback(G*);
408 void» endcgocallback(void); 437 void» endcgocallback(G*);
409 G* newproc1(byte*, byte*, int32, int32); 438 G* newproc1(byte*, byte*, int32, int32);
410 void siginit(void); 439 void siginit(void);
411 bool sigsend(int32 sig); 440 bool sigsend(int32 sig);
412 void gettime(int64*, int32*); 441 void gettime(int64*, int32*);
413 int32 callers(int32, uintptr*, int32); 442 int32 callers(int32, uintptr*, int32);
414 int64 nanotime(void); 443 int64 nanotime(void);
444 void panic(int32);
415 445
416 #pragma varargck argpos printf 1 446 #pragma varargck argpos printf 1
417 447
418 #pragma varargck type "d" int32 448 #pragma varargck type "d" int32
419 #pragma varargck type "d" uint32 449 #pragma varargck type "d" uint32
420 #pragma varargck type "D" int64 450 #pragma varargck type "D" int64
421 #pragma varargck type "D" uint64 451 #pragma varargck type "D" uint64
422 #pragma varargck type "x" int32 452 #pragma varargck type "x" int32
423 #pragma varargck type "x" uint32 453 #pragma varargck type "x" uint32
424 #pragma varargck type "X" int64 454 #pragma varargck type "X" int64
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 /* 513 /*
484 * This is consistent across Linux and BSD. 514 * This is consistent across Linux and BSD.
485 * If a new OS is added that is different, move this to 515 * If a new OS is added that is different, move this to
486 * $GOOS/$GOARCH/defs.h. 516 * $GOOS/$GOARCH/defs.h.
487 */ 517 */
488 #define EACCES 13 518 #define EACCES 13
489 519
490 /* 520 /*
491 * low level go-called 521 * low level go-called
492 */ 522 */
493 uint8*» runtime_mmap(byte*, uint32, int32, int32, int32, uint32); 523 uint8*» runtime_mmap(byte*, uintptr, int32, int32, int32, uint32);
494 void runtime_memclr(byte*, uint32); 524 void runtime_memclr(byte*, uint32);
495 void runtime_setcallerpc(void*, void*); 525 void runtime_setcallerpc(void*, void*);
496 void* runtime_getcallerpc(void*); 526 void* runtime_getcallerpc(void*);
497 527
498 /* 528 /*
499 * runtime go-called 529 * runtime go-called
500 */ 530 */
501 void runtime_printbool(bool); 531 void runtime_printbool(bool);
502 void runtime_printfloat(float64); 532 void runtime_printfloat(float64);
503 void runtime_printint(int64); 533 void runtime_printint(int64);
504 void runtime_printiface(Iface); 534 void runtime_printiface(Iface);
505 void runtime_printeface(Eface); 535 void runtime_printeface(Eface);
506 void runtime_printstring(String); 536 void runtime_printstring(String);
507 void runtime_printpc(void*); 537 void runtime_printpc(void*);
508 void runtime_printpointer(void*); 538 void runtime_printpointer(void*);
509 void runtime_printuint(uint64); 539 void runtime_printuint(uint64);
510 void runtime_printhex(uint64); 540 void runtime_printhex(uint64);
511 void runtime_printslice(Slice); 541 void runtime_printslice(Slice);
512 void runtime_printcomplex(Complex128); 542 void runtime_printcomplex(Complex128);
513 void ·panicl(int32);
514 void reflect·call(byte*, byte*, uint32); 543 void reflect·call(byte*, byte*, uint32);
544 void ·panic(Eface);
545 void ·panicindex(void);
546 void ·panicslice(void);
547 /*
548 * runtime c-called (but written in Go)
549 */
550 void ·newError(String, Eface*);
551 void ·printany(Eface);
552 void ·newTypeAssertionError(Type*, Type*, Type*, String*, String*, String*, S tring*, Eface*);
553 void ·newErrorString(String, Eface*);
515 554
516 /* 555 /*
517 * wrapped for go users 556 * wrapped for go users
518 */ 557 */
519 float64 Inf(int32 sign); 558 float64 Inf(int32 sign);
520 float64 NaN(void); 559 float64 NaN(void);
521 float32 float32frombits(uint32 i); 560 float32 float32frombits(uint32 i);
522 uint32 float32tobits(float32 f); 561 uint32 float32tobits(float32 f);
523 float64 float64frombits(uint64 i); 562 float64 float64frombits(uint64 i);
524 uint64 float64tobits(float64 f); 563 uint64 float64tobits(float64 f);
(...skipping 17 matching lines...) Expand all
542 581
543 Hchan* makechan(Type*, uint32); 582 Hchan* makechan(Type*, uint32);
544 void chansend(Hchan*, void*, bool*); 583 void chansend(Hchan*, void*, bool*);
545 void chanrecv(Hchan*, void*, bool*); 584 void chanrecv(Hchan*, void*, bool*);
546 void chanclose(Hchan*); 585 void chanclose(Hchan*);
547 bool chanclosed(Hchan*); 586 bool chanclosed(Hchan*);
548 int32 chanlen(Hchan*); 587 int32 chanlen(Hchan*);
549 int32 chancap(Hchan*); 588 int32 chancap(Hchan*);
550 589
551 void ifaceE2I(struct InterfaceType*, Eface, Iface*); 590 void ifaceE2I(struct InterfaceType*, Eface, Iface*);
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b