summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-05-08 15:21:41 -0700
committerRuss Cox <rsc@golang.org>2009-05-08 15:21:41 -0700
commit1ea895d9a458c9e4a91993924fcd39ce7f1dcabe (patch)
tree5b8c80c41b4110b57cef1a0945350c2caf7557e2 /src
parent206ea17d5fe6ad6d6492afe73ec2d72ce399a3fd (diff)
downloadgolang-1ea895d9a458c9e4a91993924fcd39ce7f1dcabe.tar.gz
move things out of sys into os and runtime
R=r OCL=28569 CL=28573
Diffstat (limited to 'src')
-rw-r--r--src/cmd/gc/Makefile2
-rw-r--r--src/cmd/gc/builtin.c.boot15
-rw-r--r--src/cmd/gc/go.h1
-rw-r--r--src/cmd/gc/lex.c4
-rwxr-xr-xsrc/cmd/gc/mkbuiltin9
-rw-r--r--src/cmd/gc/runtime.go9
-rw-r--r--src/cmd/gc/sys.go14
-rw-r--r--src/cmd/gobuild/gobuild.go2
-rw-r--r--src/cmd/gobuild/util.go2
-rw-r--r--src/lib/flag/flag.go24
-rw-r--r--src/lib/http/triv.go2
-rw-r--r--src/lib/log/log.go9
-rw-r--r--src/lib/os/Makefile5
-rw-r--r--src/lib/os/env.go2
-rw-r--r--src/lib/os/file.go2
-rw-r--r--src/lib/regexp/regexp.go3
-rw-r--r--src/lib/template/template.go5
-rw-r--r--src/lib/testing/testing.go6
-rw-r--r--src/runtime/386/asm.s4
-rw-r--r--src/runtime/386/traceback.c2
-rw-r--r--src/runtime/amd64/asm.s4
-rw-r--r--src/runtime/amd64/traceback.c2
-rw-r--r--src/runtime/chan.c10
-rw-r--r--src/runtime/darwin/386/signal.c6
-rw-r--r--src/runtime/darwin/386/sys.s2
-rw-r--r--src/runtime/darwin/amd64/signal.c6
-rw-r--r--src/runtime/darwin/amd64/sys.s2
-rw-r--r--src/runtime/linux/386/signal.c6
-rwxr-xr-xsrc/runtime/linux/386/sys.s2
-rw-r--r--src/runtime/linux/amd64/signal.c6
-rw-r--r--src/runtime/linux/amd64/sys.s2
-rw-r--r--src/runtime/proc.c30
-rw-r--r--src/runtime/runtime.c28
-rw-r--r--src/runtime/runtime.h12
-rw-r--r--src/runtime/sema.c2
-rw-r--r--src/runtime/string.c2
36 files changed, 132 insertions, 112 deletions
diff --git a/src/cmd/gc/Makefile b/src/cmd/gc/Makefile
index 0fc15deaa..0083240e4 100644
--- a/src/cmd/gc/Makefile
+++ b/src/cmd/gc/Makefile
@@ -44,7 +44,7 @@ y.tab.h: $(YFILES)
y.tab.c: y.tab.h
test -f y.tab.c && touch y.tab.c
-builtin.c: sys.go unsafe.go mkbuiltin1.c mkbuiltin
+builtin.c: sys.go unsafe.go runtime.go mkbuiltin1.c mkbuiltin
./mkbuiltin >builtin.c || \
(echo 'mkbuiltin failed; using bootstrap copy of builtin.c'; cp builtin.c.boot builtin.c)
diff --git a/src/cmd/gc/builtin.c.boot b/src/cmd/gc/builtin.c.boot
index 0f189d363..8657944b5 100644
--- a/src/cmd/gc/builtin.c.boot
+++ b/src/cmd/gc/builtin.c.boot
@@ -55,13 +55,6 @@ char *sysimport =
"func sys.arrayslices (old *any, nel int, lb int, hb int, width int) (ary []any)\n"
"func sys.arrays2d (old *any, nel int) (ary []any)\n"
"func sys.closure ()\n"
- "func sys.Breakpoint ()\n"
- "var sys.Args []string\n"
- "var sys.Envs []string\n"
- "func sys.Gosched ()\n"
- "func sys.Goexit ()\n"
- "func sys.Exit (? int)\n"
- "func sys.Caller (n int) (pc uint64, file string, line int, ok bool)\n"
"\n"
"$$\n";
char *unsafeimport =
@@ -74,3 +67,11 @@ char *unsafeimport =
"func unsafe.Unreflect (? uint64, ? string, ? bool) (ret interface { })\n"
"\n"
"$$\n";
+char *runtimeimport =
+ "package runtime\n"
+ "func runtime.Breakpoint ()\n"
+ "func runtime.Gosched ()\n"
+ "func runtime.Goexit ()\n"
+ "func runtime.Caller (n int) (pc uint64, file string, line int, ok bool)\n"
+ "\n"
+ "$$\n";
diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h
index a74dd645c..29e2fd64b 100644
--- a/src/cmd/gc/go.h
+++ b/src/cmd/gc/go.h
@@ -541,6 +541,7 @@ EXTERN Sym* pkgimportname; // package name from imported package
EXTERN int tptr; // either TPTR32 or TPTR64
extern char* sysimport;
extern char* unsafeimport;
+extern char* runtimeimport;
EXTERN char* filename; // name to uniqify names
EXTERN Idir* idirs;
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c
index b84d91ba7..e5edf5051 100644
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -265,6 +265,10 @@ importfile(Val *f)
cannedimports("unsafe.6", unsafeimport);
return;
}
+ if(strcmp(f->u.sval->s, "runtime") == 0) {
+ cannedimports("runtime.6", runtimeimport);
+ return;
+ }
if(!findpkg(f->u.sval))
fatal("can't find import: %Z", f->u.sval);
diff --git a/src/cmd/gc/mkbuiltin b/src/cmd/gc/mkbuiltin
index e0c29c1bb..b0cb634f5 100755
--- a/src/cmd/gc/mkbuiltin
+++ b/src/cmd/gc/mkbuiltin
@@ -5,11 +5,12 @@
set -e
gcc -o mkbuiltin1 mkbuiltin1.c
-6g sys.go
-6g unsafe.go
rm -f _builtin.c
-./mkbuiltin1 sys >_builtin.c
-./mkbuiltin1 unsafe >>_builtin.c
+for i in sys unsafe runtime
+do
+ 6g $i.go
+ ./mkbuiltin1 $i >>_builtin.c
+done
# If _builtin.c has changed vs builtin.c.boot,
# check in the new change if being run by
diff --git a/src/cmd/gc/runtime.go b/src/cmd/gc/runtime.go
new file mode 100644
index 000000000..6b9722ac5
--- /dev/null
+++ b/src/cmd/gc/runtime.go
@@ -0,0 +1,9 @@
+// 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.
+
+package PACKAGE
+func Breakpoint();
+func Gosched();
+func Goexit();
+func Caller(n int) (pc uint64, file string, line int, ok bool);
diff --git a/src/cmd/gc/sys.go b/src/cmd/gc/sys.go
index f77771a09..67fbb0391 100644
--- a/src/cmd/gc/sys.go
+++ b/src/cmd/gc/sys.go
@@ -72,17 +72,3 @@ func arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any);
func arrays2d(old *any, nel int) (ary []any);
func closure(); // has args, but compiler fills in
-
-// used by go programs
-
-func Breakpoint();
-
-var Args []string;
-var Envs []string;
-
-func Gosched();
-func Goexit();
-
-func Exit(int);
-
-func Caller(n int) (pc uint64, file string, line int, ok bool);
diff --git a/src/cmd/gobuild/gobuild.go b/src/cmd/gobuild/gobuild.go
index 9324e98ff..0db9bca04 100644
--- a/src/cmd/gobuild/gobuild.go
+++ b/src/cmd/gobuild/gobuild.go
@@ -131,7 +131,7 @@ func ScanFiles(filenames []string) *Info {
// TODO(rsc): Build a binary from package main?
z := new(Info);
- z.Args = sys.Args;
+ z.Args = os.Args;
z.Dir = PkgDir();
z.Char = theChar; // for template
z.ObjDir = ObjDir; // for template
diff --git a/src/cmd/gobuild/util.go b/src/cmd/gobuild/util.go
index 34351cea8..be50ba1ca 100644
--- a/src/cmd/gobuild/util.go
+++ b/src/cmd/gobuild/util.go
@@ -34,7 +34,7 @@ const ObjDir = "_obj"
func fatal(args ...) {
fmt.Fprintf(os.Stderr, "gobuild: %s\n", fmt.Sprint(args));
- sys.Exit(1);
+ os.Exit(1);
}
func init() {
diff --git a/src/lib/flag/flag.go b/src/lib/flag/flag.go
index e66238f6d..63d649a9b 100644
--- a/src/lib/flag/flag.go
+++ b/src/lib/flag/flag.go
@@ -261,15 +261,15 @@ func PrintDefaults() {
}
// Usage prints to standard error a default usage message documenting all defined flags and
-// then calls sys.Exit(1).
+// then calls os.Exit(1).
func Usage() {
- if len(sys.Args) > 0 {
- fmt.Fprintln(os.Stderr, "Usage of", sys.Args[0] + ":");
+ if len(os.Args) > 0 {
+ fmt.Fprintln(os.Stderr, "Usage of", os.Args[0] + ":");
} else {
fmt.Fprintln(os.Stderr, "Usage:");
}
PrintDefaults();
- sys.Exit(1);
+ os.Exit(1);
}
func NFlag() int {
@@ -280,20 +280,20 @@ func NFlag() int {
// after flags have been processed.
func Arg(i int) string {
i += flags.first_arg;
- if i < 0 || i >= len(sys.Args) {
+ if i < 0 || i >= len(os.Args) {
return "";
}
- return sys.Args[i]
+ return os.Args[i]
}
// NArg is the number of arguments remaining after flags have been processed.
func NArg() int {
- return len(sys.Args) - flags.first_arg
+ return len(os.Args) - flags.first_arg
}
// Args returns the non-flag command-line arguments.
func Args() []string {
- return sys.Args[flags.first_arg:len(sys.Args)];
+ return os.Args[flags.first_arg:len(os.Args)];
}
func add(name string, value FlagValue, usage string) {
@@ -393,7 +393,7 @@ func String(name, value string, usage string) *string {
func (f *allFlags) parseOne(index int) (ok bool, next int)
{
- s := sys.Args[index];
+ s := os.Args[index];
f.first_arg = index; // until proven otherwise
if len(s) == 0 {
return false, -1
@@ -450,11 +450,11 @@ func (f *allFlags) parseOne(index int) (ok bool, next int)
}
} else {
// It must have a value, which might be the next argument.
- if !has_value && index < len(sys.Args)-1 {
+ if !has_value && index < len(os.Args)-1 {
// value is the next arg
has_value = true;
index++;
- value = sys.Args[index];
+ value = os.Args[index];
}
if !has_value {
print("flag needs an argument: -", name, "\n");
@@ -473,7 +473,7 @@ func (f *allFlags) parseOne(index int) (ok bool, next int)
// Parse parses the command-line flags. Must be called after all flags are defined
// and before any are accessed by the program.
func Parse() {
- for i := 1; i < len(sys.Args); {
+ for i := 1; i < len(os.Args); {
ok, next := flags.parseOne(i);
if next > 0 {
flags.first_arg = next;
diff --git a/src/lib/http/triv.go b/src/lib/http/triv.go
index d2e074d73..f8b59ebea 100644
--- a/src/lib/http/triv.go
+++ b/src/lib/http/triv.go
@@ -74,7 +74,7 @@ func FlagServer(c *http.Conn, req *http.Request) {
// simple argument server
func ArgServer(c *http.Conn, req *http.Request) {
- for i, s := range sys.Args {
+ for i, s := range os.Args {
fmt.Fprint(c, s, " ");
}
}
diff --git a/src/lib/log/log.go b/src/lib/log/log.go
index 4a679a839..f5e4dd4a9 100644
--- a/src/lib/log/log.go
+++ b/src/lib/log/log.go
@@ -14,6 +14,7 @@ package log
import (
"fmt";
"io";
+ "runtime";
"os";
"time";
)
@@ -96,7 +97,7 @@ func (l *Logger) formatHeader(ns int64, calldepth int) string {
}
}
if l.flag & (Lshortfile | Llongfile) != 0 {
- pc, file, line, ok := sys.Caller(calldepth);
+ pc, file, line, ok := runtime.Caller(calldepth);
if ok {
if l.flag & Lshortfile != 0 {
short, ok := shortnames[file];
@@ -139,7 +140,7 @@ func (l *Logger) Output(calldepth int, s string) {
case Lcrash:
panic("log: fatal error");
case Lexit:
- sys.Exit(1);
+ os.Exit(1);
}
}
@@ -173,12 +174,12 @@ func Stderrf(format string, v ...) {
stderr.Output(2, fmt.Sprintf(format, v))
}
-// Exit is equivalent to Stderr() followed by a call to sys.Exit(1).
+// Exit is equivalent to Stderr() followed by a call to os.Exit(1).
func Exit(v ...) {
exit.Output(2, fmt.Sprintln(v))
}
-// Exitf is equivalent to Stderrf() followed by a call to sys.Exit(1).
+// Exitf is equivalent to Stderrf() followed by a call to os.Exit(1).
func Exitf(format string, v ...) {
exit.Output(2, fmt.Sprintf(format, v))
}
diff --git a/src/lib/os/Makefile b/src/lib/os/Makefile
index b563da3f3..e7b49e5b9 100644
--- a/src/lib/os/Makefile
+++ b/src/lib/os/Makefile
@@ -3,7 +3,7 @@
# license that can be found in the LICENSE file.
# DO NOT EDIT. Automatically generated by gobuild.
-# gobuild -m dir_${GOARCH}_${GOOS}.go env.go error.go file.go stat_${GOARCH}_${GOOS}.go time.go types.go exec.go >Makefile
+# gobuild -m dir_${GOARCH}_${GOOS}.go env.go error.go file.go proc.go stat_${GOARCH}_${GOOS}.go time.go types.go exec.go >Makefile
D=
@@ -41,6 +41,7 @@ coverage: packages
O1=\
error.$O\
+ proc.$O\
types.$O\
O2=\
@@ -60,7 +61,7 @@ phases: a1 a2 a3 a4
_obj$D/os.a: phases
a1: $(O1)
- $(AR) grc _obj$D/os.a error.$O types.$O
+ $(AR) grc _obj$D/os.a error.$O proc.$O types.$O
rm -f $(O1)
a2: $(O2)
diff --git a/src/lib/os/env.go b/src/lib/os/env.go
index e7df309e0..748750413 100644
--- a/src/lib/os/env.go
+++ b/src/lib/os/env.go
@@ -19,7 +19,7 @@ var env map[string] string;
func copyenv() {
env = make(map[string] string);
- for i, s := range sys.Envs {
+ for i, s := range os.Envs {
for j := 0; j < len(s); j++ {
if s[j] == '=' {
env[s[0:j]] = s[j+1:len(s)];
diff --git a/src/lib/os/file.go b/src/lib/os/file.go
index fa1784a42..9b22a896d 100644
--- a/src/lib/os/file.go
+++ b/src/lib/os/file.go
@@ -132,7 +132,7 @@ func (file *File) Write(b []byte) (ret int, err Error) {
if e == syscall.EPIPE {
file.nepipe++;
if file.nepipe >= 10 {
- sys.Exit(syscall.EPIPE);
+ os.Exit(syscall.EPIPE);
}
} else {
file.nepipe = 0;
diff --git a/src/lib/regexp/regexp.go b/src/lib/regexp/regexp.go
index 135dcc368..8cbd38035 100644
--- a/src/lib/regexp/regexp.go
+++ b/src/lib/regexp/regexp.go
@@ -25,6 +25,7 @@ package regexp
import (
"container/vector";
"os";
+ "runtime";
"utf8";
)
@@ -236,7 +237,7 @@ func (nop *_Nop) print() { print("nop") }
func (re *Regexp) setError(err os.Error) {
re.error = err;
re.ch <- re;
- sys.Goexit();
+ runtime.Goexit();
}
func (re *Regexp) add(i instr) instr {
diff --git a/src/lib/template/template.go b/src/lib/template/template.go
index b886b3181..182a85b42 100644
--- a/src/lib/template/template.go
+++ b/src/lib/template/template.go
@@ -44,7 +44,7 @@
first looked for in the cursor, as in .section and .repeated.
If it is not found, the search continues in outer sections
until the top level is reached.
-
+
If a formatter is specified, it must be named in the formatter
map passed to the template set up routines or in the default
set ("html","str","") and is used to process the data for
@@ -61,6 +61,7 @@ import (
"io";
"os";
"reflect";
+ "runtime";
"strings";
"template";
"container/vector";
@@ -181,7 +182,7 @@ func New(fmap FormatterMap) *Template {
// Generic error handler, called only from execError or parseError.
func error(errors chan os.Error, line int, err string, args ...) {
errors <- ParseError{fmt.Sprintf("line %d: %s", line, fmt.Sprintf(err, args))};
- sys.Goexit();
+ runtime.Goexit();
}
// Report error and stop executing. The line number must be provided explicitly.
diff --git a/src/lib/testing/testing.go b/src/lib/testing/testing.go
index 2f717d0e9..63e4af5e9 100644
--- a/src/lib/testing/testing.go
+++ b/src/lib/testing/testing.go
@@ -14,6 +14,8 @@ package testing
import (
"flag";
"fmt";
+ "os";
+ "runtime";
)
// Report as tests are run; default is silent for success.
@@ -47,7 +49,7 @@ func (t *T) Fail() {
func (t *T) FailNow() {
t.Fail();
t.ch <- t;
- sys.Goexit();
+ runtime.Goexit();
}
// Log formats its arguments using default formatting, analogous to Print(),
@@ -129,7 +131,7 @@ func Main(tests []Test) {
}
if !ok {
println("FAIL");
- sys.Exit(1);
+ os.Exit(1);
}
println("PASS");
}
diff --git a/src/runtime/386/asm.s b/src/runtime/386/asm.s
index 3ef8d8e47..9dd9c11a9 100644
--- a/src/runtime/386/asm.s
+++ b/src/runtime/386/asm.s
@@ -84,12 +84,12 @@ TEXT mainstart(SB),7,$0
CALL initdone(SB)
CALL main·main(SB)
PUSHL $0
- CALL sys·Exit(SB)
+ CALL exit(SB)
POPL AX
INT $3
RET
-TEXT sys·Breakpoint(SB),7,$0
+TEXT breakpoint(SB),7,$0
BYTE $0xcc
RET
diff --git a/src/runtime/386/traceback.c b/src/runtime/386/traceback.c
index b60512ab1..23e92d892 100644
--- a/src/runtime/386/traceback.c
+++ b/src/runtime/386/traceback.c
@@ -82,7 +82,7 @@ traceback(byte *pc0, byte *sp, G *g)
// func caller(n int) (pc uint64, file string, line int, ok bool)
void
-sys·Caller(int32 n, uint64 retpc, string retfile, int32 retline, bool retbool)
+runtime·Caller(int32 n, uint64 retpc, string retfile, int32 retline, bool retbool)
{
uint64 pc;
byte *sp;
diff --git a/src/runtime/amd64/asm.s b/src/runtime/amd64/asm.s
index cad656e70..b69259e31 100644
--- a/src/runtime/amd64/asm.s
+++ b/src/runtime/amd64/asm.s
@@ -55,12 +55,12 @@ TEXT mainstart(SB),7,$0
CALL initdone(SB)
CALL main·main(SB)
PUSHQ $0
- CALL sys·Exit(SB)
+ CALL exit(SB)
POPQ AX
CALL notok(SB)
RET
-TEXT sys·Breakpoint(SB),7,$0
+TEXT breakpoint(SB),7,$0
BYTE $0xcc
RET
diff --git a/src/runtime/amd64/traceback.c b/src/runtime/amd64/traceback.c
index 2e237a21f..16d7bed72 100644
--- a/src/runtime/amd64/traceback.c
+++ b/src/runtime/amd64/traceback.c
@@ -79,7 +79,7 @@ traceback(byte *pc0, byte *sp, G *g)
// func caller(n int) (pc uint64, file string, line int, ok bool)
void
-sys·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbool)
+runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbool)
{
uint64 pc;
byte *sp;
diff --git a/src/runtime/chan.c b/src/runtime/chan.c
index 59ac78d79..be65bcbc1 100644
--- a/src/runtime/chan.c
+++ b/src/runtime/chan.c
@@ -211,7 +211,7 @@ loop:
g->status = Gwaiting;
enqueue(&c->sendq, sg);
unlock(&chanlock);
- sys·Gosched();
+ gosched();
lock(&chanlock);
sg = g->param;
@@ -237,7 +237,7 @@ asynch:
g->status = Gwaiting;
enqueue(&c->sendq, sg);
unlock(&chanlock);
- sys·Gosched();
+ gosched();
lock(&chanlock);
goto asynch;
@@ -311,7 +311,7 @@ loop:
g->status = Gwaiting;
enqueue(&c->recvq, sg);
unlock(&chanlock);
- sys·Gosched();
+ gosched();
lock(&chanlock);
sg = g->param;
@@ -339,7 +339,7 @@ asynch:
g->status = Gwaiting;
enqueue(&c->recvq, sg);
unlock(&chanlock);
- sys·Gosched();
+ gosched();
lock(&chanlock);
goto asynch;
@@ -748,7 +748,7 @@ loop:
g->param = nil;
g->status = Gwaiting;
unlock(&chanlock);
- sys·Gosched();
+ gosched();
lock(&chanlock);
sg = g->param;
diff --git a/src/runtime/darwin/386/signal.c b/src/runtime/darwin/386/signal.c
index a6c782294..3a63c4b38 100644
--- a/src/runtime/darwin/386/signal.c
+++ b/src/runtime/darwin/386/signal.c
@@ -33,7 +33,7 @@ sighandler(int32 sig, Siginfo *info, void *context)
Regs *r;
if(panicking) // traceback already printed
- sys_Exit(2);
+ exit(2);
panicking = 1;
if(sig < 0 || sig >= NSIG){
@@ -56,8 +56,8 @@ sighandler(int32 sig, Siginfo *info, void *context)
dumpregs(r);
}
- sys·Breakpoint();
- sys_Exit(2);
+ breakpoint();
+ exit(2);
}
void
diff --git a/src/runtime/darwin/386/sys.s b/src/runtime/darwin/386/sys.s
index 93dd4e300..1ad6d2ace 100644
--- a/src/runtime/darwin/386/sys.s
+++ b/src/runtime/darwin/386/sys.s
@@ -11,7 +11,7 @@ TEXT notok(SB),7,$0
RET
// Exit the entire program (like C exit)
-TEXT sys·Exit(SB),7,$0
+TEXT exit(SB),7,$0
MOVL $1, AX
INT $0x80
CALL notok(SB)
diff --git a/src/runtime/darwin/amd64/signal.c b/src/runtime/darwin/amd64/signal.c
index 88cddeb00..45e5e8d47 100644
--- a/src/runtime/darwin/amd64/signal.c
+++ b/src/runtime/darwin/amd64/signal.c
@@ -41,7 +41,7 @@ sighandler(int32 sig, Siginfo *info, void *context)
Regs *r;
if(panicking) // traceback already printed
- sys_Exit(2);
+ exit(2);
panicking = 1;
if(sig < 0 || sig >= NSIG){
@@ -64,8 +64,8 @@ sighandler(int32 sig, Siginfo *info, void *context)
dumpregs(r);
}
- sys·Breakpoint();
- sys_Exit(2);
+ breakpoint();
+ exit(2);
}
void
diff --git a/src/runtime/darwin/amd64/sys.s b/src/runtime/darwin/amd64/sys.s
index e16983346..4238cd185 100644
--- a/src/runtime/darwin/amd64/sys.s
+++ b/src/runtime/darwin/amd64/sys.s
@@ -9,7 +9,7 @@
//
// Exit the entire program (like C exit)
-TEXT sys·Exit(SB),7,$-8
+TEXT exit(SB),7,$-8
MOVL 8(SP), DI // arg 1 exit status
MOVL $(0x2000000+1), AX // syscall entry
SYSCALL
diff --git a/src/runtime/linux/386/signal.c b/src/runtime/linux/386/signal.c
index 9cbd9fa85..7dfca6bb4 100644
--- a/src/runtime/linux/386/signal.c
+++ b/src/runtime/linux/386/signal.c
@@ -40,7 +40,7 @@ sighandler(int32 sig, Siginfo* info, void* context)
Sigcontext *sc;
if(panicking) // traceback already printed
- sys_Exit(2);
+ exit(2);
panicking = 1;
uc = context;
@@ -61,8 +61,8 @@ sighandler(int32 sig, Siginfo* info, void* context)
dumpregs(sc);
}
- sys·Breakpoint();
- sys_Exit(2);
+ breakpoint();
+ exit(2);
}
void
diff --git a/src/runtime/linux/386/sys.s b/src/runtime/linux/386/sys.s
index 379d153e4..419973a5c 100755
--- a/src/runtime/linux/386/sys.s
+++ b/src/runtime/linux/386/sys.s
@@ -20,7 +20,7 @@ TEXT syscall(SB),7,$0
INT $3 // not reached
RET
-TEXT sys·Exit(SB),7,$0
+TEXT exit(SB),7,$0
MOVL $252, AX // syscall number
MOVL 4(SP), BX
INT $0x80
diff --git a/src/runtime/linux/amd64/signal.c b/src/runtime/linux/amd64/signal.c
index 5f3574f8e..55215176d 100644
--- a/src/runtime/linux/amd64/signal.c
+++ b/src/runtime/linux/amd64/signal.c
@@ -49,7 +49,7 @@ sighandler(int32 sig, Siginfo* info, void* context)
Sigcontext *sc;
if(panicking) // traceback already printed
- sys_Exit(2);
+ exit(2);
panicking = 1;
uc = context;
@@ -71,8 +71,8 @@ sighandler(int32 sig, Siginfo* info, void* context)
dumpregs(sc);
}
- sys·Breakpoint();
- sys_Exit(2);
+ breakpoint();
+ exit(2);
}
void
diff --git a/src/runtime/linux/amd64/sys.s b/src/runtime/linux/amd64/sys.s
index 5c4d98f97..f90c704fa 100644
--- a/src/runtime/linux/amd64/sys.s
+++ b/src/runtime/linux/amd64/sys.s
@@ -6,7 +6,7 @@
// System calls and other sys.stuff for AMD64, Linux
//
-TEXT sys·Exit(SB),7,$0-8
+TEXT exit(SB),7,$0-8
MOVL 8(SP), DI
MOVL $231, AX // exitgroup - force all os threads to exi
SYSCALL
diff --git a/src/runtime/proc.c b/src/runtime/proc.c
index 3875916e7..d52adf94c 100644
--- a/src/runtime/proc.c
+++ b/src/runtime/proc.c
@@ -129,7 +129,7 @@ initdone(void)
}
void
-sys·Goexit(void)
+goexit(void)
{
if(debug > 1){
lock(&debuglock);
@@ -137,7 +137,7 @@ sys·Goexit(void)
unlock(&debuglock);
}
g->status = Gmoribund;
- sys·Gosched();
+ gosched();
}
void
@@ -431,7 +431,7 @@ scheduler(void)
case Gmoribund:
gp->status = Gdead;
if(--sched.gcount == 0)
- sys_Exit(0);
+ exit(0);
break;
}
if(gp->readyonstop){
@@ -461,7 +461,7 @@ scheduler(void)
// before running g again. If g->status is Gmoribund,
// kills off g.
void
-sys·Gosched(void)
+gosched(void)
{
if(g == m->g0)
throw("gosched of g0");
@@ -529,7 +529,7 @@ sys·exitsyscall(void)
// The scheduler will ready g and put this m to sleep.
// When the scheduler takes g awa from m,
// it will undo the sched.mcpu++ above.
- sys·Gosched();
+ gosched();
}
/*
@@ -784,7 +784,7 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
mcpy(sp, (byte*)&arg0, siz);
sp -= sizeof(uintptr);
- *(byte**)sp = (byte*)sys·Goexit;
+ *(byte**)sp = (byte*)goexit;
sp -= sizeof(uintptr); // retpc used by gogo
newg->sched.SP = sp;
@@ -839,3 +839,21 @@ sys·deferreturn(int32 arg0)
jmpdefer(sp);
}
+void
+runtime·Breakpoint(void)
+{
+ breakpoint();
+}
+
+void
+runtime·Goexit(void)
+{
+ goexit();
+}
+
+void
+runtime·Gosched(void)
+{
+ gosched();
+}
+
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c
index e05563bd6..afb9cce17 100644
--- a/src/runtime/runtime.c
+++ b/src/runtime/runtime.c
@@ -25,7 +25,7 @@ sys·panicl(int32 lno)
if(panicking) {
printf("double panic\n");
- sys_Exit(3);
+ exit(3);
}
panicking++;
@@ -35,8 +35,8 @@ sys·panicl(int32 lno)
traceback(sys·getcallerpc(&lno), sp, g);
tracebackothers(g);
}
- sys·Breakpoint(); // so we can grab it in a debugger
- sys_Exit(2);
+ breakpoint(); // so we can grab it in a debugger
+ exit(2);
}
void
@@ -57,7 +57,7 @@ throw(int8 *s)
printf("throw: %s\n", s);
sys·panicl(-1);
*(int32*)0 = 0; // not reached
- sys_Exit(1); // even more not reached
+ exit(1); // even more not reached
}
void
@@ -136,8 +136,8 @@ rnd(uint32 n, uint32 m)
static int32 argc;
static uint8** argv;
-Array sys·Args;
-Array sys·Envs;
+Array os·Args;
+Array os·Envs;
void
args(int32 c, uint8 **v)
@@ -161,15 +161,15 @@ goargs(void)
for(i=0; i<argc; i++)
gargv[i] = gostring(argv[i]);
- sys·Args.array = (byte*)gargv;
- sys·Args.nel = argc;
- sys·Args.cap = argc;
+ os·Args.array = (byte*)gargv;
+ os·Args.nel = argc;
+ os·Args.cap = argc;
for(i=0; i<envc; i++)
genvv[i] = gostring(argv[argc+1+i]);
- sys·Envs.array = (byte*)genvv;
- sys·Envs.nel = envc;
- sys·Envs.cap = envc;
+ os·Envs.array = (byte*)genvv;
+ os·Envs.nel = envc;
+ os·Envs.cap = envc;
}
byte*
@@ -182,8 +182,8 @@ getenv(int8 *s)
bs = (byte*)s;
len = findnull(bs);
- envv = (String*)sys·Envs.array;
- envc = sys·Envs.nel;
+ envv = (String*)os·Envs.array;
+ envc = os·Envs.nel;
for(i=0; i<envc; i++){
if(envv[i].len <= len)
continue;
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index 6b398c2bf..68d3748f3 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -329,6 +329,10 @@ uint32 noequal(uint32, void*, void*);
void* malloc(uintptr size);
void* mallocgc(uintptr size);
void free(void *v);
+void exit(int32);
+void breakpoint(void);
+void gosched(void);
+void goexit(void);
#pragma varargck argpos printf 1
@@ -378,15 +382,11 @@ void notewakeup(Note*);
* UTF-8 characters in identifiers.
*/
#ifndef __GNUC__
-#define sys_Exit sys·Exit
-#define sys_Gosched sys·Gosched
#define sys_memclr sys·memclr
#define sys_write sys·write
-#define sys_Breakpoint sys·Breakpoint
#define sys_catstring sys·catstring
#define sys_cmpstring sys·cmpstring
#define sys_getcallerpc sys·getcallerpc
-#define sys_Goexit sys·Goexit
#define sys_indexstring sys·indexstring
#define sys_intstring sys·intstring
#define sys_mal sys·mal
@@ -408,11 +408,7 @@ void notewakeup(Note*);
/*
* low level go-called
*/
-void sys_Goexit(void);
-void sys_Gosched(void);
-void sys_Exit(int32);
void sys_write(int32, void*, int32);
-void sys_Breakpoint(void);
uint8* sys_mmap(byte*, uint32, int32, int32, int32, uint32);
void sys_memclr(byte*, uint32);
void sys_setcallerpc(void*, void*);
diff --git a/src/runtime/sema.c b/src/runtime/sema.c
index cad08d167..5e5b07aa6 100644
--- a/src/runtime/sema.c
+++ b/src/runtime/sema.c
@@ -119,7 +119,7 @@ semsleep2(Sema *s)
{
USED(s);
g->status = Gwaiting;
- sys·Gosched();
+ gosched();
}
static int32
diff --git a/src/runtime/string.c b/src/runtime/string.c
index 667828d66..5e4922a99 100644
--- a/src/runtime/string.c
+++ b/src/runtime/string.c
@@ -215,8 +215,6 @@ out:
void
sys·stringiter2(String s, int32 k, int32 retk, int32 retv)
{
- int32 l;
-
if(k >= s.len) {
// retk=0 is end of iteration
retk = 0;