runtime: Use some of 6g runtime.c for easier merging.
From-SVN: r181368
This commit is contained in:
parent
8c121ccb53
commit
5c262e9444
@ -435,7 +435,6 @@ runtime_files = \
|
||||
runtime/go-note.c \
|
||||
runtime/go-panic.c \
|
||||
runtime/go-print.c \
|
||||
runtime/go-rand.c \
|
||||
runtime/go-rec-big.c \
|
||||
runtime/go-rec-nb-big.c \
|
||||
runtime/go-rec-nb-small.c \
|
||||
@ -484,6 +483,7 @@ runtime_files = \
|
||||
runtime/mheap.c \
|
||||
runtime/msize.c \
|
||||
runtime/proc.c \
|
||||
runtime/runtime.c \
|
||||
runtime/thread.c \
|
||||
runtime/yield.c \
|
||||
$(rtems_task_variable_add_file) \
|
||||
|
@ -199,7 +199,7 @@ am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \
|
||||
runtime/go-map-range.c runtime/go-nanotime.c \
|
||||
runtime/go-new-channel.c runtime/go-new-map.c runtime/go-new.c \
|
||||
runtime/go-note.c runtime/go-panic.c runtime/go-print.c \
|
||||
runtime/go-rand.c runtime/go-rec-big.c runtime/go-rec-nb-big.c \
|
||||
runtime/go-rec-big.c runtime/go-rec-nb-big.c \
|
||||
runtime/go-rec-nb-small.c runtime/go-rec-small.c \
|
||||
runtime/go-recover.c runtime/go-reflect.c \
|
||||
runtime/go-reflect-call.c runtime/go-reflect-chan.c \
|
||||
@ -221,9 +221,10 @@ am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \
|
||||
runtime/cpuprof.c runtime/mcache.c runtime/mcentral.c \
|
||||
runtime/mem_posix_memalign.c runtime/mem.c runtime/mfinal.c \
|
||||
runtime/mfixalloc.c runtime/mgc0.c runtime/mheap.c \
|
||||
runtime/msize.c runtime/proc.c runtime/thread.c \
|
||||
runtime/yield.c runtime/rtems-task-variable-add.c chan.c \
|
||||
iface.c malloc.c map.c mprof.c reflect.c sigqueue.c string.c
|
||||
runtime/msize.c runtime/proc.c runtime/runtime.c \
|
||||
runtime/thread.c runtime/yield.c \
|
||||
runtime/rtems-task-variable-add.c chan.c iface.c malloc.c \
|
||||
map.c mprof.c reflect.c sigqueue.c string.c
|
||||
@HAVE_SYS_MMAN_H_FALSE@am__objects_1 = mem_posix_memalign.lo
|
||||
@HAVE_SYS_MMAN_H_TRUE@am__objects_1 = mem.lo
|
||||
@LIBGO_IS_RTEMS_TRUE@am__objects_2 = rtems-task-variable-add.lo
|
||||
@ -240,7 +241,7 @@ am__objects_3 = go-append.lo go-assert.lo go-assert-interface.lo \
|
||||
go-make-slice.lo go-map-delete.lo go-map-index.lo \
|
||||
go-map-len.lo go-map-range.lo go-nanotime.lo go-new-channel.lo \
|
||||
go-new-map.lo go-new.lo go-note.lo go-panic.lo go-print.lo \
|
||||
go-rand.lo go-rec-big.lo go-rec-nb-big.lo go-rec-nb-small.lo \
|
||||
go-rec-big.lo go-rec-nb-big.lo go-rec-nb-small.lo \
|
||||
go-rec-small.lo go-recover.lo go-reflect.lo go-reflect-call.lo \
|
||||
go-reflect-chan.lo go-reflect-map.lo go-rune.lo \
|
||||
go-runtime-error.lo go-sched.lo go-select.lo go-semacquire.lo \
|
||||
@ -253,9 +254,9 @@ am__objects_3 = go-append.lo go-assert.lo go-assert-interface.lo \
|
||||
go-unreflect.lo go-unsafe-new.lo go-unsafe-newarray.lo \
|
||||
go-unsafe-pointer.lo go-unwind.lo cpuprof.lo mcache.lo \
|
||||
mcentral.lo $(am__objects_1) mfinal.lo mfixalloc.lo mgc0.lo \
|
||||
mheap.lo msize.lo proc.lo thread.lo yield.lo $(am__objects_2) \
|
||||
chan.lo iface.lo malloc.lo map.lo mprof.lo reflect.lo \
|
||||
sigqueue.lo string.lo
|
||||
mheap.lo msize.lo proc.lo runtime.lo thread.lo yield.lo \
|
||||
$(am__objects_2) chan.lo iface.lo malloc.lo map.lo mprof.lo \
|
||||
reflect.lo sigqueue.lo string.lo
|
||||
am_libgo_la_OBJECTS = $(am__objects_3)
|
||||
libgo_la_OBJECTS = $(am_libgo_la_OBJECTS)
|
||||
libgo_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
@ -865,7 +866,6 @@ runtime_files = \
|
||||
runtime/go-note.c \
|
||||
runtime/go-panic.c \
|
||||
runtime/go-print.c \
|
||||
runtime/go-rand.c \
|
||||
runtime/go-rec-big.c \
|
||||
runtime/go-rec-nb-big.c \
|
||||
runtime/go-rec-nb-small.c \
|
||||
@ -914,6 +914,7 @@ runtime_files = \
|
||||
runtime/mheap.c \
|
||||
runtime/msize.c \
|
||||
runtime/proc.c \
|
||||
runtime/runtime.c \
|
||||
runtime/thread.c \
|
||||
runtime/yield.c \
|
||||
$(rtems_task_variable_add_file) \
|
||||
@ -2492,7 +2493,6 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-note.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-panic.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-print.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-rand.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-rec-big.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-rec-nb-big.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/go-rec-nb-small.Plo@am__quote@
|
||||
@ -2547,6 +2547,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reflect.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtems-task-variable-add.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/runtime.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigqueue.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread.Plo@am__quote@
|
||||
@ -2867,13 +2868,6 @@ go-print.lo: runtime/go-print.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o go-print.lo `test -f 'runtime/go-print.c' || echo '$(srcdir)/'`runtime/go-print.c
|
||||
|
||||
go-rand.lo: runtime/go-rand.c
|
||||
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT go-rand.lo -MD -MP -MF $(DEPDIR)/go-rand.Tpo -c -o go-rand.lo `test -f 'runtime/go-rand.c' || echo '$(srcdir)/'`runtime/go-rand.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/go-rand.Tpo $(DEPDIR)/go-rand.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/go-rand.c' object='go-rand.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o go-rand.lo `test -f 'runtime/go-rand.c' || echo '$(srcdir)/'`runtime/go-rand.c
|
||||
|
||||
go-rec-big.lo: runtime/go-rec-big.c
|
||||
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT go-rec-big.lo -MD -MP -MF $(DEPDIR)/go-rec-big.Tpo -c -o go-rec-big.lo `test -f 'runtime/go-rec-big.c' || echo '$(srcdir)/'`runtime/go-rec-big.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/go-rec-big.Tpo $(DEPDIR)/go-rec-big.Plo
|
||||
@ -3217,6 +3211,13 @@ proc.lo: runtime/proc.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o proc.lo `test -f 'runtime/proc.c' || echo '$(srcdir)/'`runtime/proc.c
|
||||
|
||||
runtime.lo: runtime/runtime.c
|
||||
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT runtime.lo -MD -MP -MF $(DEPDIR)/runtime.Tpo -c -o runtime.lo `test -f 'runtime/runtime.c' || echo '$(srcdir)/'`runtime/runtime.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/runtime.Tpo $(DEPDIR)/runtime.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/runtime.c' object='runtime.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o runtime.lo `test -f 'runtime/runtime.c' || echo '$(srcdir)/'`runtime/runtime.c
|
||||
|
||||
thread.lo: runtime/thread.c
|
||||
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT thread.lo -MD -MP -MF $(DEPDIR)/thread.Tpo -c -o thread.lo `test -f 'runtime/thread.c' || echo '$(srcdir)/'`runtime/thread.c
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/thread.Tpo $(DEPDIR)/thread.Plo
|
||||
|
@ -32,10 +32,6 @@
|
||||
|
||||
extern char **environ;
|
||||
|
||||
extern struct __go_open_array Args asm ("libgo_os.os.Args");
|
||||
|
||||
extern struct __go_open_array Envs asm ("libgo_os.os.Envs");
|
||||
|
||||
/* These functions are created for the main package. */
|
||||
extern void __go_init_main (void);
|
||||
extern void real_main (void) asm ("main.main");
|
||||
@ -45,38 +41,19 @@ extern void real_main (void) asm ("main.main");
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
struct __go_string *values;
|
||||
runtime_args (argc, (byte **) argv);
|
||||
|
||||
m = &runtime_m0;
|
||||
g = &runtime_g0;
|
||||
m->curg = g;
|
||||
g->m = m;
|
||||
runtime_initpanic ();
|
||||
runtime_mallocinit ();
|
||||
runtime_cpuprofinit ();
|
||||
__go_gc_goroutine_init (&argc);
|
||||
|
||||
Args.__count = argc;
|
||||
Args.__capacity = argc;
|
||||
values = __go_alloc (argc * sizeof (struct __go_string));
|
||||
for (i = 0; i < argc; ++i)
|
||||
{
|
||||
values[i].__data = (unsigned char *) argv[i];
|
||||
values[i].__length = __builtin_strlen (argv[i]);
|
||||
}
|
||||
Args.__values = values;
|
||||
|
||||
for (i = 0; environ[i] != NULL; ++i)
|
||||
;
|
||||
Envs.__count = i;
|
||||
Envs.__capacity = i;
|
||||
values = __go_alloc (i * sizeof (struct __go_string));
|
||||
for (i = 0; environ[i] != NULL; ++i)
|
||||
{
|
||||
values[i].__data = (unsigned char *) environ[i];
|
||||
values[i].__length = __builtin_strlen (environ[i]);
|
||||
}
|
||||
Envs.__values = values;
|
||||
runtime_goargs();
|
||||
runtime_goenvs();
|
||||
|
||||
__initsig ();
|
||||
|
||||
|
@ -98,10 +98,9 @@ __go_panic (struct __go_empty_interface arg)
|
||||
|
||||
/* The panic was not recovered. */
|
||||
|
||||
runtime_startpanic ();
|
||||
__printpanics (g->panic);
|
||||
|
||||
/* FIXME: We should dump a call stack here. */
|
||||
abort ();
|
||||
runtime_dopanic (0);
|
||||
}
|
||||
|
||||
/* This is used by the runtime library. */
|
||||
|
@ -1,18 +0,0 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include "runtime.h"
|
||||
|
||||
uint32
|
||||
runtime_fastrand1(void)
|
||||
{
|
||||
uint32 x;
|
||||
|
||||
x = m->fastrand;
|
||||
x += x;
|
||||
if(x & 0x80000000L)
|
||||
x ^= 0x88888eefUL;
|
||||
m->fastrand = x;
|
||||
return x;
|
||||
}
|
@ -834,7 +834,7 @@ runtime_gc(int32 force __attribute__ ((unused)))
|
||||
{
|
||||
int64 t0, t1, t2, t3;
|
||||
uint64 heap0, heap1, obj0, obj1;
|
||||
char *p;
|
||||
const byte *p;
|
||||
bool extra;
|
||||
|
||||
// The gc is turned off (via enablegc) until
|
||||
@ -852,7 +852,7 @@ runtime_gc(int32 force __attribute__ ((unused)))
|
||||
p = runtime_getenv("GOGC");
|
||||
if(p == nil || p[0] == '\0')
|
||||
gcpercent = 100;
|
||||
else if(runtime_strcmp(p, "off") == 0)
|
||||
else if(runtime_strcmp((const char*)p, "off") == 0)
|
||||
gcpercent = -1;
|
||||
else
|
||||
gcpercent = runtime_atoi(p);
|
||||
|
174
libgo/runtime/runtime.c
Normal file
174
libgo/runtime/runtime.c
Normal file
@ -0,0 +1,174 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "runtime.h"
|
||||
#include "array.h"
|
||||
#include "go-panic.h"
|
||||
#include "go-string.h"
|
||||
|
||||
uint32 runtime_panicking;
|
||||
|
||||
static Lock paniclk;
|
||||
|
||||
void
|
||||
runtime_initpanic(void)
|
||||
{
|
||||
runtime_initlock(&paniclk);
|
||||
}
|
||||
|
||||
void
|
||||
runtime_startpanic(void)
|
||||
{
|
||||
if(m->dying) {
|
||||
runtime_printf("panic during panic\n");
|
||||
runtime_exit(3);
|
||||
}
|
||||
m->dying = 1;
|
||||
runtime_xadd(&runtime_panicking, 1);
|
||||
runtime_lock(&paniclk);
|
||||
}
|
||||
|
||||
void
|
||||
runtime_dopanic(int32 unused __attribute__ ((unused)))
|
||||
{
|
||||
/*
|
||||
static bool didothers;
|
||||
|
||||
if(g->sig != 0)
|
||||
runtime_printf("[signal %x code=%p addr=%p pc=%p]\n",
|
||||
g->sig, g->sigcode0, g->sigcode1, g->sigpc);
|
||||
|
||||
if(runtime_gotraceback()){
|
||||
if(!didothers) {
|
||||
didothers = true;
|
||||
runtime_tracebackothers(g);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
runtime_unlock(&paniclk);
|
||||
if(runtime_xadd(&runtime_panicking, -1) != 0) {
|
||||
// Some other m is panicking too.
|
||||
// Let it print what it needs to print.
|
||||
// Wait forever without chewing up cpu.
|
||||
// It will exit when it's done.
|
||||
static Lock deadlock;
|
||||
runtime_initlock(&deadlock);
|
||||
runtime_lock(&deadlock);
|
||||
runtime_lock(&deadlock);
|
||||
}
|
||||
|
||||
runtime_exit(2);
|
||||
}
|
||||
|
||||
void
|
||||
runtime_throw(const char *s)
|
||||
{
|
||||
runtime_startpanic();
|
||||
runtime_printf("throw: %s\n", s);
|
||||
runtime_dopanic(0);
|
||||
*(int32*)0 = 0; // not reached
|
||||
runtime_exit(1); // even more not reached
|
||||
}
|
||||
|
||||
static int32 argc;
|
||||
static byte** argv;
|
||||
|
||||
extern Slice os_Args asm ("libgo_os.os.Args");
|
||||
extern Slice os_Envs asm ("libgo_os.os.Envs");
|
||||
|
||||
void
|
||||
runtime_args(int32 c, byte **v)
|
||||
{
|
||||
argc = c;
|
||||
argv = v;
|
||||
}
|
||||
|
||||
void
|
||||
runtime_goargs(void)
|
||||
{
|
||||
String *s;
|
||||
int32 i;
|
||||
|
||||
// for windows implementation see "os" package
|
||||
if(Windows)
|
||||
return;
|
||||
|
||||
s = runtime_malloc(argc*sizeof s[0]);
|
||||
for(i=0; i<argc; i++)
|
||||
s[i] = runtime_gostringnocopy((byte*)argv[i]);
|
||||
os_Args.__values = (void*)s;
|
||||
os_Args.__count = argc;
|
||||
os_Args.__capacity = argc;
|
||||
}
|
||||
|
||||
void
|
||||
runtime_goenvs(void)
|
||||
{
|
||||
String *s;
|
||||
int32 i, n;
|
||||
|
||||
for(n=0; argv[argc+1+n] != 0; n++)
|
||||
;
|
||||
|
||||
s = runtime_malloc(n*sizeof s[0]);
|
||||
for(i=0; i<n; i++)
|
||||
s[i] = runtime_gostringnocopy(argv[argc+1+i]);
|
||||
os_Envs.__values = (void*)s;
|
||||
os_Envs.__count = n;
|
||||
os_Envs.__capacity = n;
|
||||
}
|
||||
|
||||
const byte*
|
||||
runtime_getenv(const char *s)
|
||||
{
|
||||
int32 i, j, len;
|
||||
const byte *v, *bs;
|
||||
String* envv;
|
||||
int32 envc;
|
||||
|
||||
bs = (const byte*)s;
|
||||
len = runtime_findnull(bs);
|
||||
envv = (String*)os_Envs.__values;
|
||||
envc = os_Envs.__count;
|
||||
for(i=0; i<envc; i++){
|
||||
if(envv[i].__length <= len)
|
||||
continue;
|
||||
v = (const byte*)envv[i].__data;
|
||||
for(j=0; j<len; j++)
|
||||
if(bs[j] != v[j])
|
||||
goto nomatch;
|
||||
if(v[len] != '=')
|
||||
goto nomatch;
|
||||
return v+len+1;
|
||||
nomatch:;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
int32
|
||||
runtime_atoi(const byte *p)
|
||||
{
|
||||
int32 n;
|
||||
|
||||
n = 0;
|
||||
while('0' <= *p && *p <= '9')
|
||||
n = n*10 + *p++ - '0';
|
||||
return n;
|
||||
}
|
||||
|
||||
uint32
|
||||
runtime_fastrand1(void)
|
||||
{
|
||||
uint32 x;
|
||||
|
||||
x = m->fastrand;
|
||||
x += x;
|
||||
if(x & 0x80000000L)
|
||||
x ^= 0x88888eefUL;
|
||||
m->fastrand = x;
|
||||
return x;
|
||||
}
|
@ -22,12 +22,11 @@
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#include "array.h"
|
||||
#include "go-alloc.h"
|
||||
#include "go-panic.h"
|
||||
#include "go-string.h"
|
||||
|
||||
typedef struct __go_string String;
|
||||
|
||||
/* This file supports C files copied from the 6g runtime library.
|
||||
This is a version of the 6g runtime.h rewritten for gccgo's version
|
||||
of the code. */
|
||||
@ -56,6 +55,8 @@ typedef struct Lock Lock;
|
||||
|
||||
typedef struct __go_defer_stack Defer;
|
||||
typedef struct __go_panic_stack Panic;
|
||||
typedef struct __go_open_array Slice;
|
||||
typedef struct __go_string String;
|
||||
|
||||
/* We use mutexes for locks. 6g uses futexes directly, and perhaps
|
||||
someday we will do that too. */
|
||||
@ -136,6 +137,7 @@ struct M
|
||||
int32 gcing_for_prof;
|
||||
int32 holds_finlock;
|
||||
int32 gcing_for_finlock;
|
||||
int32 dying;
|
||||
int32 profilehz;
|
||||
uint32 fastrand;
|
||||
MCache *mcache;
|
||||
@ -152,14 +154,40 @@ struct M
|
||||
};
|
||||
|
||||
/* Macros. */
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
enum {
|
||||
Windows = 1
|
||||
};
|
||||
#else
|
||||
enum {
|
||||
Windows = 0
|
||||
};
|
||||
#endif
|
||||
|
||||
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
|
||||
#define nil ((void*)0)
|
||||
#define USED(v) ((void) v)
|
||||
|
||||
/* We map throw to assert. */
|
||||
#define runtime_throw(s) __go_assert(s == 0)
|
||||
/*
|
||||
* external data
|
||||
*/
|
||||
extern uint32 runtime_panicking;
|
||||
|
||||
/*
|
||||
* common functions and data
|
||||
*/
|
||||
int32 runtime_findnull(const byte*);
|
||||
|
||||
/*
|
||||
* very low level c-called
|
||||
*/
|
||||
void runtime_args(int32, byte**);
|
||||
void runtime_goargs(void);
|
||||
void runtime_goenvs(void);
|
||||
void runtime_throw(const char*);
|
||||
void* runtime_mal(uintptr);
|
||||
String runtime_gostringnocopy(byte*);
|
||||
void runtime_mallocinit(void);
|
||||
void runtime_initfintab(void);
|
||||
void siginit(void);
|
||||
@ -208,10 +236,9 @@ void runtime_notewakeup(Note*);
|
||||
#define runtime_free(p) __go_free(p)
|
||||
#define runtime_memclr(buf, size) __builtin_memset((buf), 0, (size))
|
||||
#define runtime_strcmp(s1, s2) __builtin_strcmp((s1), (s2))
|
||||
#define runtime_getenv(s) getenv(s)
|
||||
#define runtime_atoi(s) atoi(s)
|
||||
#define runtime_mcmp(a, b, s) __builtin_memcmp((a), (b), (s))
|
||||
#define runtime_memmove(a, b, s) __builtin_memmove((a), (b), (s))
|
||||
#define runtime_exit(s) _exit(s)
|
||||
MCache* runtime_allocmcache(void);
|
||||
void free(void *v);
|
||||
struct __go_func_type;
|
||||
@ -222,6 +249,11 @@ bool runtime_addfinalizer(void*, void(*fn)(void*), const struct __go_func_type *
|
||||
#define runtime_casp(pval, old, new) __sync_bool_compare_and_swap (pval, old, new)
|
||||
#define runtime_xadd(p, v) __sync_add_and_fetch (p, v)
|
||||
|
||||
void runtime_initpanic(void);
|
||||
void runtime_dopanic(int32) __attribute__ ((noreturn));
|
||||
void runtime_startpanic(void);
|
||||
const byte* runtime_getenv(const char*);
|
||||
int32 runtime_atoi(const byte*);
|
||||
void runtime_sigprof(uint8 *pc, uint8 *sp, uint8 *lr);
|
||||
void runtime_cpuprofinit(void);
|
||||
void runtime_resetcpuprofiler(int32);
|
||||
|
@ -6,6 +6,24 @@ package runtime
|
||||
#include "runtime.h"
|
||||
#define charntorune(pv, str, len) __go_get_rune(str, len, pv)
|
||||
|
||||
int32
|
||||
runtime_findnull(const byte *s)
|
||||
{
|
||||
if(s == nil)
|
||||
return 0;
|
||||
return __builtin_strlen((const char*) s);
|
||||
}
|
||||
|
||||
String
|
||||
runtime_gostringnocopy(byte *str)
|
||||
{
|
||||
String s;
|
||||
|
||||
s.__data = (const unsigned char *) str;
|
||||
s.__length = runtime_findnull(str);
|
||||
return s;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
Runeself = 0x80,
|
||||
|
Loading…
Reference in New Issue
Block a user