summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libgo/Makefile.am1
-rw-r--r--libgo/Makefile.in17
-rwxr-xr-xlibgo/merge.sh2
-rw-r--r--libgo/runtime/chan.c4
-rw-r--r--libgo/runtime/go-assert.c3
-rw-r--r--libgo/runtime/go-panic.c8
-rw-r--r--libgo/runtime/go-print.c143
-rw-r--r--libgo/runtime/malloc.goc12
-rw-r--r--libgo/runtime/mgc0.c27
-rw-r--r--libgo/runtime/mheap.c14
-rw-r--r--libgo/runtime/msize.c10
-rw-r--r--libgo/runtime/runtime.c12
-rw-r--r--libgo/runtime/runtime.h36
-rw-r--r--libgo/runtime/thread-linux.c2
14 files changed, 106 insertions, 185 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index a27216a9626..1d761bca381 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -465,6 +465,7 @@ runtime_files = \
runtime/mgc0.c \
runtime/mheap.c \
runtime/msize.c \
+ runtime/print.c \
runtime/proc.c \
runtime/runtime.c \
runtime/signal_unix.c \
diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index 018ac859fcb..af18b702531 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -209,7 +209,7 @@ am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \
runtime/lock_futex.c runtime/thread-linux.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/mheap.c runtime/msize.c runtime/print.c runtime/proc.c \
runtime/runtime.c runtime/signal_unix.c runtime/thread.c \
runtime/yield.c runtime/rtems-task-variable-add.c iface.c \
malloc.c map.c mprof.c reflect.c runtime1.c sema.c sigqueue.c \
@@ -242,9 +242,9 @@ am__objects_4 = go-append.lo go-assert.lo go-assert-interface.lo \
go-unsafe-newarray.lo go-unsafe-pointer.lo go-unwind.lo \
chan.lo cpuprof.lo $(am__objects_1) mcache.lo mcentral.lo \
$(am__objects_2) mfinal.lo mfixalloc.lo mgc0.lo mheap.lo \
- msize.lo proc.lo runtime.lo signal_unix.lo thread.lo yield.lo \
- $(am__objects_3) iface.lo malloc.lo map.lo mprof.lo reflect.lo \
- runtime1.lo sema.lo sigqueue.lo string.lo time.lo
+ msize.lo print.lo proc.lo runtime.lo signal_unix.lo thread.lo \
+ yield.lo $(am__objects_3) iface.lo malloc.lo map.lo mprof.lo \
+ reflect.lo runtime1.lo sema.lo sigqueue.lo string.lo time.lo
am_libgo_la_OBJECTS = $(am__objects_4)
libgo_la_OBJECTS = $(am_libgo_la_OBJECTS)
libgo_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -882,6 +882,7 @@ runtime_files = \
runtime/mgc0.c \
runtime/mheap.c \
runtime/msize.c \
+ runtime/print.c \
runtime/proc.c \
runtime/runtime.c \
runtime/signal_unix.c \
@@ -2440,6 +2441,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mheap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mprof.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msize.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Plo@am__quote@
@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@
@@ -3036,6 +3038,13 @@ msize.lo: runtime/msize.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 msize.lo `test -f 'runtime/msize.c' || echo '$(srcdir)/'`runtime/msize.c
+print.lo: runtime/print.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT print.lo -MD -MP -MF $(DEPDIR)/print.Tpo -c -o print.lo `test -f 'runtime/print.c' || echo '$(srcdir)/'`runtime/print.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/print.Tpo $(DEPDIR)/print.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/print.c' object='print.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 print.lo `test -f 'runtime/print.c' || echo '$(srcdir)/'`runtime/print.c
+
proc.lo: runtime/proc.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT proc.lo -MD -MP -MF $(DEPDIR)/proc.Tpo -c -o proc.lo `test -f 'runtime/proc.c' || echo '$(srcdir)/'`runtime/proc.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proc.Tpo $(DEPDIR)/proc.Plo
diff --git a/libgo/merge.sh b/libgo/merge.sh
index 9e2ca01cc96..fbc71188032 100755
--- a/libgo/merge.sh
+++ b/libgo/merge.sh
@@ -163,7 +163,7 @@ done
done
done
-runtime="chan.c cpuprof.c lock_futex.c lock_sema.c mcache.c mcentral.c mfinal.c mfixalloc.c mgc0.c mheap.c msize.c proc.c runtime.c runtime.h signal_unix.c malloc.h malloc.goc mprof.goc runtime1.goc sema.goc sigqueue.goc string.goc time.goc"
+runtime="chan.c cpuprof.c lock_futex.c lock_sema.c mcache.c mcentral.c mfinal.c mfixalloc.c mgc0.c mheap.c msize.c print.c proc.c runtime.c runtime.h signal_unix.c malloc.h malloc.goc mprof.goc runtime1.goc sema.goc sigqueue.goc string.goc time.goc"
for f in $runtime; do
merge_c $f $f
done
diff --git a/libgo/runtime/chan.c b/libgo/runtime/chan.c
index 7cf307f0378..c8ee10e8c88 100644
--- a/libgo/runtime/chan.c
+++ b/libgo/runtime/chan.c
@@ -100,8 +100,8 @@ runtime_makechan_c(ChanType *t, int64 hint)
c->dataqsiz = hint;
if(debug)
- runtime_printf("makechan: chan=%p; elemsize=%lld; elemalign=%d; dataqsiz=%d\n",
- c, (long long)elem->__size, elem->__align, c->dataqsiz);
+ runtime_printf("makechan: chan=%p; elemsize=%D; elemalign=%d; dataqsiz=%d\n",
+ c, (int64)elem->__size, elem->__align, c->dataqsiz);
return c;
}
diff --git a/libgo/runtime/go-assert.c b/libgo/runtime/go-assert.c
index 48aa0725cec..a36f43a75e4 100644
--- a/libgo/runtime/go-assert.c
+++ b/libgo/runtime/go-assert.c
@@ -7,12 +7,13 @@
#include <stdio.h>
#include <stdlib.h>
+#include "runtime.h"
#include "go-assert.h"
void
__go_assert_fail (const char *file, unsigned int lineno)
{
/* FIXME: Eventually we should dump a stack trace here. */
- fprintf (stderr, "%s:%u: libgo assertion failure\n", file, lineno);
+ runtime_printf ("%s:%U: libgo assertion failure\n", file, (uint64) lineno);
abort ();
}
diff --git a/libgo/runtime/go-panic.c b/libgo/runtime/go-panic.c
index 7ba426f5148..05325b1194f 100644
--- a/libgo/runtime/go-panic.c
+++ b/libgo/runtime/go-panic.c
@@ -24,13 +24,13 @@ __printpanics (struct __go_panic_stack *p)
if (p->__next != NULL)
{
__printpanics (p->__next);
- fprintf (stderr, "\t");
+ runtime_printf ("\t");
}
- fprintf (stderr, "panic: ");
+ runtime_printf ("panic: ");
runtime_printany (p->__arg);
if (p->__was_recovered)
- fprintf (stderr, " [recovered]");
- fputc ('\n', stderr);
+ runtime_printf (" [recovered]");
+ runtime_printf ("\n");
}
/* This implements __go_panic which is used for the panic
diff --git a/libgo/runtime/go-print.c b/libgo/runtime/go-print.c
index 03cfd01869c..3fe879a48af 100644
--- a/libgo/runtime/go-print.c
+++ b/libgo/runtime/go-print.c
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <stdio.h>
+#include "runtime.h"
#include "array.h"
#include "go-panic.h"
#include "go-string.h"
@@ -17,154 +18,20 @@
the predeclared functions print/println/panic/panicln. */
void
-__go_print_space ()
-{
- putc (' ', stderr);
-}
-
-void
-__go_print_nl ()
-{
- putc ('\n', stderr);
-}
-
-void
-__go_print_string (struct __go_string val)
-{
- fprintf (stderr, "%.*s", (int) val.__length, (const char *) val.__data);
-}
-
-void
-__go_print_uint64 (uint64_t val)
-{
- fprintf (stderr, "%llu", (unsigned long long) val);
-}
-
-void
-__go_print_int64 (int64_t val)
-{
- fprintf (stderr, "%lld", (long long) val);
-}
-
-void
-__go_print_double (double v)
-{
- char buf[20];
- int e, s, i, n;
- double h;
-
- if (isnan (v))
- {
- fputs ("NaN", stderr);
- return;
- }
- if (__builtin_isinf (v))
- {
- putc (v < 0 ? '-' : '+', stderr);
- fputs ("Inf", stderr);
- return;
- }
-
- /* The number of digits printed. */
- n = 7;
- /* The exponent. */
- e = 0;
- /* The sign. */
- s = 0;
- if (v != 0)
- {
- if (v < 0)
- {
- v = -v;
- s = 1;
- }
-
- /* Normalize. */
- while (v >= 10)
- {
- ++e;
- v /= 10;
- }
- while (v < 1)
- {
- --e;
- v *= 10;
- }
-
- /* Round. */
- h = 5;
- for (i = 0; i < n; ++i)
- h /= 10;
-
- v += h;
- if (v >= 10)
- {
- ++e;
- v /= 10;
- }
- }
-
- /* The format is +d.dddd+edd. */
- buf[0] = s ? '-' : '+';
- for (i = 0; i < n; ++i)
- {
- int d;
-
- d = v;
- buf[i + 2] = d + '0';
- v -= d;
- v *= 10;
- }
- buf[1] = buf[2];
- buf[2] = '.';
-
- buf[n + 2] = 'e';
- buf[n + 3] = e < 0 ? '-' : '+';
- if (e < 0)
- e = - e;
- buf[n + 4] = e / 100 + '0';
- buf[n + 5] = (e / 10) % 10 + '0';
- buf[n + 6] = e % 10 + '0';
- buf[n + 7] = '\0';
- fputs (buf, stderr);
-}
-
-void
-__go_print_complex (__complex double val)
-{
- putc ('(', stderr);
- __go_print_double (__builtin_creal (val));
- __go_print_double (__builtin_cimag (val));
- fputs ("i)", stderr);
-}
-
-void
-__go_print_bool (_Bool val)
-{
- fputs (val ? "true" : "false", stderr);
-}
-
-void
-__go_print_pointer (void *val)
-{
- fprintf (stderr, "0x%lx", (unsigned long) (uintptr_t) val);
-}
-
-void
__go_print_empty_interface (struct __go_empty_interface e)
{
- fprintf (stderr, "(%p,%p)", e.__type_descriptor, e.__object);
+ runtime_printf ("(%p,%p)", e.__type_descriptor, e.__object);
}
void
__go_print_interface (struct __go_interface i)
{
- fprintf (stderr, "(%p,%p)", i.__methods, i.__object);
+ runtime_printf ("(%p,%p)", i.__methods, i.__object);
}
void
__go_print_slice (struct __go_open_array val)
{
- fprintf (stderr, "[%d/%d]", val.__count, val.__capacity);
- __go_print_pointer (val.__values);
+ runtime_printf ("[%d/%d]", val.__count, val.__capacity);
+ runtime_printpointer (val.__values);
}
diff --git a/libgo/runtime/malloc.goc b/libgo/runtime/malloc.goc
index ae5e15fa9dd..1a40637c3dd 100644
--- a/libgo/runtime/malloc.goc
+++ b/libgo/runtime/malloc.goc
@@ -139,7 +139,7 @@ __go_free(void *v)
m->mallocing = 1;
if(!runtime_mlookup(v, nil, nil, &s)) {
- // runtime_printf("free %p: not an allocated block\n", v);
+ runtime_printf("free %p: not an allocated block\n", v);
runtime_throw("free runtime_mlookup");
}
prof = runtime_blockspecial(v);
@@ -367,7 +367,7 @@ runtime_mallocinit(void)
if(p == nil)
runtime_throw("runtime: cannot reserve arena virtual address space");
if((uintptr)p & (((uintptr)1<<PageShift)-1))
- runtime_printf("runtime: SysReserve returned unaligned address %p; asked for %p", p, (void*)(bitmap_size+arena_size));
+ runtime_printf("runtime: SysReserve returned unaligned address %p; asked for %p", p, bitmap_size+arena_size);
}
if((uintptr)p & (((uintptr)1<<PageShift)-1))
runtime_throw("runtime: SysReserve returned unaligned address");
@@ -467,15 +467,15 @@ func SetFinalizer(obj Eface, finalizer Eface) {
const FuncType *ft;
if(obj.__type_descriptor == nil) {
- // runtime·printf("runtime.SetFinalizer: first argument is nil interface\n");
+ runtime_printf("runtime.SetFinalizer: first argument is nil interface\n");
goto throw;
}
if(obj.__type_descriptor->__code != GO_PTR) {
- // runtime_printf("runtime.SetFinalizer: first argument is %S, not pointer\n", *obj.type->string);
+ runtime_printf("runtime.SetFinalizer: first argument is %S, not pointer\n", *obj.__type_descriptor->__reflection);
goto throw;
}
if(!runtime_mlookup(obj.__object, &base, &size, nil) || obj.__object != base) {
- // runtime_printf("runtime.SetFinalizer: pointer not at beginning of allocated block\n");
+ runtime_printf("runtime.SetFinalizer: pointer not at beginning of allocated block\n");
goto throw;
}
ft = nil;
@@ -494,7 +494,7 @@ func SetFinalizer(obj Eface, finalizer Eface) {
return;
badfunc:
- // runtime_printf("runtime.SetFinalizer: second argument is %S, not func(%S)\n", *finalizer.type->string, *obj.type->string);
+ runtime_printf("runtime.SetFinalizer: second argument is %S, not func(%S)\n", *finalizer.__type_descriptor->__reflection, *obj.__type_descriptor->__reflection);
throw:
runtime_throw("runtime.SetFinalizer");
}
diff --git a/libgo/runtime/mgc0.c b/libgo/runtime/mgc0.c
index c08d5c1548e..c84bdd67821 100644
--- a/libgo/runtime/mgc0.c
+++ b/libgo/runtime/mgc0.c
@@ -159,7 +159,7 @@ scanblock(byte *b, int64 n)
bool keepworking;
if((int64)(uintptr)n != n || n < 0) {
- // runtime_printf("scanblock %p %lld\n", b, (long long)n);
+ runtime_printf("scanblock %p %D\n", b, n);
runtime_throw("scanblock");
}
@@ -190,7 +190,7 @@ scanblock(byte *b, int64 n)
// Each iteration scans the block b of length n, queueing pointers in
// the work buffer.
if(Debug > 1)
- runtime_printf("scanblock %p %lld\n", b, (long long) n);
+ runtime_printf("scanblock %p %D\n", b, n);
vp = (void**)b;
n >>= (2+PtrSize/8); /* n /= PtrSize (4 or 8) */
@@ -346,7 +346,7 @@ debug_scanblock(byte *b, int64 n)
runtime_throw("debug_scanblock without DebugMark");
if((int64)(uintptr)n != n || n < 0) {
- //runtime_printf("debug_scanblock %p %D\n", b, n);
+ runtime_printf("debug_scanblock %p %D\n", b, n);
runtime_throw("debug_scanblock");
}
@@ -1047,14 +1047,13 @@ runtime_gc(int32 force)
mstats.pause_total_ns += t3 - t0;
mstats.numgc++;
if(mstats.debuggc)
- runtime_printf("pause %llu\n", (unsigned long long)t3-t0);
+ runtime_printf("pause %D\n", t3-t0);
if(gctrace) {
- runtime_printf("gc%d(%d): %llu+%llu+%llu ms %llu -> %llu MB %llu -> %llu (%llu-%llu) objects %llu handoff\n",
- mstats.numgc, work.nproc, (unsigned long long)(t1-t0)/1000000, (unsigned long long)(t2-t1)/1000000, (unsigned long long)(t3-t2)/1000000,
- (unsigned long long)heap0>>20, (unsigned long long)heap1>>20, (unsigned long long)obj0, (unsigned long long)obj1,
- (unsigned long long) mstats.nmalloc, (unsigned long long)mstats.nfree,
- (unsigned long long) nhandoff);
+ runtime_printf("gc%d(%d): %D+%D+%D ms, %D -> %D MB %D -> %D (%D-%D) objects\n",
+ mstats.numgc, work.nproc, (t1-t0)/1000000, (t2-t1)/1000000, (t3-t2)/1000000,
+ heap0>>20, heap1>>20, obj0, obj1,
+ mstats.nmalloc, mstats.nfree);
}
runtime_MProf_GC();
@@ -1152,8 +1151,8 @@ runtime_markallocated(void *v, uintptr n, bool noptr)
{
uintptr *b, obits, bits, off, shift;
- // if(0)
- // runtime_printf("markallocated %p+%p\n", v, n);
+ if(0)
+ runtime_printf("markallocated %p+%p\n", v, n);
if((byte*)v+n > (byte*)runtime_mheap.arena_used || (byte*)v < runtime_mheap.arena_start)
runtime_throw("markallocated: bad pointer");
@@ -1184,8 +1183,8 @@ runtime_markfreed(void *v, uintptr n)
{
uintptr *b, obits, bits, off, shift;
- // if(0)
- // runtime_printf("markallocated %p+%p\n", v, n);
+ if(0)
+ runtime_printf("markallocated %p+%p\n", v, n);
if((byte*)v+n > (byte*)runtime_mheap.arena_used || (byte*)v < runtime_mheap.arena_start)
runtime_throw("markallocated: bad pointer");
@@ -1227,7 +1226,7 @@ runtime_checkfreed(void *v, uintptr n)
bits = *b>>shift;
if((bits & bitAllocated) != 0) {
runtime_printf("checkfreed %p+%p: off=%p have=%p\n",
- v, (void*)n, (void*)off, (void*)(bits & bitMask));
+ v, n, off, bits & bitMask);
runtime_throw("checkfreed: not freed");
}
}
diff --git a/libgo/runtime/mheap.c b/libgo/runtime/mheap.c
index 6bf38aa9934..221c5af861e 100644
--- a/libgo/runtime/mheap.c
+++ b/libgo/runtime/mheap.c
@@ -191,7 +191,7 @@ MHeap_Grow(MHeap *h, uintptr npage)
v = runtime_MHeap_SysAlloc(h, ask);
}
if(v == nil) {
- runtime_printf("runtime: out of memory: cannot allocate %llu-byte block (%llu in use)\n", (unsigned long long)ask, (unsigned long long)mstats.heap_sys);
+ runtime_printf("runtime: out of memory: cannot allocate %D-byte block (%D in use)\n", (uint64)ask, mstats.heap_sys);
return false;
}
}
@@ -277,7 +277,7 @@ MHeap_FreeLocked(MHeap *h, MSpan *s)
PageID p;
if(s->state != MSpanInUse || s->ref != 0) {
- // runtime_printf("MHeap_FreeLocked - span %p ptr %p state %d ref %d\n", s, s->start<<PageShift, s->state, s->ref);
+ runtime_printf("MHeap_FreeLocked - span %p ptr %p state %d ref %d\n", s, s->start<<PageShift, s->state, s->ref);
runtime_throw("MHeap_FreeLocked - invalid free");
}
mstats.heap_idle += s->npages<<PageShift;
@@ -397,10 +397,10 @@ runtime_MHeap_Scavenger(void* dummy)
if(trace) {
if(sumreleased > 0)
- runtime_printf("scvg%d: %p MB released\n", k, (void*)(sumreleased>>20));
- runtime_printf("scvg%d: inuse: %lld, idle: %lld, sys: %lld, released: %lld, consumed: %lld (MB)\n",
- k, (long long)(mstats.heap_inuse>>20), (long long)(mstats.heap_idle>>20), (long long)(mstats.heap_sys>>20),
- (long long)(mstats.heap_released>>20), (long long)((mstats.heap_sys - mstats.heap_released)>>20));
+ runtime_printf("scvg%d: %p MB released\n", k, sumreleased>>20);
+ runtime_printf("scvg%d: inuse: %D, idle: %D, sys: %D, released: %D, consumed: %D (MB)\n",
+ k, mstats.heap_inuse>>20, mstats.heap_idle>>20, mstats.heap_sys>>20,
+ mstats.heap_released>>20, (mstats.heap_sys - mstats.heap_released)>>20);
}
}
}
@@ -451,7 +451,7 @@ void
runtime_MSpanList_Insert(MSpan *list, MSpan *span)
{
if(span->next != nil || span->prev != nil) {
- // runtime_printf("failed MSpanList_Insert %p %p %p\n", span, span->next, span->prev);
+ runtime_printf("failed MSpanList_Insert %p %p %p\n", span, span->next, span->prev);
runtime_throw("MSpanList_Insert");
}
span->next = list->next;
diff --git a/libgo/runtime/msize.c b/libgo/runtime/msize.c
index e2672b07f9a..3b5591c1b17 100644
--- a/libgo/runtime/msize.c
+++ b/libgo/runtime/msize.c
@@ -103,7 +103,7 @@ runtime_InitSizes(void)
sizeclass++;
}
if(sizeclass != NumSizeClasses) {
- // runtime_printf("sizeclass=%d NumSizeClasses=%d\n", sizeclass, NumSizeClasses);
+ runtime_printf("sizeclass=%d NumSizeClasses=%d\n", sizeclass, NumSizeClasses);
runtime_throw("InitSizes - bad NumSizeClasses");
}
@@ -122,13 +122,13 @@ runtime_InitSizes(void)
for(n=0; n < MaxSmallSize; n++) {
sizeclass = runtime_SizeToClass(n);
if(sizeclass < 1 || sizeclass >= NumSizeClasses || runtime_class_to_size[sizeclass] < n) {
- // runtime_printf("size=%d sizeclass=%d runtime_class_to_size=%d\n", n, sizeclass, runtime_class_to_size[sizeclass]);
- // runtime_printf("incorrect SizeToClass");
+ runtime_printf("size=%d sizeclass=%d runtime_class_to_size=%d\n", n, sizeclass, runtime_class_to_size[sizeclass]);
+ runtime_printf("incorrect SizeToClass");
goto dump;
}
if(sizeclass > 1 && runtime_class_to_size[sizeclass-1] >= n) {
- // runtime_printf("size=%d sizeclass=%d runtime_class_to_size=%d\n", n, sizeclass, runtime_class_to_size[sizeclass]);
- // runtime_printf("SizeToClass too big");
+ runtime_printf("size=%d sizeclass=%d runtime_class_to_size=%d\n", n, sizeclass, runtime_class_to_size[sizeclass]);
+ runtime_printf("SizeToClass too big");
goto dump;
}
}
diff --git a/libgo/runtime/runtime.c b/libgo/runtime/runtime.c
index 3c8d76225fc..72875fd53f7 100644
--- a/libgo/runtime/runtime.c
+++ b/libgo/runtime/runtime.c
@@ -236,3 +236,15 @@ runtime_showframe(const unsigned char *s)
traceback = runtime_gotraceback();
return traceback > 1 || (__builtin_strchr((const char*)s, '.') != nil && __builtin_memcmp(s, "runtime.", 7) != 0);
}
+
+bool
+runtime_isInf(float64 f, int32 sign)
+{
+ if(!__builtin_isinf(f))
+ return false;
+ if(sign == 0)
+ return true;
+ if(sign > 0)
+ return f > 0;
+ return f < 0;
+}
diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h
index 67dabd26b14..8828aa59e15 100644
--- a/libgo/runtime/runtime.h
+++ b/libgo/runtime/runtime.h
@@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
#include <ucontext.h>
@@ -275,6 +276,7 @@ int32 runtime_ncpu;
* common functions and data
*/
int32 runtime_findnull(const byte*);
+void runtime_dump(byte*, int32);
/*
* very low level c-called
@@ -286,6 +288,8 @@ void runtime_goenvs(void);
void runtime_goenvs_unix(void);
void runtime_throw(const char*) __attribute__ ((noreturn));
void runtime_panicstring(const char*) __attribute__ ((noreturn));
+void runtime_prints(const char*);
+void runtime_printf(const char*, ...);
void* runtime_mal(uintptr);
void runtime_schedinit(void);
void runtime_initsig(void);
@@ -374,9 +378,35 @@ void __wrap_rtems_task_variable_add(void **);
#endif
/*
+ * Names generated by gccgo.
+ */
+#define runtime_printbool __go_print_bool
+#define runtime_printfloat __go_print_double
+#define runtime_printint __go_print_int64
+#define runtime_printiface __go_print_interface
+#define runtime_printeface __go_print_empty_interface
+#define runtime_printstring __go_print_string
+#define runtime_printpointer __go_print_pointer
+#define runtime_printuint __go_print_uint64
+#define runtime_printslice __go_print_slice
+#define runtime_printcomplex __go_print_complex
+
+/*
* runtime go-called
*/
-void runtime_panic(Eface);
+void runtime_printbool(_Bool);
+void runtime_printfloat(double);
+void runtime_printint(int64);
+void runtime_printiface(Iface);
+void runtime_printeface(Eface);
+void runtime_printstring(String);
+void runtime_printpc(void*);
+void runtime_printpointer(void*);
+void runtime_printuint(uint64);
+void runtime_printhex(uint64);
+void runtime_printslice(Slice);
+void runtime_printcomplex(__complex double);
+
struct __go_func_type;
void reflect_call(const struct __go_func_type *, const void *, _Bool, _Bool,
void **, void **)
@@ -384,7 +414,7 @@ void reflect_call(const struct __go_func_type *, const void *, _Bool, _Bool,
/* Functions. */
#define runtime_panic __go_panic
-#define runtime_printf printf
+#define runtime_write(d, v, n) write((d), (v), (n))
#define runtime_malloc(s) __go_alloc(s)
#define runtime_free(p) __go_free(p)
#define runtime_strcmp(s1, s2) __builtin_strcmp((s1), (s2))
@@ -432,6 +462,8 @@ void runtime_newErrorString(String, Eface*)
/*
* wrapped for go users
*/
+bool runtime_isInf(float64 f, int32 sign);
+#define runtime_isNaN(f) __builtin_isnan(f)
void runtime_semacquire(uint32 volatile *);
void runtime_semrelease(uint32 volatile *);
int32 runtime_gomaxprocsfunc(int32 n);
diff --git a/libgo/runtime/thread-linux.c b/libgo/runtime/thread-linux.c
index 6a69fb429a4..0014068b2cd 100644
--- a/libgo/runtime/thread-linux.c
+++ b/libgo/runtime/thread-linux.c
@@ -68,7 +68,7 @@ runtime_futexwakeup(uint32 *addr, uint32 cnt)
// I don't know that futex wakeup can return
// EAGAIN or EINTR, but if it does, it would be
// safe to loop and call futex again.
- runtime_printf("futexwakeup addr=%p returned %lld\n", addr, (long long)ret);
+ runtime_printf("futexwakeup addr=%p returned %D\n", addr, ret);
*(int32*)0x1006 = 0x1006;
}
OpenPOWER on IntegriCloud