2008-06-05 20:38:39 -06:00
|
|
|
// 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"
|
2011-02-22 15:40:40 -07:00
|
|
|
#include "stack.h"
|
2012-04-05 08:47:43 -06:00
|
|
|
#include "arch_GOARCH.h"
|
2008-06-05 20:38:39 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
enum {
|
|
|
|
maxround = sizeof(uintptr),
|
|
|
|
};
|
|
|
|
|
2011-02-16 11:21:13 -07:00
|
|
|
uint32 runtime·panicking;
|
2011-08-04 06:31:03 -06:00
|
|
|
void (*runtime·destroylock)(Lock*);
|
2008-06-05 20:38:39 -06:00
|
|
|
|
2011-07-25 22:52:46 -06:00
|
|
|
/*
|
|
|
|
* We assume that all architectures turn faults and the like
|
|
|
|
* into apparent calls to runtime.sigpanic. If we see a "call"
|
|
|
|
* to runtime.sigpanic, we do not back up the PC to find the
|
|
|
|
* line number of the CALL instruction, because there is no CALL.
|
|
|
|
*/
|
|
|
|
void runtime·sigpanic(void);
|
|
|
|
|
2008-09-22 14:47:53 -06:00
|
|
|
int32
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·gotraceback(void)
|
2008-09-22 14:47:53 -06:00
|
|
|
{
|
|
|
|
byte *p;
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
p = runtime·getenv("GOTRACEBACK");
|
2008-09-22 14:47:53 -06:00
|
|
|
if(p == nil || p[0] == '\0')
|
|
|
|
return 1; // default is on
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
return runtime·atoi(p);
|
2008-09-22 14:47:53 -06:00
|
|
|
}
|
|
|
|
|
2011-02-16 11:21:13 -07:00
|
|
|
static Lock paniclk;
|
|
|
|
|
2008-06-16 18:04:30 -06:00
|
|
|
void
|
2011-02-16 11:21:13 -07:00
|
|
|
runtime·startpanic(void)
|
2008-06-16 18:04:30 -06:00
|
|
|
{
|
2011-02-16 11:21:13 -07:00
|
|
|
if(m->dying) {
|
|
|
|
runtime·printf("panic during panic\n");
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·exit(3);
|
2009-03-31 16:45:12 -06:00
|
|
|
}
|
2011-02-16 11:21:13 -07:00
|
|
|
m->dying = 1;
|
|
|
|
runtime·xadd(&runtime·panicking, 1);
|
|
|
|
runtime·lock(&paniclk);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime·dopanic(int32 unused)
|
|
|
|
{
|
|
|
|
static bool didothers;
|
2009-03-31 16:45:12 -06:00
|
|
|
|
2011-01-18 12:15:11 -07:00
|
|
|
if(g->sig != 0)
|
2011-08-22 21:26:39 -06:00
|
|
|
runtime·printf("[signal %x code=%p addr=%p pc=%p]\n",
|
2011-01-18 12:15:11 -07:00
|
|
|
g->sig, g->sigcode0, g->sigcode1, g->sigpc);
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
if(runtime·gotraceback()){
|
2011-08-22 21:26:39 -06:00
|
|
|
if(g != m->g0) {
|
|
|
|
runtime·printf("\n");
|
|
|
|
runtime·goroutineheader(g);
|
|
|
|
runtime·traceback(runtime·getcallerpc(&unused), runtime·getcallersp(&unused), 0, g);
|
|
|
|
}
|
2011-02-16 11:21:13 -07:00
|
|
|
if(!didothers) {
|
|
|
|
didothers = true;
|
|
|
|
runtime·tracebackothers(g);
|
|
|
|
}
|
2008-09-22 14:47:53 -06:00
|
|
|
}
|
2011-02-16 11:21:13 -07:00
|
|
|
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·lock(&deadlock);
|
|
|
|
runtime·lock(&deadlock);
|
|
|
|
}
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·exit(2);
|
2008-06-16 18:04:30 -06:00
|
|
|
}
|
|
|
|
|
2008-09-12 17:48:35 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicindex(void)
|
2008-09-12 17:48:35 -06:00
|
|
|
{
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("index out of range");
|
2008-09-12 17:48:35 -06:00
|
|
|
}
|
|
|
|
|
2009-08-28 13:37:39 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicslice(void)
|
2009-08-28 13:37:39 -06:00
|
|
|
{
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("slice bounds out of range");
|
2009-08-28 13:37:39 -06:00
|
|
|
}
|
|
|
|
|
2008-09-12 17:48:35 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·throwreturn(void)
|
2008-09-12 17:48:35 -06:00
|
|
|
{
|
2010-04-01 23:31:27 -06:00
|
|
|
// can only happen if compiler is broken
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·throw("no return at end of a typed function - compiler is broken");
|
2008-09-12 17:48:35 -06:00
|
|
|
}
|
|
|
|
|
2009-05-28 17:00:55 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·throwinit(void)
|
2009-05-28 17:00:55 -06:00
|
|
|
{
|
2010-04-01 23:31:27 -06:00
|
|
|
// can only happen with linker skew
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·throw("recursive call during initialization - linker skew");
|
2009-05-28 17:00:55 -06:00
|
|
|
}
|
|
|
|
|
2008-06-16 23:34:50 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·throw(int8 *s)
|
2008-06-05 20:38:39 -06:00
|
|
|
{
|
2011-02-16 11:21:13 -07:00
|
|
|
runtime·startpanic();
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·printf("throw: %s\n", s);
|
|
|
|
runtime·dopanic(0);
|
2009-03-31 18:33:04 -06:00
|
|
|
*(int32*)0 = 0; // not reached
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·exit(1); // even more not reached
|
2008-06-05 20:38:39 -06:00
|
|
|
}
|
|
|
|
|
2010-04-01 23:31:27 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring(int8 *s)
|
2010-04-01 23:31:27 -06:00
|
|
|
{
|
|
|
|
Eface err;
|
2012-03-15 20:17:54 -06:00
|
|
|
|
2011-01-25 14:35:36 -07:00
|
|
|
if(m->gcing) {
|
|
|
|
runtime·printf("panic: %s\n", s);
|
|
|
|
runtime·throw("panic during gc");
|
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·newErrorString(runtime·gostringnocopy((byte*)s), &err);
|
|
|
|
runtime·panic(err);
|
2010-04-01 23:31:27 -06:00
|
|
|
}
|
|
|
|
|
2009-01-26 13:36:21 -07:00
|
|
|
int32
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·mcmp(byte *s1, byte *s2, uint32 n)
|
2009-01-26 13:36:21 -07:00
|
|
|
{
|
|
|
|
uint32 i;
|
|
|
|
byte c1, c2;
|
|
|
|
|
|
|
|
for(i=0; i<n; i++) {
|
|
|
|
c1 = s1[i];
|
|
|
|
c2 = s2[i];
|
|
|
|
if(c1 < c2)
|
|
|
|
return -1;
|
|
|
|
if(c1 > c2)
|
|
|
|
return +1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-23 18:08:55 -07:00
|
|
|
byte*
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·mchr(byte *p, byte c, byte *ep)
|
2008-11-23 18:08:55 -07:00
|
|
|
{
|
|
|
|
for(; p < ep; p++)
|
|
|
|
if(*p == c)
|
|
|
|
return p;
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2008-07-13 15:29:46 -06:00
|
|
|
uint32
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·rnd(uint32 n, uint32 m)
|
2008-07-13 15:29:46 -06:00
|
|
|
{
|
|
|
|
uint32 r;
|
|
|
|
|
2008-11-05 22:50:28 -07:00
|
|
|
if(m > maxround)
|
|
|
|
m = maxround;
|
2008-07-13 15:29:46 -06:00
|
|
|
r = n % m;
|
|
|
|
if(r)
|
|
|
|
n += m-r;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2008-06-30 16:30:47 -06:00
|
|
|
static int32 argc;
|
|
|
|
static uint8** argv;
|
2009-01-16 15:58:14 -07:00
|
|
|
|
2009-08-25 16:54:25 -06:00
|
|
|
Slice os·Args;
|
2011-11-14 12:06:50 -07:00
|
|
|
Slice syscall·envs;
|
2008-06-30 16:30:47 -06:00
|
|
|
|
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·args(int32 c, uint8 **v)
|
2008-06-30 16:30:47 -06:00
|
|
|
{
|
|
|
|
argc = c;
|
|
|
|
argv = v;
|
|
|
|
}
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
int32 runtime·isplan9;
|
2011-01-20 08:22:20 -07:00
|
|
|
int32 runtime·iswindows;
|
2010-10-18 10:32:55 -06:00
|
|
|
|
2009-01-16 15:58:14 -07:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·goargs(void)
|
2008-08-04 17:43:49 -06:00
|
|
|
{
|
2011-01-11 17:48:15 -07:00
|
|
|
String *s;
|
|
|
|
int32 i;
|
2012-03-15 20:17:54 -06:00
|
|
|
|
2010-12-15 18:18:18 -07:00
|
|
|
// for windows implementation see "os" package
|
|
|
|
if(Windows)
|
|
|
|
return;
|
|
|
|
|
2011-01-11 17:48:15 -07:00
|
|
|
s = runtime·malloc(argc*sizeof s[0]);
|
2009-01-26 18:37:05 -07:00
|
|
|
for(i=0; i<argc; i++)
|
2011-01-11 17:48:15 -07:00
|
|
|
s[i] = runtime·gostringnocopy(argv[i]);
|
|
|
|
os·Args.array = (byte*)s;
|
2009-08-25 16:54:25 -06:00
|
|
|
os·Args.len = argc;
|
2009-05-08 16:21:41 -06:00
|
|
|
os·Args.cap = argc;
|
2011-01-11 17:48:15 -07:00
|
|
|
}
|
2009-01-16 15:58:14 -07:00
|
|
|
|
2011-01-11 17:48:15 -07:00
|
|
|
void
|
|
|
|
runtime·goenvs_unix(void)
|
|
|
|
{
|
|
|
|
String *s;
|
|
|
|
int32 i, n;
|
2012-03-15 20:17:54 -06:00
|
|
|
|
2011-01-11 17:48:15 -07:00
|
|
|
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]);
|
2011-11-14 12:06:50 -07:00
|
|
|
syscall·envs.array = (byte*)s;
|
|
|
|
syscall·envs.len = n;
|
|
|
|
syscall·envs.cap = n;
|
2008-08-04 17:43:49 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
byte*
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·getenv(int8 *s)
|
2008-08-04 17:43:49 -06:00
|
|
|
{
|
|
|
|
int32 i, j, len;
|
|
|
|
byte *v, *bs;
|
2009-04-09 19:16:21 -06:00
|
|
|
String* envv;
|
2009-01-16 15:58:14 -07:00
|
|
|
int32 envc;
|
2008-08-05 15:21:42 -06:00
|
|
|
|
2008-08-04 17:43:49 -06:00
|
|
|
bs = (byte*)s;
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
len = runtime·findnull(bs);
|
2011-11-14 12:06:50 -07:00
|
|
|
envv = (String*)syscall·envs.array;
|
|
|
|
envc = syscall·envs.len;
|
2008-08-04 17:43:49 -06:00
|
|
|
for(i=0; i<envc; i++){
|
2009-04-09 19:16:21 -06:00
|
|
|
if(envv[i].len <= len)
|
2009-03-30 01:01:07 -06:00
|
|
|
continue;
|
2009-04-09 19:16:21 -06:00
|
|
|
v = envv[i].str;
|
2008-08-04 17:43:49 -06:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-03-17 00:10:33 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·getgoroot(String out)
|
2010-03-17 00:10:33 -06:00
|
|
|
{
|
|
|
|
byte *p;
|
2010-03-24 10:40:09 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
p = runtime·getenv("GOROOT");
|
|
|
|
out = runtime·gostringnocopy(p);
|
2010-03-17 00:10:33 -06:00
|
|
|
FLUSH(&out);
|
|
|
|
}
|
2009-01-16 15:58:14 -07:00
|
|
|
|
2008-08-04 17:43:49 -06:00
|
|
|
int32
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·atoi(byte *p)
|
2008-08-04 17:43:49 -06:00
|
|
|
{
|
|
|
|
int32 n;
|
2008-08-05 15:21:42 -06:00
|
|
|
|
2008-08-04 17:43:49 -06:00
|
|
|
n = 0;
|
|
|
|
while('0' <= *p && *p <= '9')
|
|
|
|
n = n*10 + *p++ - '0';
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-04-05 08:47:43 -06:00
|
|
|
static void
|
|
|
|
TestAtomic64(void)
|
|
|
|
{
|
|
|
|
uint64 z64, x64;
|
|
|
|
|
|
|
|
z64 = 42;
|
|
|
|
x64 = 0;
|
|
|
|
PREFETCH(&z64);
|
|
|
|
if(runtime·cas64(&z64, &x64, 1))
|
|
|
|
runtime·throw("cas64 failed");
|
|
|
|
if(x64 != 42)
|
|
|
|
runtime·throw("cas64 failed");
|
|
|
|
if(!runtime·cas64(&z64, &x64, 1))
|
|
|
|
runtime·throw("cas64 failed");
|
|
|
|
if(x64 != 42 || z64 != 1)
|
|
|
|
runtime·throw("cas64 failed");
|
|
|
|
if(runtime·atomicload64(&z64) != 1)
|
|
|
|
runtime·throw("load64 failed");
|
|
|
|
runtime·atomicstore64(&z64, (1ull<<40)+1);
|
|
|
|
if(runtime·atomicload64(&z64) != (1ull<<40)+1)
|
|
|
|
runtime·throw("store64 failed");
|
|
|
|
if(runtime·xadd64(&z64, (1ull<<40)+1) != (2ull<<40)+2)
|
|
|
|
runtime·throw("xadd64 failed");
|
|
|
|
if(runtime·atomicload64(&z64) != (2ull<<40)+2)
|
|
|
|
runtime·throw("xadd64 failed");
|
|
|
|
}
|
|
|
|
|
2008-08-05 15:18:47 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·check(void)
|
2008-06-30 16:30:47 -06:00
|
|
|
{
|
|
|
|
int8 a;
|
|
|
|
uint8 b;
|
|
|
|
int16 c;
|
|
|
|
uint16 d;
|
|
|
|
int32 e;
|
|
|
|
uint32 f;
|
|
|
|
int64 g;
|
|
|
|
uint64 h;
|
2012-01-26 14:25:07 -07:00
|
|
|
float32 i, i1;
|
|
|
|
float64 j, j1;
|
2008-06-30 16:30:47 -06:00
|
|
|
void* k;
|
|
|
|
uint16* l;
|
2010-12-13 14:22:19 -07:00
|
|
|
struct x1 {
|
|
|
|
byte x;
|
|
|
|
};
|
|
|
|
struct y1 {
|
|
|
|
struct x1 x1;
|
|
|
|
byte y;
|
|
|
|
};
|
2008-06-30 16:30:47 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
if(sizeof(a) != 1) runtime·throw("bad a");
|
|
|
|
if(sizeof(b) != 1) runtime·throw("bad b");
|
|
|
|
if(sizeof(c) != 2) runtime·throw("bad c");
|
|
|
|
if(sizeof(d) != 2) runtime·throw("bad d");
|
|
|
|
if(sizeof(e) != 4) runtime·throw("bad e");
|
|
|
|
if(sizeof(f) != 4) runtime·throw("bad f");
|
|
|
|
if(sizeof(g) != 8) runtime·throw("bad g");
|
|
|
|
if(sizeof(h) != 8) runtime·throw("bad h");
|
|
|
|
if(sizeof(i) != 4) runtime·throw("bad i");
|
|
|
|
if(sizeof(j) != 8) runtime·throw("bad j");
|
|
|
|
if(sizeof(k) != sizeof(uintptr)) runtime·throw("bad k");
|
|
|
|
if(sizeof(l) != sizeof(uintptr)) runtime·throw("bad l");
|
2010-12-13 14:22:19 -07:00
|
|
|
if(sizeof(struct x1) != 1) runtime·throw("bad sizeof x1");
|
|
|
|
if(offsetof(struct y1, y) != 1) runtime·throw("bad offsetof y1.y");
|
|
|
|
if(sizeof(struct y1) != 2) runtime·throw("bad sizeof y1");
|
2008-08-04 17:43:49 -06:00
|
|
|
|
|
|
|
uint32 z;
|
|
|
|
z = 1;
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
if(!runtime·cas(&z, 1, 2))
|
|
|
|
runtime·throw("cas1");
|
2008-08-04 17:43:49 -06:00
|
|
|
if(z != 2)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·throw("cas2");
|
2008-08-05 15:21:42 -06:00
|
|
|
|
2008-08-04 17:43:49 -06:00
|
|
|
z = 4;
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
if(runtime·cas(&z, 5, 6))
|
|
|
|
runtime·throw("cas3");
|
2008-08-04 17:43:49 -06:00
|
|
|
if(z != 4)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·throw("cas4");
|
2008-08-04 17:43:49 -06:00
|
|
|
|
2012-01-26 14:25:07 -07:00
|
|
|
*(uint64*)&j = ~0ULL;
|
|
|
|
if(j == j)
|
|
|
|
runtime·throw("float64nan");
|
|
|
|
if(!(j != j))
|
|
|
|
runtime·throw("float64nan1");
|
|
|
|
|
|
|
|
*(uint64*)&j1 = ~1ULL;
|
|
|
|
if(j == j1)
|
|
|
|
runtime·throw("float64nan2");
|
|
|
|
if(!(j != j1))
|
|
|
|
runtime·throw("float64nan3");
|
|
|
|
|
|
|
|
*(uint32*)&i = ~0UL;
|
|
|
|
if(i == i)
|
|
|
|
runtime·throw("float32nan");
|
|
|
|
if(!(i != i))
|
|
|
|
runtime·throw("float32nan1");
|
|
|
|
|
|
|
|
*(uint32*)&i1 = ~1UL;
|
|
|
|
if(i == i1)
|
|
|
|
runtime·throw("float32nan2");
|
|
|
|
if(!(i != i1))
|
|
|
|
runtime·throw("float32nan3");
|
2012-04-05 08:47:43 -06:00
|
|
|
|
|
|
|
TestAtomic64();
|
2008-06-30 16:30:47 -06:00
|
|
|
}
|
2008-07-08 18:19:17 -06:00
|
|
|
|
2010-03-23 18:01:17 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·Caller(int32 skip, uintptr retpc, String retfile, int32 retline, bool retbool)
|
2010-03-23 18:01:17 -06:00
|
|
|
{
|
2011-07-25 22:52:46 -06:00
|
|
|
Func *f, *g;
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
uintptr pc;
|
2011-07-25 22:52:46 -06:00
|
|
|
uintptr rpc[2];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask for two PCs: the one we were asked for
|
|
|
|
* and what it called, so that we can see if it
|
|
|
|
* "called" sigpanic.
|
|
|
|
*/
|
|
|
|
retpc = 0;
|
|
|
|
if(runtime·callers(1+skip-1, rpc, 2) < 2) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
retfile = runtime·emptystring;
|
2010-03-23 18:01:17 -06:00
|
|
|
retline = 0;
|
|
|
|
retbool = false;
|
2011-07-25 22:52:46 -06:00
|
|
|
} else if((f = runtime·findfunc(rpc[1])) == nil) {
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
retfile = runtime·emptystring;
|
|
|
|
retline = 0;
|
|
|
|
retbool = true; // have retpc at least
|
2010-03-23 18:01:17 -06:00
|
|
|
} else {
|
2011-07-25 22:52:46 -06:00
|
|
|
retpc = rpc[1];
|
2010-03-23 18:01:17 -06:00
|
|
|
retfile = f->src;
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
pc = retpc;
|
2011-07-25 22:52:46 -06:00
|
|
|
g = runtime·findfunc(rpc[0]);
|
|
|
|
if(pc > f->entry && (g == nil || g->entry != (uintptr)runtime·sigpanic))
|
runtime: more detailed panic traces, line number work
Follow morestack, so that crashes during a stack split
give complete traces. Also mark stack segment boundaries
as an aid to debugging.
Correct various line number bugs with yet another attempt
at interpreting the pc/ln table. This one has a chance at
being correct, because I based it on reading src/cmd/ld/lib.c
instead of on reading the documentation.
Fixes #1138.
Fixes #1430.
Fixes #1461.
throw: runtime: split stack overflow
runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78
runtime.throw(0x81880af, 0xf75c8b18)
runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728
runtime.newstack()
runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184
runtime.morestack()
----- morestack called from stack: -----
runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288
runtime.new(0x1, 0x0, 0x0)
gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344
gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1)
----- stack segment boundary -----
gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287
gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1)
gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255
gongo.TestEasyScore(0xf764b710, 0x818a990)
testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132
testing.tRunner(0xf764b710, 0xf763b5dc, 0x0)
runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149
runtime.goexit()
R=ken2, r
CC=golang-dev
https://golang.org/cl/4000053
2011-02-02 14:44:20 -07:00
|
|
|
pc--;
|
|
|
|
retline = runtime·funcline(f, pc);
|
2010-03-23 18:01:17 -06:00
|
|
|
retbool = true;
|
|
|
|
}
|
2011-07-25 22:52:46 -06:00
|
|
|
FLUSH(&retpc);
|
2010-03-23 18:01:17 -06:00
|
|
|
FLUSH(&retfile);
|
|
|
|
FLUSH(&retline);
|
|
|
|
FLUSH(&retbool);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·Callers(int32 skip, Slice pc, int32 retn)
|
2010-03-23 18:01:17 -06:00
|
|
|
{
|
2011-08-22 21:26:39 -06:00
|
|
|
// runtime.callers uses pc.array==nil as a signal
|
|
|
|
// to print a stack trace. Pick off 0-length pc here
|
|
|
|
// so that we don't let a nil pc slice get to it.
|
|
|
|
if(pc.len == 0)
|
|
|
|
retn = 0;
|
|
|
|
else
|
|
|
|
retn = runtime·callers(skip, (uintptr*)pc.array, pc.len);
|
2010-03-23 18:01:17 -06:00
|
|
|
FLUSH(&retn);
|
|
|
|
}
|
2010-03-24 10:40:09 -06:00
|
|
|
|
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·FuncForPC(uintptr pc, void *retf)
|
2010-03-24 10:40:09 -06:00
|
|
|
{
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
retf = runtime·findfunc(pc);
|
2010-03-24 10:40:09 -06:00
|
|
|
FLUSH(&retf);
|
|
|
|
}
|
2011-07-11 23:23:58 -06:00
|
|
|
|
|
|
|
uint32
|
|
|
|
runtime·fastrand1(void)
|
|
|
|
{
|
|
|
|
uint32 x;
|
|
|
|
|
|
|
|
x = m->fastrand;
|
|
|
|
x += x;
|
|
|
|
if(x & 0x80000000L)
|
|
|
|
x ^= 0x88888eefUL;
|
|
|
|
m->fastrand = x;
|
|
|
|
return x;
|
|
|
|
}
|