libgo: Merge to master revision 19184.
[official-gcc.git] / libgo / runtime / runtime.h
blob9d5e42f50dc66626034f738724c7a12862d9ccf4
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.
5 #include "config.h"
7 #include "go-assert.h"
8 #include <complex.h>
9 #include <signal.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <sys/types.h>
14 #include <sys/stat.h>
15 #include <fcntl.h>
16 #include <unistd.h>
17 #include <pthread.h>
18 #include <semaphore.h>
19 #include <ucontext.h>
21 #ifdef HAVE_SYS_MMAN_H
22 #include <sys/mman.h>
23 #endif
25 #include "interface.h"
26 #include "go-alloc.h"
28 #define _STRINGIFY2_(x) #x
29 #define _STRINGIFY_(x) _STRINGIFY2_(x)
30 #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
32 /* This file supports C files copied from the 6g runtime library.
33 This is a version of the 6g runtime.h rewritten for gccgo's version
34 of the code. */
36 typedef signed int int8 __attribute__ ((mode (QI)));
37 typedef unsigned int uint8 __attribute__ ((mode (QI)));
38 typedef signed int int16 __attribute__ ((mode (HI)));
39 typedef unsigned int uint16 __attribute__ ((mode (HI)));
40 typedef signed int int32 __attribute__ ((mode (SI)));
41 typedef unsigned int uint32 __attribute__ ((mode (SI)));
42 typedef signed int int64 __attribute__ ((mode (DI)));
43 typedef unsigned int uint64 __attribute__ ((mode (DI)));
44 typedef float float32 __attribute__ ((mode (SF)));
45 typedef double float64 __attribute__ ((mode (DF)));
46 typedef signed int intptr __attribute__ ((mode (pointer)));
47 typedef unsigned int uintptr __attribute__ ((mode (pointer)));
49 typedef intptr intgo; // Go's int
50 typedef uintptr uintgo; // Go's uint
52 /* Defined types. */
54 typedef uint8 bool;
55 typedef uint8 byte;
56 typedef struct Func Func;
57 typedef struct G G;
58 typedef struct Lock Lock;
59 typedef struct M M;
60 typedef struct P P;
61 typedef struct Note Note;
62 typedef struct String String;
63 typedef struct FuncVal FuncVal;
64 typedef struct SigTab SigTab;
65 typedef struct MCache MCache;
66 typedef struct FixAlloc FixAlloc;
67 typedef struct Hchan Hchan;
68 typedef struct Timers Timers;
69 typedef struct Timer Timer;
70 typedef struct GCStats GCStats;
71 typedef struct LFNode LFNode;
72 typedef struct ParFor ParFor;
73 typedef struct ParForThread ParForThread;
74 typedef struct CgoMal CgoMal;
75 typedef struct PollDesc PollDesc;
76 typedef struct DebugVars DebugVars;
78 typedef struct __go_open_array Slice;
79 typedef struct __go_interface Iface;
80 typedef struct __go_empty_interface Eface;
81 typedef struct __go_type_descriptor Type;
82 typedef struct __go_defer_stack Defer;
83 typedef struct __go_panic_stack Panic;
85 typedef struct __go_ptr_type PtrType;
86 typedef struct __go_func_type FuncType;
87 typedef struct __go_interface_type InterfaceType;
88 typedef struct __go_map_type MapType;
89 typedef struct __go_channel_type ChanType;
91 typedef struct Traceback Traceback;
93 typedef struct Location Location;
96 * Per-CPU declaration.
98 extern M* runtime_m(void);
99 extern G* runtime_g(void);
101 extern M runtime_m0;
102 extern G runtime_g0;
105 * defined constants
107 enum
109 // G status
111 // If you add to this list, add to the list
112 // of "okay during garbage collection" status
113 // in mgc0.c too.
114 Gidle,
115 Grunnable,
116 Grunning,
117 Gsyscall,
118 Gwaiting,
119 Gmoribund_unused, // currently unused, but hardcoded in gdb scripts
120 Gdead,
122 enum
124 // P status
125 Pidle,
126 Prunning,
127 Psyscall,
128 Pgcstop,
129 Pdead,
131 enum
133 true = 1,
134 false = 0,
136 enum
138 PtrSize = sizeof(void*),
140 enum
142 // Per-M stack segment cache size.
143 StackCacheSize = 32,
144 // Global <-> per-M stack segment cache transfer batch size.
145 StackCacheBatch = 16,
148 * structures
150 struct Lock
152 // Futex-based impl treats it as uint32 key,
153 // while sema-based impl as M* waitm.
154 // Used to be a union, but unions break precise GC.
155 uintptr key;
157 struct Note
159 // Futex-based impl treats it as uint32 key,
160 // while sema-based impl as M* waitm.
161 // Used to be a union, but unions break precise GC.
162 uintptr key;
164 struct String
166 const byte* str;
167 intgo len;
169 struct FuncVal
171 void (*fn)(void);
172 // variable-size, fn-specific data here
174 struct GCStats
176 // the struct must consist of only uint64's,
177 // because it is casted to uint64[].
178 uint64 nhandoff;
179 uint64 nhandoffcnt;
180 uint64 nprocyield;
181 uint64 nosyield;
182 uint64 nsleep;
185 // A location in the program, used for backtraces.
186 struct Location
188 uintptr pc;
189 String filename;
190 String function;
191 intgo lineno;
194 struct G
196 void* closure; // Closure value.
197 Defer* defer;
198 Panic* panic;
199 void* exception; // current exception being thrown
200 bool is_foreign; // whether current exception from other language
201 void *gcstack; // if status==Gsyscall, gcstack = stackbase to use during gc
202 uintptr gcstack_size;
203 void* gcnext_segment;
204 void* gcnext_sp;
205 void* gcinitial_sp;
206 ucontext_t gcregs;
207 byte* entry; // initial function
208 void* param; // passed parameter on wakeup
209 bool fromgogo; // reached from gogo
210 int16 status;
211 uint32 selgen; // valid sudog pointer
212 int64 goid;
213 int64 waitsince; // approx time when the G become blocked
214 const char* waitreason; // if status==Gwaiting
215 G* schedlink;
216 bool ispanic;
217 bool issystem; // do not output in stack dump
218 bool isbackground; // ignore in deadlock detector
219 M* m; // for debuggers, but offset not hard-coded
220 M* lockedm;
221 int32 sig;
222 int32 writenbuf;
223 byte* writebuf;
224 uintptr sigcode0;
225 uintptr sigcode1;
226 // uintptr sigpc;
227 uintptr gopc; // pc of go statement that created this goroutine
229 int32 ncgo;
230 CgoMal* cgomal;
232 Traceback* traceback;
234 ucontext_t context;
235 void* stack_context[10];
238 struct M
240 G* g0; // goroutine with scheduling stack
241 G* gsignal; // signal-handling G
242 byte* gsignalstack;
243 size_t gsignalstacksize;
244 void (*mstartfn)(void);
245 G* curg; // current running goroutine
246 G* caughtsig; // goroutine running during fatal signal
247 P* p; // attached P for executing Go code (nil if not executing Go code)
248 P* nextp;
249 int32 id;
250 int32 mallocing;
251 int32 throwing;
252 int32 gcing;
253 int32 locks;
254 int32 dying;
255 int32 profilehz;
256 int32 helpgc;
257 bool spinning; // M is out of work and is actively looking for work
258 bool blocked; // M is blocked on a Note
259 uint32 fastrand;
260 uint64 ncgocall; // number of cgo calls in total
261 int32 ncgo; // number of cgo calls currently in progress
262 CgoMal* cgomal;
263 Note park;
264 M* alllink; // on allm
265 M* schedlink;
266 MCache *mcache;
267 G* lockedg;
268 Location createstack[32]; // Stack that created this thread.
269 uint32 locked; // tracking for LockOSThread
270 M* nextwaitm; // next M waiting for lock
271 uintptr waitsema; // semaphore for parking on locks
272 uint32 waitsemacount;
273 uint32 waitsemalock;
274 GCStats gcstats;
275 bool racecall;
276 bool needextram;
277 bool dropextram; // for gccgo: drop after call is done.
278 bool (*waitunlockf)(G*, void*);
279 void* waitlock;
281 uintptr settype_buf[1024];
282 uintptr settype_bufsize;
284 uintptr end[];
287 struct P
289 Lock;
291 int32 id;
292 uint32 status; // one of Pidle/Prunning/...
293 P* link;
294 uint32 schedtick; // incremented on every scheduler call
295 uint32 syscalltick; // incremented on every system call
296 M* m; // back-link to associated M (nil if idle)
297 MCache* mcache;
298 Defer* deferpool; // pool of available Defer structs (see panic.c)
300 // Cache of goroutine ids, amortizes accesses to runtime_sched.goidgen.
301 uint64 goidcache;
302 uint64 goidcacheend;
304 // Queue of runnable goroutines.
305 uint32 runqhead;
306 uint32 runqtail;
307 G* runq[256];
309 // Available G's (status == Gdead)
310 G* gfree;
311 int32 gfreecnt;
313 byte pad[64];
316 // The m->locked word holds two pieces of state counting active calls to LockOSThread/lockOSThread.
317 // The low bit (LockExternal) is a boolean reporting whether any LockOSThread call is active.
318 // External locks are not recursive; a second lock is silently ignored.
319 // The upper bits of m->lockedcount record the nesting depth of calls to lockOSThread
320 // (counting up by LockInternal), popped by unlockOSThread (counting down by LockInternal).
321 // Internal locks can be recursive. For instance, a lock for cgo can occur while the main
322 // goroutine is holding the lock during the initialization phase.
323 enum
325 LockExternal = 1,
326 LockInternal = 2,
329 struct SigTab
331 int32 sig;
332 int32 flags;
334 enum
336 SigNotify = 1<<0, // let signal.Notify have signal, even if from kernel
337 SigKill = 1<<1, // if signal.Notify doesn't take it, exit quietly
338 SigThrow = 1<<2, // if signal.Notify doesn't take it, exit loudly
339 SigPanic = 1<<3, // if the signal is from the kernel, panic
340 SigDefault = 1<<4, // if the signal isn't explicitly requested, don't monitor it
341 SigHandling = 1<<5, // our signal handler is registered
342 SigIgnored = 1<<6, // the signal was ignored before we registered for it
345 // Layout of in-memory per-function information prepared by linker
346 // See http://golang.org/s/go12symtab.
347 // Keep in sync with linker and with ../../libmach/sym.c
348 // and with package debug/gosym.
349 struct Func
351 String name;
352 uintptr entry; // entry pc
355 #ifdef GOOS_windows
356 enum {
357 Windows = 1
359 #else
360 enum {
361 Windows = 0
363 #endif
364 #ifdef GOOS_solaris
365 enum {
366 Solaris = 1
368 #else
369 enum {
370 Solaris = 0
372 #endif
374 struct Timers
376 Lock;
377 G *timerproc;
378 bool sleeping;
379 bool rescheduling;
380 Note waitnote;
381 Timer **t;
382 int32 len;
383 int32 cap;
386 // Package time knows the layout of this structure.
387 // If this struct changes, adjust ../time/sleep.go:/runtimeTimer.
388 struct Timer
390 int32 i; // heap index
392 // Timer wakes up at when, and then at when+period, ... (period > 0 only)
393 // each time calling f(now, arg) in the timer goroutine, so f must be
394 // a well-behaved function and not block.
395 int64 when;
396 int64 period;
397 FuncVal *fv;
398 Eface arg;
401 // Lock-free stack node.
402 struct LFNode
404 LFNode *next;
405 uintptr pushcnt;
408 // Parallel for descriptor.
409 struct ParFor
411 void (*body)(ParFor*, uint32); // executed for each element
412 uint32 done; // number of idle threads
413 uint32 nthr; // total number of threads
414 uint32 nthrmax; // maximum number of threads
415 uint32 thrseq; // thread id sequencer
416 uint32 cnt; // iteration space [0, cnt)
417 void *ctx; // arbitrary user context
418 bool wait; // if true, wait while all threads finish processing,
419 // otherwise parfor may return while other threads are still working
420 ParForThread *thr; // array of thread descriptors
421 uint32 pad; // to align ParForThread.pos for 64-bit atomic operations
422 // stats
423 uint64 nsteal;
424 uint64 nstealcnt;
425 uint64 nprocyield;
426 uint64 nosyield;
427 uint64 nsleep;
430 // Track memory allocated by code not written in Go during a cgo call,
431 // so that the garbage collector can see them.
432 struct CgoMal
434 CgoMal *next;
435 void *alloc;
438 // Holds variables parsed from GODEBUG env var.
439 struct DebugVars
441 int32 allocfreetrace;
442 int32 efence;
443 int32 gctrace;
444 int32 scheddetail;
445 int32 schedtrace;
448 extern bool runtime_precisestack;
451 * defined macros
452 * you need super-gopher-guru privilege
453 * to add this list.
455 #define nelem(x) (sizeof(x)/sizeof((x)[0]))
456 #define nil ((void*)0)
457 #define USED(v) ((void) v)
458 #define ROUND(x, n) (((x)+(n)-1)&~((n)-1)) /* all-caps to mark as macro: it evaluates n twice */
460 byte* runtime_startup_random_data;
461 uint32 runtime_startup_random_data_len;
462 void runtime_get_random_data(byte**, int32*);
464 enum {
465 // hashinit wants this many random bytes
466 HashRandomBytes = 32
468 void runtime_hashinit(void);
470 void runtime_traceback(void);
471 void runtime_tracebackothers(G*);
472 enum
474 // The maximum number of frames we print for a traceback
475 TracebackMaxFrames = 100,
479 * external data
481 extern uintptr runtime_zerobase;
482 extern G** runtime_allg;
483 extern uintptr runtime_allglen;
484 extern G* runtime_lastg;
485 extern M* runtime_allm;
486 extern P** runtime_allp;
487 extern int32 runtime_gomaxprocs;
488 extern uint32 runtime_needextram;
489 extern uint32 runtime_panicking;
490 extern int8* runtime_goos;
491 extern int32 runtime_ncpu;
492 extern void (*runtime_sysargs)(int32, uint8**);
493 extern DebugVars runtime_debug;
496 * common functions and data
498 #define runtime_strcmp(s1, s2) __builtin_strcmp((s1), (s2))
499 #define runtime_strstr(s1, s2) __builtin_strstr((s1), (s2))
500 intgo runtime_findnull(const byte*);
501 intgo runtime_findnullw(const uint16*);
502 void runtime_dump(byte*, int32);
505 * very low level c-called
507 void runtime_gogo(G*);
508 struct __go_func_type;
509 void runtime_args(int32, byte**);
510 void runtime_osinit();
511 void runtime_goargs(void);
512 void runtime_goenvs(void);
513 void runtime_goenvs_unix(void);
514 void runtime_throw(const char*) __attribute__ ((noreturn));
515 void runtime_panicstring(const char*) __attribute__ ((noreturn));
516 void runtime_prints(const char*);
517 void runtime_printf(const char*, ...);
518 #define runtime_mcmp(a, b, s) __builtin_memcmp((a), (b), (s))
519 #define runtime_memmove(a, b, s) __builtin_memmove((a), (b), (s))
520 void* runtime_mal(uintptr);
521 String runtime_gostring(const byte*);
522 String runtime_gostringnocopy(const byte*);
523 void runtime_schedinit(void);
524 void runtime_initsig(void);
525 void runtime_sigenable(uint32 sig);
526 void runtime_sigdisable(uint32 sig);
527 int32 runtime_gotraceback(bool *crash);
528 void runtime_goroutineheader(G*);
529 void runtime_printtrace(Location*, int32, bool);
530 #define runtime_open(p, f, m) open((p), (f), (m))
531 #define runtime_read(d, v, n) read((d), (v), (n))
532 #define runtime_write(d, v, n) write((d), (v), (n))
533 #define runtime_close(d) close(d)
534 void runtime_ready(G*);
535 const byte* runtime_getenv(const char*);
536 int32 runtime_atoi(const byte*);
537 void* runtime_mstart(void*);
538 G* runtime_malg(int32, byte**, size_t*);
539 void runtime_mpreinit(M*);
540 void runtime_minit(void);
541 void runtime_unminit(void);
542 void runtime_needm(void);
543 void runtime_dropm(void);
544 void runtime_signalstack(byte*, int32);
545 MCache* runtime_allocmcache(void);
546 void runtime_freemcache(MCache*);
547 void runtime_mallocinit(void);
548 void runtime_mprofinit(void);
549 #define runtime_malloc(s) __go_alloc(s)
550 #define runtime_free(p) __go_free(p)
551 #define runtime_getcallersp(p) __builtin_frame_address(1)
552 int32 runtime_mcount(void);
553 int32 runtime_gcount(void);
554 void runtime_mcall(void(*)(G*));
555 uint32 runtime_fastrand1(void);
556 int32 runtime_timediv(int64, int32, int32*);
558 // atomic operations
559 #define runtime_cas(pval, old, new) __sync_bool_compare_and_swap (pval, old, new)
560 #define runtime_cas64(pval, old, new) __sync_bool_compare_and_swap (pval, old, new)
561 #define runtime_casp(pval, old, new) __sync_bool_compare_and_swap (pval, old, new)
562 // Don't confuse with XADD x86 instruction,
563 // this one is actually 'addx', that is, add-and-fetch.
564 #define runtime_xadd(p, v) __sync_add_and_fetch (p, v)
565 #define runtime_xadd64(p, v) __sync_add_and_fetch (p, v)
566 #define runtime_xchg(p, v) __atomic_exchange_n (p, v, __ATOMIC_SEQ_CST)
567 #define runtime_xchg64(p, v) __atomic_exchange_n (p, v, __ATOMIC_SEQ_CST)
568 #define runtime_xchgp(p, v) __atomic_exchange_n (p, v, __ATOMIC_SEQ_CST)
569 #define runtime_atomicload(p) __atomic_load_n (p, __ATOMIC_SEQ_CST)
570 #define runtime_atomicstore(p, v) __atomic_store_n (p, v, __ATOMIC_SEQ_CST)
571 #define runtime_atomicstore64(p, v) __atomic_store_n (p, v, __ATOMIC_SEQ_CST)
572 #define runtime_atomicload64(p) __atomic_load_n (p, __ATOMIC_SEQ_CST)
573 #define runtime_atomicloadp(p) __atomic_load_n (p, __ATOMIC_SEQ_CST)
574 #define runtime_atomicstorep(p, v) __atomic_store_n (p, v, __ATOMIC_SEQ_CST)
576 void runtime_setmg(M*, G*);
577 void runtime_newextram(void);
578 #define runtime_exit(s) exit(s)
579 #define runtime_breakpoint() __builtin_trap()
580 void runtime_gosched(void);
581 void runtime_gosched0(G*);
582 void runtime_schedtrace(bool);
583 void runtime_park(bool(*)(G*, void*), void*, const char*);
584 void runtime_parkunlock(Lock*, const char*);
585 void runtime_tsleep(int64, const char*);
586 M* runtime_newm(void);
587 void runtime_goexit(void);
588 void runtime_entersyscall(void) __asm__ (GOSYM_PREFIX "syscall.Entersyscall");
589 void runtime_entersyscallblock(void);
590 void runtime_exitsyscall(void) __asm__ (GOSYM_PREFIX "syscall.Exitsyscall");
591 G* __go_go(void (*pfn)(void*), void*);
592 void siginit(void);
593 bool __go_sigsend(int32 sig);
594 int32 runtime_callers(int32, Location*, int32);
595 int64 runtime_nanotime(void);
596 void runtime_dopanic(int32) __attribute__ ((noreturn));
597 void runtime_startpanic(void);
598 void runtime_freezetheworld(void);
599 void runtime_unwindstack(G*, byte*);
600 void runtime_sigprof();
601 void runtime_resetcpuprofiler(int32);
602 void runtime_setcpuprofilerate(void(*)(uintptr*, int32), int32);
603 void runtime_usleep(uint32);
604 int64 runtime_cputicks(void);
605 int64 runtime_tickspersecond(void);
606 void runtime_blockevent(int64, int32);
607 extern int64 runtime_blockprofilerate;
608 void runtime_addtimer(Timer*);
609 bool runtime_deltimer(Timer*);
610 G* runtime_netpoll(bool);
611 void runtime_netpollinit(void);
612 int32 runtime_netpollopen(uintptr, PollDesc*);
613 int32 runtime_netpollclose(uintptr);
614 void runtime_netpollready(G**, PollDesc*, int32);
615 uintptr runtime_netpollfd(PollDesc*);
616 void runtime_netpollarm(uintptr, int32);
617 void runtime_crash(void);
618 void runtime_parsedebugvars(void);
619 void _rt0_go(void);
620 void* runtime_funcdata(Func*, int32);
622 void runtime_stoptheworld(void);
623 void runtime_starttheworld(void);
624 extern uint32 runtime_worldsema;
627 * mutual exclusion locks. in the uncontended case,
628 * as fast as spin locks (just a few user-level instructions),
629 * but on the contention path they sleep in the kernel.
630 * a zeroed Lock is unlocked (no need to initialize each lock).
632 void runtime_lock(Lock*);
633 void runtime_unlock(Lock*);
636 * sleep and wakeup on one-time events.
637 * before any calls to notesleep or notewakeup,
638 * must call noteclear to initialize the Note.
639 * then, exactly one thread can call notesleep
640 * and exactly one thread can call notewakeup (once).
641 * once notewakeup has been called, the notesleep
642 * will return. future notesleep will return immediately.
643 * subsequent noteclear must be called only after
644 * previous notesleep has returned, e.g. it's disallowed
645 * to call noteclear straight after notewakeup.
647 * notetsleep is like notesleep but wakes up after
648 * a given number of nanoseconds even if the event
649 * has not yet happened. if a goroutine uses notetsleep to
650 * wake up early, it must wait to call noteclear until it
651 * can be sure that no other goroutine is calling
652 * notewakeup.
654 * notesleep/notetsleep are generally called on g0,
655 * notetsleepg is similar to notetsleep but is called on user g.
657 void runtime_noteclear(Note*);
658 void runtime_notesleep(Note*);
659 void runtime_notewakeup(Note*);
660 bool runtime_notetsleep(Note*, int64); // false - timeout
661 bool runtime_notetsleepg(Note*, int64); // false - timeout
664 * low-level synchronization for implementing the above
666 uintptr runtime_semacreate(void);
667 int32 runtime_semasleep(int64);
668 void runtime_semawakeup(M*);
669 // or
670 void runtime_futexsleep(uint32*, uint32, int64);
671 void runtime_futexwakeup(uint32*, uint32);
674 * Lock-free stack.
675 * Initialize uint64 head to 0, compare with 0 to test for emptiness.
676 * The stack does not keep pointers to nodes,
677 * so they can be garbage collected if there are no other pointers to nodes.
679 void runtime_lfstackpush(uint64 *head, LFNode *node)
680 __asm__ (GOSYM_PREFIX "runtime.lfstackpush");
681 LFNode* runtime_lfstackpop(uint64 *head);
684 * Parallel for over [0, n).
685 * body() is executed for each iteration.
686 * nthr - total number of worker threads.
687 * ctx - arbitrary user context.
688 * if wait=true, threads return from parfor() when all work is done;
689 * otherwise, threads can return while other threads are still finishing processing.
691 ParFor* runtime_parforalloc(uint32 nthrmax);
692 void runtime_parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void (*body)(ParFor*, uint32));
693 void runtime_parfordo(ParFor *desc) __asm__ (GOSYM_PREFIX "runtime.parfordo");
696 * low level C-called
698 #define runtime_mmap mmap
699 #define runtime_munmap munmap
700 #define runtime_madvise madvise
701 #define runtime_memclr(buf, size) __builtin_memset((buf), 0, (size))
702 #define runtime_getcallerpc(p) __builtin_return_address(0)
704 #ifdef __rtems__
705 void __wrap_rtems_task_variable_add(void **);
706 #endif
709 * Names generated by gccgo.
711 #define runtime_printbool __go_print_bool
712 #define runtime_printfloat __go_print_double
713 #define runtime_printint __go_print_int64
714 #define runtime_printiface __go_print_interface
715 #define runtime_printeface __go_print_empty_interface
716 #define runtime_printstring __go_print_string
717 #define runtime_printpointer __go_print_pointer
718 #define runtime_printuint __go_print_uint64
719 #define runtime_printslice __go_print_slice
720 #define runtime_printcomplex __go_print_complex
723 * runtime go-called
725 void runtime_printbool(_Bool);
726 void runtime_printbyte(int8);
727 void runtime_printfloat(double);
728 void runtime_printint(int64);
729 void runtime_printiface(Iface);
730 void runtime_printeface(Eface);
731 void runtime_printstring(String);
732 void runtime_printpc(void*);
733 void runtime_printpointer(void*);
734 void runtime_printuint(uint64);
735 void runtime_printhex(uint64);
736 void runtime_printslice(Slice);
737 void runtime_printcomplex(complex double);
738 void reflect_call(const struct __go_func_type *, FuncVal *, _Bool, _Bool,
739 void **, void **)
740 __asm__ (GOSYM_PREFIX "reflect.call");
741 #define runtime_panic __go_panic
744 * runtime c-called (but written in Go)
746 void runtime_printany(Eface)
747 __asm__ (GOSYM_PREFIX "runtime.Printany");
748 void runtime_newTypeAssertionError(const String*, const String*, const String*, const String*, Eface*)
749 __asm__ (GOSYM_PREFIX "runtime.NewTypeAssertionError");
750 void runtime_newErrorString(String, Eface*)
751 __asm__ (GOSYM_PREFIX "runtime.NewErrorString");
752 void runtime_newErrorCString(const char*, Eface*)
753 __asm__ (GOSYM_PREFIX "runtime.NewErrorCString");
756 * wrapped for go users
758 void runtime_semacquire(uint32 volatile *, bool);
759 void runtime_semrelease(uint32 volatile *);
760 int32 runtime_gomaxprocsfunc(int32 n);
761 void runtime_procyield(uint32);
762 void runtime_osyield(void);
763 void runtime_lockOSThread(void);
764 void runtime_unlockOSThread(void);
766 bool runtime_showframe(String, bool);
767 void runtime_printcreatedby(G*);
769 uintptr runtime_memlimit(void);
771 #define ISNAN(f) __builtin_isnan(f)
773 enum
775 UseSpanType = 0,
778 #define runtime_setitimer setitimer
780 void runtime_check(void);
782 // A list of global variables that the garbage collector must scan.
783 struct root_list {
784 struct root_list *next;
785 struct root {
786 void *decl;
787 size_t size;
788 } roots[];
791 void __go_register_gc_roots(struct root_list*);
793 // Size of stack space allocated using Go's allocator.
794 // This will be 0 when using split stacks, as in that case
795 // the stacks are allocated by the splitstack library.
796 extern uintptr runtime_stacks_sys;
798 struct backtrace_state;
799 extern struct backtrace_state *__go_get_backtrace_state(void);
800 extern _Bool __go_file_line(uintptr, String*, String*, intgo *);
801 extern byte* runtime_progname();
802 extern void runtime_main(void*);
803 extern uint32 runtime_in_callers;
805 int32 getproccount(void);
807 #define PREFETCH(p) __builtin_prefetch(p)
809 void __go_set_closure(void*);
810 void* __go_get_closure(void);
812 bool runtime_gcwaiting(void);
813 void runtime_badsignal(int);
814 Defer* runtime_newdefer(void);
815 void runtime_freedefer(Defer*);