]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgo/runtime/runtime.h
1 /* runtime.h -- runtime support for Go.
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
10 #include "go-assert.h"
16 #include <semaphore.h>
18 #ifdef HAVE_SYS_MMAN_H
24 #include "go-string.h"
26 typedef struct __go_string String
;
28 /* This file supports C files copied from the 6g runtime library.
29 This is a version of the 6g runtime.h rewritten for gccgo's version
32 typedef signed int int8
__attribute__ ((mode (QI
)));
33 typedef unsigned int uint8
__attribute__ ((mode (QI
)));
34 typedef signed int int16
__attribute__ ((mode (HI
)));
35 typedef unsigned int uint16
__attribute__ ((mode (HI
)));
36 typedef signed int int32
__attribute__ ((mode (SI
)));
37 typedef unsigned int uint32
__attribute__ ((mode (SI
)));
38 typedef signed int int64
__attribute__ ((mode (DI
)));
39 typedef unsigned int uint64
__attribute__ ((mode (DI
)));
40 typedef float float32
__attribute__ ((mode (SF
)));
41 typedef double float64
__attribute__ ((mode (DF
)));
42 typedef unsigned int uintptr
__attribute__ ((mode (pointer
)));
49 typedef struct MCache MCache
;
50 typedef struct Lock Lock
;
52 /* We use mutexes for locks. 6g uses futexes directly, and perhaps
53 someday we will do that too. */
63 typedef struct Note Note
;
69 /* Per CPU declarations. */
102 /* For the list of all threads. */
103 struct __go_thread_id
*list_entry
;
105 /* For the garbage collector. */
108 void *gc_next_segment
;
111 struct __go_panic_defer_struct
*gc_panic_defer
;
115 #define nelem(x) (sizeof(x)/sizeof((x)[0]))
116 #define nil ((void*)0)
117 #define USED(v) ((void) v)
119 /* We map throw to assert. */
120 #define runtime_throw(s) __go_assert(s == 0)
122 void* runtime_mal(uintptr
);
123 void runtime_mallocinit(void);
124 void runtime_initfintab(void);
126 bool __go_sigsend(int32 sig
);
127 int64
runtime_nanotime(void);
129 void runtime_stoptheworld(void);
130 void runtime_starttheworld(void);
131 void __go_go(void (*pfn
)(void*), void*);
132 void __go_gc_goroutine_init(void*);
133 void __go_enable_gc(void);
134 int __go_run_goroutine_gc(int);
135 void __go_scanstacks(void (*scan
)(byte
*, int64
));
136 void __go_stealcache(void);
137 void __go_cachestats(void);
140 * mutual exclusion locks. in the uncontended case,
141 * as fast as spin locks (just a few user-level instructions),
142 * but on the contention path they sleep in the kernel.
144 void runtime_initlock(Lock
*);
145 void runtime_lock(Lock
*);
146 void runtime_unlock(Lock
*);
147 void runtime_destroylock(Lock
*);
149 void semacquire (uint32
*) asm ("libgo_runtime.runtime.Semacquire");
150 void semrelease (uint32
*) asm ("libgo_runtime.runtime.Semrelease");
153 * sleep and wakeup on one-time events.
154 * before any calls to notesleep or notewakeup,
155 * must call noteclear to initialize the Note.
156 * then, any number of threads can call notesleep
157 * and exactly one thread can call notewakeup (once).
158 * once notewakeup has been called, all the notesleeps
159 * will return. future notesleeps will return immediately.
161 void noteclear(Note
*);
162 void notesleep(Note
*);
163 void notewakeup(Note
*);
166 #define runtime_printf printf
167 #define runtime_malloc(s) __go_alloc(s)
168 #define runtime_free(p) __go_free(p)
169 #define runtime_memclr(buf, size) __builtin_memset((buf), 0, (size))
170 #define runtime_strcmp(s1, s2) __builtin_strcmp((s1), (s2))
171 #define runtime_getenv(s) getenv(s)
172 #define runtime_atoi(s) atoi(s)
173 #define runtime_mcmp(a, b, s) __builtin_memcmp((a), (b), (s))
174 #define runtime_memmove(a, b, s) __builtin_memmove((a), (b), (s))
175 MCache
* runtime_allocmcache(void);
177 struct __go_func_type
;
178 void runtime_addfinalizer(void*, void(*fn
)(void*), const struct __go_func_type
*);
179 void runtime_walkfintab(void (*fn
)(void*), void (*scan
)(byte
*, int64
));
180 #define runtime_mmap mmap
181 #define runtime_munmap(p, s) munmap((p), (s))
182 #define runtime_cas(pval, old, new) __sync_bool_compare_and_swap (pval, old, new)
184 struct __go_func_type
;
185 void reflect_call(const struct __go_func_type
*, const void *, _Bool
, void **,
187 asm ("libgo_reflect.reflect.call");
190 void __wrap_rtems_task_variable_add(void **);