Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
918afd94
Commit
918afd94
authored
May 08, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move things out of sys into os and runtime
R=r OCL=28569 CL=28573
parent
c367d1b7
Changes
70
Show whitespace changes
Inline
Side-by-side
Showing
70 changed files
with
243 additions
and
174 deletions
+243
-174
doc/progs/cat.go
doc/progs/cat.go
+2
-2
doc/progs/cat_rot13.go
doc/progs/cat_rot13.go
+2
-2
doc/progs/helloworld3.go
doc/progs/helloworld3.go
+2
-1
doc/progs/strings.go
doc/progs/strings.go
+2
-1
src/cmd/gc/Makefile
src/cmd/gc/Makefile
+1
-1
src/cmd/gc/builtin.c.boot
src/cmd/gc/builtin.c.boot
+8
-7
src/cmd/gc/go.h
src/cmd/gc/go.h
+1
-0
src/cmd/gc/lex.c
src/cmd/gc/lex.c
+4
-0
src/cmd/gc/mkbuiltin
src/cmd/gc/mkbuiltin
+5
-4
src/cmd/gc/runtime.go
src/cmd/gc/runtime.go
+9
-0
src/cmd/gc/sys.go
src/cmd/gc/sys.go
+0
-14
src/cmd/gobuild/gobuild.go
src/cmd/gobuild/gobuild.go
+1
-1
src/cmd/gobuild/util.go
src/cmd/gobuild/util.go
+1
-1
src/lib/flag/flag.go
src/lib/flag/flag.go
+12
-12
src/lib/http/triv.go
src/lib/http/triv.go
+1
-1
src/lib/log/log.go
src/lib/log/log.go
+5
-4
src/lib/os/Makefile
src/lib/os/Makefile
+3
-2
src/lib/os/env.go
src/lib/os/env.go
+1
-1
src/lib/os/file.go
src/lib/os/file.go
+1
-1
src/lib/regexp/regexp.go
src/lib/regexp/regexp.go
+2
-1
src/lib/template/template.go
src/lib/template/template.go
+3
-2
src/lib/testing/testing.go
src/lib/testing/testing.go
+4
-2
src/runtime/386/asm.s
src/runtime/386/asm.s
+2
-2
src/runtime/386/traceback.c
src/runtime/386/traceback.c
+1
-1
src/runtime/amd64/asm.s
src/runtime/amd64/asm.s
+2
-2
src/runtime/amd64/traceback.c
src/runtime/amd64/traceback.c
+1
-1
src/runtime/chan.c
src/runtime/chan.c
+5
-5
src/runtime/darwin/386/signal.c
src/runtime/darwin/386/signal.c
+3
-3
src/runtime/darwin/386/sys.s
src/runtime/darwin/386/sys.s
+1
-1
src/runtime/darwin/amd64/signal.c
src/runtime/darwin/amd64/signal.c
+3
-3
src/runtime/darwin/amd64/sys.s
src/runtime/darwin/amd64/sys.s
+1
-1
src/runtime/linux/386/signal.c
src/runtime/linux/386/signal.c
+3
-3
src/runtime/linux/386/sys.s
src/runtime/linux/386/sys.s
+1
-1
src/runtime/linux/amd64/signal.c
src/runtime/linux/amd64/signal.c
+3
-3
src/runtime/linux/amd64/sys.s
src/runtime/linux/amd64/sys.s
+1
-1
src/runtime/proc.c
src/runtime/proc.c
+24
-6
src/runtime/runtime.c
src/runtime/runtime.c
+14
-14
src/runtime/runtime.h
src/runtime/runtime.h
+4
-8
src/runtime/sema.c
src/runtime/sema.c
+1
-1
src/runtime/string.c
src/runtime/string.c
+0
-2
test/235.go
test/235.go
+3
-1
test/args.go
test/args.go
+5
-3
test/chan/fifo.go
test/chan/fifo.go
+3
-1
test/chan/goroutines.go
test/chan/goroutines.go
+3
-3
test/chan/nonblock.go
test/chan/nonblock.go
+4
-3
test/chan/powser1.go
test/chan/powser1.go
+3
-1
test/chan/powser2.go
test/chan/powser2.go
+3
-1
test/chan/sieve.go
test/chan/sieve.go
+3
-1
test/char_lit.go
test/char_lit.go
+4
-2
test/env.go
test/env.go
+3
-3
test/fixedbugs/bug006.go
test/fixedbugs/bug006.go
+3
-1
test/fixedbugs/bug059.go
test/fixedbugs/bug059.go
+3
-1
test/fixedbugs/bug060.go
test/fixedbugs/bug060.go
+3
-1
test/fixedbugs/bug120.go
test/fixedbugs/bug120.go
+2
-1
test/fixedbugs/bug130.go
test/fixedbugs/bug130.go
+3
-1
test/fixedbugs/bug141.go
test/fixedbugs/bug141.go
+3
-1
test/if1.go
test/if1.go
+3
-1
test/int_lit.go
test/int_lit.go
+3
-1
test/interface10.go
test/interface10.go
+3
-1
test/interface4.go
test/interface4.go
+3
-1
test/interface6.go
test/interface6.go
+3
-1
test/ken/chan.go
test/ken/chan.go
+9
-7
test/ken/chan1.go
test/ken/chan1.go
+5
-3
test/string_lit.go
test/string_lit.go
+3
-1
test/stringrange.go
test/stringrange.go
+2
-1
test/switch1.go
test/switch1.go
+4
-2
test/typeswitch.go
test/typeswitch.go
+3
-1
usr/gri/pretty/godoc.go
usr/gri/pretty/godoc.go
+4
-4
usr/gri/pretty/pretty.go
usr/gri/pretty/pretty.go
+6
-6
usr/gri/pretty/untab.go
usr/gri/pretty/untab.go
+1
-1
No files found.
doc/progs/cat.go
View file @
918afd94
...
@@ -18,7 +18,7 @@ func cat(f *file.File) {
...
@@ -18,7 +18,7 @@ func cat(f *file.File) {
switch
nr
,
er
:=
f
.
Read
(
&
buf
);
true
{
switch
nr
,
er
:=
f
.
Read
(
&
buf
);
true
{
case
nr
<
0
:
case
nr
<
0
:
fmt
.
Fprintf
(
os
.
Stderr
,
"error reading from %s: %s
\n
"
,
f
.
String
(),
er
.
String
());
fmt
.
Fprintf
(
os
.
Stderr
,
"error reading from %s: %s
\n
"
,
f
.
String
(),
er
.
String
());
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
case
nr
==
0
:
// EOF
case
nr
==
0
:
// EOF
return
;
return
;
case
nr
>
0
:
case
nr
>
0
:
...
@@ -38,7 +38,7 @@ func main() {
...
@@ -38,7 +38,7 @@ func main() {
f
,
err
:=
file
.
Open
(
flag
.
Arg
(
i
),
0
,
0
);
f
,
err
:=
file
.
Open
(
flag
.
Arg
(
i
),
0
,
0
);
if
f
==
nil
{
if
f
==
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"can't open %s: error %s
\n
"
,
flag
.
Arg
(
i
),
err
);
fmt
.
Fprintf
(
os
.
Stderr
,
"can't open %s: error %s
\n
"
,
flag
.
Arg
(
i
),
err
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
cat
(
f
);
cat
(
f
);
f
.
Close
();
f
.
Close
();
...
...
doc/progs/cat_rot13.go
View file @
918afd94
...
@@ -60,7 +60,7 @@ func cat(r reader) {
...
@@ -60,7 +60,7 @@ func cat(r reader) {
switch
nr
,
er
:=
r
.
Read
(
&
buf
);
{
switch
nr
,
er
:=
r
.
Read
(
&
buf
);
{
case
nr
<
0
:
case
nr
<
0
:
fmt
.
Fprintf
(
os
.
Stderr
,
"error reading from %s: %s
\n
"
,
r
.
String
(),
er
.
String
());
fmt
.
Fprintf
(
os
.
Stderr
,
"error reading from %s: %s
\n
"
,
r
.
String
(),
er
.
String
());
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
case
nr
==
0
:
// EOF
case
nr
==
0
:
// EOF
return
;
return
;
case
nr
>
0
:
case
nr
>
0
:
...
@@ -81,7 +81,7 @@ func main() {
...
@@ -81,7 +81,7 @@ func main() {
f
,
err
:=
file
.
Open
(
flag
.
Arg
(
i
),
0
,
0
);
f
,
err
:=
file
.
Open
(
flag
.
Arg
(
i
),
0
,
0
);
if
f
==
nil
{
if
f
==
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"can't open %s: error %s
\n
"
,
flag
.
Arg
(
i
),
err
);
fmt
.
Fprintf
(
os
.
Stderr
,
"can't open %s: error %s
\n
"
,
flag
.
Arg
(
i
),
err
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
cat
(
f
);
cat
(
f
);
f
.
Close
();
f
.
Close
();
...
...
doc/progs/helloworld3.go
View file @
918afd94
...
@@ -7,6 +7,7 @@ package main
...
@@ -7,6 +7,7 @@ package main
import
(
import
(
"file"
;
"file"
;
"fmt"
;
"fmt"
;
"os"
;
)
)
func
main
()
{
func
main
()
{
...
@@ -15,6 +16,6 @@ func main() {
...
@@ -15,6 +16,6 @@ func main() {
file
,
err
:=
file
.
Open
(
"/does/not/exist"
,
0
,
0
);
file
,
err
:=
file
.
Open
(
"/does/not/exist"
,
0
,
0
);
if
file
==
nil
{
if
file
==
nil
{
fmt
.
Printf
(
"can't open file; err=%s
\n
"
,
err
.
String
());
fmt
.
Printf
(
"can't open file; err=%s
\n
"
,
err
.
String
());
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
doc/progs/strings.go
View file @
918afd94
...
@@ -5,10 +5,11 @@
...
@@ -5,10 +5,11 @@
package
main
package
main
import
"fmt"
import
"fmt"
import
"os"
func
main
()
{
func
main
()
{
s
:=
"hello"
;
s
:=
"hello"
;
if
s
[
1
]
!=
'e'
{
sy
s
.
Exit
(
1
)
}
if
s
[
1
]
!=
'e'
{
o
s
.
Exit
(
1
)
}
s
=
"good bye"
;
s
=
"good bye"
;
var
p
*
string
=
&
s
;
var
p
*
string
=
&
s
;
*
p
=
"ciao"
;
*
p
=
"ciao"
;
...
...
src/cmd/gc/Makefile
View file @
918afd94
...
@@ -44,7 +44,7 @@ y.tab.h: $(YFILES)
...
@@ -44,7 +44,7 @@ y.tab.h: $(YFILES)
y.tab.c
:
y.tab.h
y.tab.c
:
y.tab.h
test
-f
y.tab.c
&&
touch
y.tab.c
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
||
\
./mkbuiltin
>
builtin.c
||
\
(
echo
'mkbuiltin failed; using bootstrap copy of builtin.c'
;
cp
builtin.c.boot builtin.c
)
(
echo
'mkbuiltin failed; using bootstrap copy of builtin.c'
;
cp
builtin.c.boot builtin.c
)
...
...
src/cmd/gc/builtin.c.boot
View file @
918afd94
...
@@ -55,13 +55,6 @@ char *sysimport =
...
@@ -55,13 +55,6 @@ char *sysimport =
"func sys.arrayslices (old *any, nel int, lb int, hb int, width int) (ary []any)\n"
"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.arrays2d (old *any, nel int) (ary []any)\n"
"func sys.closure ()\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"
"$$\n";
"$$\n";
char *unsafeimport =
char *unsafeimport =
...
@@ -74,3 +67,11 @@ char *unsafeimport =
...
@@ -74,3 +67,11 @@ char *unsafeimport =
"func unsafe.Unreflect (? uint64, ? string, ? bool) (ret interface { })\n"
"func unsafe.Unreflect (? uint64, ? string, ? bool) (ret interface { })\n"
"\n"
"\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";
src/cmd/gc/go.h
View file @
918afd94
...
@@ -541,6 +541,7 @@ EXTERN Sym* pkgimportname; // package name from imported package
...
@@ -541,6 +541,7 @@ EXTERN Sym* pkgimportname; // package name from imported package
EXTERN
int
tptr
;
// either TPTR32 or TPTR64
EXTERN
int
tptr
;
// either TPTR32 or TPTR64
extern
char
*
sysimport
;
extern
char
*
sysimport
;
extern
char
*
unsafeimport
;
extern
char
*
unsafeimport
;
extern
char
*
runtimeimport
;
EXTERN
char
*
filename
;
// name to uniqify names
EXTERN
char
*
filename
;
// name to uniqify names
EXTERN
Idir
*
idirs
;
EXTERN
Idir
*
idirs
;
...
...
src/cmd/gc/lex.c
View file @
918afd94
...
@@ -265,6 +265,10 @@ importfile(Val *f)
...
@@ -265,6 +265,10 @@ importfile(Val *f)
cannedimports
(
"unsafe.6"
,
unsafeimport
);
cannedimports
(
"unsafe.6"
,
unsafeimport
);
return
;
return
;
}
}
if
(
strcmp
(
f
->
u
.
sval
->
s
,
"runtime"
)
==
0
)
{
cannedimports
(
"runtime.6"
,
runtimeimport
);
return
;
}
if
(
!
findpkg
(
f
->
u
.
sval
))
if
(
!
findpkg
(
f
->
u
.
sval
))
fatal
(
"can't find import: %Z"
,
f
->
u
.
sval
);
fatal
(
"can't find import: %Z"
,
f
->
u
.
sval
);
...
...
src/cmd/gc/mkbuiltin
View file @
918afd94
...
@@ -5,11 +5,12 @@
...
@@ -5,11 +5,12 @@
set
-e
set
-e
gcc
-o
mkbuiltin1 mkbuiltin1.c
gcc
-o
mkbuiltin1 mkbuiltin1.c
6g sys.go
6g unsafe.go
rm
-f
_builtin.c
rm
-f
_builtin.c
./mkbuiltin1 sys
>
_builtin.c
for
i
in
sys unsafe runtime
./mkbuiltin1 unsafe
>>
_builtin.c
do
6g
$i
.go
./mkbuiltin1
$i
>>
_builtin.c
done
# If _builtin.c has changed vs builtin.c.boot,
# If _builtin.c has changed vs builtin.c.boot,
# check in the new change if being run by
# check in the new change if being run by
...
...
src/cmd/gc/runtime.go
0 → 100644
View file @
918afd94
// 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
);
src/cmd/gc/sys.go
View file @
918afd94
...
@@ -72,17 +72,3 @@ func arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any);
...
@@ -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
arrays2d
(
old
*
any
,
nel
int
)
(
ary
[]
any
);
func
closure
();
// has args, but compiler fills in
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
);
src/cmd/gobuild/gobuild.go
View file @
918afd94
...
@@ -131,7 +131,7 @@ func ScanFiles(filenames []string) *Info {
...
@@ -131,7 +131,7 @@ func ScanFiles(filenames []string) *Info {
// TODO(rsc): Build a binary from package main?
// TODO(rsc): Build a binary from package main?
z
:=
new
(
Info
);
z
:=
new
(
Info
);
z
.
Args
=
sy
s
.
Args
;
z
.
Args
=
o
s
.
Args
;
z
.
Dir
=
PkgDir
();
z
.
Dir
=
PkgDir
();
z
.
Char
=
theChar
;
// for template
z
.
Char
=
theChar
;
// for template
z
.
ObjDir
=
ObjDir
;
// for template
z
.
ObjDir
=
ObjDir
;
// for template
...
...
src/cmd/gobuild/util.go
View file @
918afd94
...
@@ -34,7 +34,7 @@ const ObjDir = "_obj"
...
@@ -34,7 +34,7 @@ const ObjDir = "_obj"
func
fatal
(
args
...
)
{
func
fatal
(
args
...
)
{
fmt
.
Fprintf
(
os
.
Stderr
,
"gobuild: %s
\n
"
,
fmt
.
Sprint
(
args
));
fmt
.
Fprintf
(
os
.
Stderr
,
"gobuild: %s
\n
"
,
fmt
.
Sprint
(
args
));
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
func
init
()
{
func
init
()
{
...
...
src/lib/flag/flag.go
View file @
918afd94
...
@@ -261,15 +261,15 @@ func PrintDefaults() {
...
@@ -261,15 +261,15 @@ func PrintDefaults() {
}
}
// Usage prints to standard error a default usage message documenting all defined flags and
// Usage prints to standard error a default usage message documenting all defined flags and
// then calls
sy
s.Exit(1).
// then calls
o
s.Exit(1).
func
Usage
()
{
func
Usage
()
{
if
len
(
sy
s
.
Args
)
>
0
{
if
len
(
o
s
.
Args
)
>
0
{
fmt
.
Fprintln
(
os
.
Stderr
,
"Usage of"
,
sy
s
.
Args
[
0
]
+
":"
);
fmt
.
Fprintln
(
os
.
Stderr
,
"Usage of"
,
o
s
.
Args
[
0
]
+
":"
);
}
else
{
}
else
{
fmt
.
Fprintln
(
os
.
Stderr
,
"Usage:"
);
fmt
.
Fprintln
(
os
.
Stderr
,
"Usage:"
);
}
}
PrintDefaults
();
PrintDefaults
();
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
func
NFlag
()
int
{
func
NFlag
()
int
{
...
@@ -280,20 +280,20 @@ func NFlag() int {
...
@@ -280,20 +280,20 @@ func NFlag() int {
// after flags have been processed.
// after flags have been processed.
func
Arg
(
i
int
)
string
{
func
Arg
(
i
int
)
string
{
i
+=
flags
.
first_arg
;
i
+=
flags
.
first_arg
;
if
i
<
0
||
i
>=
len
(
sy
s
.
Args
)
{
if
i
<
0
||
i
>=
len
(
o
s
.
Args
)
{
return
""
;
return
""
;
}
}
return
sy
s
.
Args
[
i
]
return
o
s
.
Args
[
i
]
}
}
// NArg is the number of arguments remaining after flags have been processed.
// NArg is the number of arguments remaining after flags have been processed.
func
NArg
()
int
{
func
NArg
()
int
{
return
len
(
sy
s
.
Args
)
-
flags
.
first_arg
return
len
(
o
s
.
Args
)
-
flags
.
first_arg
}
}
// Args returns the non-flag command-line arguments.
// Args returns the non-flag command-line arguments.
func
Args
()
[]
string
{
func
Args
()
[]
string
{
return
sys
.
Args
[
flags
.
first_arg
:
len
(
sy
s
.
Args
)];
return
os
.
Args
[
flags
.
first_arg
:
len
(
o
s
.
Args
)];
}
}
func
add
(
name
string
,
value
FlagValue
,
usage
string
)
{
func
add
(
name
string
,
value
FlagValue
,
usage
string
)
{
...
@@ -393,7 +393,7 @@ func String(name, value string, usage string) *string {
...
@@ -393,7 +393,7 @@ func String(name, value string, usage string) *string {
func
(
f
*
allFlags
)
parseOne
(
index
int
)
(
ok
bool
,
next
int
)
func
(
f
*
allFlags
)
parseOne
(
index
int
)
(
ok
bool
,
next
int
)
{
{
s
:=
sy
s
.
Args
[
index
];
s
:=
o
s
.
Args
[
index
];
f
.
first_arg
=
index
;
// until proven otherwise
f
.
first_arg
=
index
;
// until proven otherwise
if
len
(
s
)
==
0
{
if
len
(
s
)
==
0
{
return
false
,
-
1
return
false
,
-
1
...
@@ -450,11 +450,11 @@ func (f *allFlags) parseOne(index int) (ok bool, next int)
...
@@ -450,11 +450,11 @@ func (f *allFlags) parseOne(index int) (ok bool, next int)
}
}
}
else
{
}
else
{
// It must have a value, which might be the next argument.
// It must have a value, which might be the next argument.
if
!
has_value
&&
index
<
len
(
sy
s
.
Args
)
-
1
{
if
!
has_value
&&
index
<
len
(
o
s
.
Args
)
-
1
{
// value is the next arg
// value is the next arg
has_value
=
true
;
has_value
=
true
;
index
++
;
index
++
;
value
=
sy
s
.
Args
[
index
];
value
=
o
s
.
Args
[
index
];
}
}
if
!
has_value
{
if
!
has_value
{
print
(
"flag needs an argument: -"
,
name
,
"
\n
"
);
print
(
"flag needs an argument: -"
,
name
,
"
\n
"
);
...
@@ -473,7 +473,7 @@ func (f *allFlags) parseOne(index int) (ok bool, next int)
...
@@ -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
// Parse parses the command-line flags. Must be called after all flags are defined
// and before any are accessed by the program.
// and before any are accessed by the program.
func
Parse
()
{
func
Parse
()
{
for
i
:=
1
;
i
<
len
(
sy
s
.
Args
);
{
for
i
:=
1
;
i
<
len
(
o
s
.
Args
);
{
ok
,
next
:=
flags
.
parseOne
(
i
);
ok
,
next
:=
flags
.
parseOne
(
i
);
if
next
>
0
{
if
next
>
0
{
flags
.
first_arg
=
next
;
flags
.
first_arg
=
next
;
...
...
src/lib/http/triv.go
View file @
918afd94
...
@@ -74,7 +74,7 @@ func FlagServer(c *http.Conn, req *http.Request) {
...
@@ -74,7 +74,7 @@ func FlagServer(c *http.Conn, req *http.Request) {
// simple argument server
// simple argument server
func
ArgServer
(
c
*
http
.
Conn
,
req
*
http
.
Request
)
{
func
ArgServer
(
c
*
http
.
Conn
,
req
*
http
.
Request
)
{
for
i
,
s
:=
range
sy
s
.
Args
{
for
i
,
s
:=
range
o
s
.
Args
{
fmt
.
Fprint
(
c
,
s
,
" "
);
fmt
.
Fprint
(
c
,
s
,
" "
);
}
}
}
}
...
...
src/lib/log/log.go
View file @
918afd94
...
@@ -14,6 +14,7 @@ package log
...
@@ -14,6 +14,7 @@ package log
import
(
import
(
"fmt"
;
"fmt"
;
"io"
;
"io"
;
"runtime"
;
"os"
;
"os"
;
"time"
;
"time"
;
)
)
...
@@ -96,7 +97,7 @@ func (l *Logger) formatHeader(ns int64, calldepth int) string {
...
@@ -96,7 +97,7 @@ func (l *Logger) formatHeader(ns int64, calldepth int) string {
}
}
}
}
if
l
.
flag
&
(
Lshortfile
|
Llongfile
)
!=
0
{
if
l
.
flag
&
(
Lshortfile
|
Llongfile
)
!=
0
{
pc
,
file
,
line
,
ok
:=
sys
.
Caller
(
calldepth
);
pc
,
file
,
line
,
ok
:=
runtime
.
Caller
(
calldepth
);
if
ok
{
if
ok
{
if
l
.
flag
&
Lshortfile
!=
0
{
if
l
.
flag
&
Lshortfile
!=
0
{
short
,
ok
:=
shortnames
[
file
];
short
,
ok
:=
shortnames
[
file
];
...
@@ -139,7 +140,7 @@ func (l *Logger) Output(calldepth int, s string) {
...
@@ -139,7 +140,7 @@ func (l *Logger) Output(calldepth int, s string) {
case
Lcrash
:
case
Lcrash
:
panic
(
"log: fatal error"
);
panic
(
"log: fatal error"
);
case
Lexit
:
case
Lexit
:
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
...
@@ -173,12 +174,12 @@ func Stderrf(format string, v ...) {
...
@@ -173,12 +174,12 @@ func Stderrf(format string, v ...) {
stderr
.
Output
(
2
,
fmt
.
Sprintf
(
format
,
v
))
stderr
.
Output
(
2
,
fmt
.
Sprintf
(
format
,
v
))
}
}
// Exit is equivalent to Stderr() followed by a call to
sy
s.Exit(1).
// Exit is equivalent to Stderr() followed by a call to
o
s.Exit(1).
func
Exit
(
v
...
)
{
func
Exit
(
v
...
)
{
exit
.
Output
(
2
,
fmt
.
Sprintln
(
v
))
exit
.
Output
(
2
,
fmt
.
Sprintln
(
v
))
}
}
// Exitf is equivalent to Stderrf() followed by a call to
sy
s.Exit(1).
// Exitf is equivalent to Stderrf() followed by a call to
o
s.Exit(1).
func
Exitf
(
format
string
,
v
...
)
{
func
Exitf
(
format
string
,
v
...
)
{
exit
.
Output
(
2
,
fmt
.
Sprintf
(
format
,
v
))
exit
.
Output
(
2
,
fmt
.
Sprintf
(
format
,
v
))
}
}
...
...
src/lib/os/Makefile
View file @
918afd94
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
# license that can be found in the LICENSE file.
# license that can be found in the LICENSE file.
# DO NOT EDIT. Automatically generated by gobuild.
# 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
=
D
=
...
@@ -41,6 +41,7 @@ coverage: packages
...
@@ -41,6 +41,7 @@ coverage: packages
O1
=
\
O1
=
\
error.
$O
\
error.
$O
\
proc.
$O
\
types.
$O
\
types.
$O
\
O2
=
\
O2
=
\
...
@@ -60,7 +61,7 @@ phases: a1 a2 a3 a4
...
@@ -60,7 +61,7 @@ phases: a1 a2 a3 a4
_obj$D/os.a
:
phases
_obj$D/os.a
:
phases
a1
:
$(O1)
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)
rm
-f
$(O1)
a2
:
$(O2)
a2
:
$(O2)
...
...
src/lib/os/env.go
View file @
918afd94
...
@@ -19,7 +19,7 @@ var env map[string] string;
...
@@ -19,7 +19,7 @@ var env map[string] string;
func
copyenv
()
{
func
copyenv
()
{
env
=
make
(
map
[
string
]
string
);
env
=
make
(
map
[
string
]
string
);
for
i
,
s
:=
range
sy
s
.
Envs
{
for
i
,
s
:=
range
o
s
.
Envs
{
for
j
:=
0
;
j
<
len
(
s
);
j
++
{
for
j
:=
0
;
j
<
len
(
s
);
j
++
{
if
s
[
j
]
==
'='
{
if
s
[
j
]
==
'='
{
env
[
s
[
0
:
j
]]
=
s
[
j
+
1
:
len
(
s
)];
env
[
s
[
0
:
j
]]
=
s
[
j
+
1
:
len
(
s
)];
...
...
src/lib/os/file.go
View file @
918afd94
...
@@ -132,7 +132,7 @@ func (file *File) Write(b []byte) (ret int, err Error) {
...
@@ -132,7 +132,7 @@ func (file *File) Write(b []byte) (ret int, err Error) {
if
e
==
syscall
.
EPIPE
{
if
e
==
syscall
.
EPIPE
{
file
.
nepipe
++
;
file
.
nepipe
++
;
if
file
.
nepipe
>=
10
{
if
file
.
nepipe
>=
10
{
sy
s
.
Exit
(
syscall
.
EPIPE
);
o
s
.
Exit
(
syscall
.
EPIPE
);
}
}
}
else
{
}
else
{
file
.
nepipe
=
0
;
file
.
nepipe
=
0
;
...
...
src/lib/regexp/regexp.go
View file @
918afd94
...
@@ -25,6 +25,7 @@ package regexp
...
@@ -25,6 +25,7 @@ package regexp
import
(
import
(
"container/vector"
;
"container/vector"
;
"os"
;
"os"
;
"runtime"
;
"utf8"
;
"utf8"
;
)
)
...
@@ -236,7 +237,7 @@ func (nop *_Nop) print() { print("nop") }
...
@@ -236,7 +237,7 @@ func (nop *_Nop) print() { print("nop") }
func
(
re
*
Regexp
)
setError
(
err
os
.
Error
)
{
func
(
re
*
Regexp
)
setError
(
err
os
.
Error
)
{
re
.
error
=
err
;
re
.
error
=
err
;
re
.
ch
<-
re
;
re
.
ch
<-
re
;
sys
.
Goexit
();
runtime
.
Goexit
();
}
}
func
(
re
*
Regexp
)
add
(
i
instr
)
instr
{
func
(
re
*
Regexp
)
add
(
i
instr
)
instr
{
...
...
src/lib/template/template.go
View file @
918afd94
...
@@ -61,6 +61,7 @@ import (
...
@@ -61,6 +61,7 @@ import (
"io"
;
"io"
;
"os"
;
"os"
;
"reflect"
;
"reflect"
;
"runtime"
;
"strings"
;
"strings"
;
"template"
;
"template"
;
"container/vector"
;
"container/vector"
;
...
@@ -181,7 +182,7 @@ func New(fmap FormatterMap) *Template {
...
@@ -181,7 +182,7 @@ func New(fmap FormatterMap) *Template {
// Generic error handler, called only from execError or parseError.
// Generic error handler, called only from execError or parseError.
func
error
(
errors
chan
os
.
Error
,
line
int
,
err
string
,
args
...
)
{
func
error
(
errors
chan
os
.
Error
,
line
int
,
err
string
,
args
...
)
{
errors
<-
ParseError
{
fmt
.
Sprintf
(
"line %d: %s"
,
line
,
fmt
.
Sprintf
(
err
,
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.
// Report error and stop executing. The line number must be provided explicitly.
...
...
src/lib/testing/testing.go
View file @
918afd94
...
@@ -14,6 +14,8 @@ package testing
...
@@ -14,6 +14,8 @@ package testing
import
(
import
(
"flag"
;
"flag"
;
"fmt"
;
"fmt"
;
"os"
;
"runtime"
;
)
)
// Report as tests are run; default is silent for success.
// Report as tests are run; default is silent for success.
...
@@ -47,7 +49,7 @@ func (t *T) Fail() {
...
@@ -47,7 +49,7 @@ func (t *T) Fail() {
func
(
t
*
T
)
FailNow
()
{
func
(
t
*
T
)
FailNow
()
{
t
.
Fail
();
t
.
Fail
();
t
.
ch
<-
t
;
t
.
ch
<-
t
;
sys
.
Goexit
();
runtime
.
Goexit
();
}
}
// Log formats its arguments using default formatting, analogous to Print(),
// Log formats its arguments using default formatting, analogous to Print(),
...
@@ -129,7 +131,7 @@ func Main(tests []Test) {
...
@@ -129,7 +131,7 @@ func Main(tests []Test) {
}
}
if
!
ok
{
if
!
ok
{
println
(
"FAIL"
);
println
(
"FAIL"
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
println
(
"PASS"
);
println
(
"PASS"
);
}
}
src/runtime/386/asm.s
View file @
918afd94
...
@@ -84,12 +84,12 @@ TEXT mainstart(SB),7,$0
...
@@ -84,12 +84,12 @@ TEXT mainstart(SB),7,$0
CALL
initdone
(
SB
)
CALL
initdone
(
SB
)
CALL
main
·
main
(
SB
)
CALL
main
·
main
(
SB
)
PUSHL
$
0
PUSHL
$
0
CALL
sys
·
E
xit
(
SB
)
CALL
e
xit
(
SB
)
POPL
AX
POPL
AX
INT
$
3
INT
$
3
RET
RET
TEXT
sys
·
B
reakpoint
(
SB
),7,$0
TEXT
b
reakpoint
(
SB
),7,$0
BYTE
$
0xcc
BYTE
$
0xcc
RET
RET
...
...
src/runtime/386/traceback.c
View file @
918afd94
...
@@ -82,7 +82,7 @@ traceback(byte *pc0, byte *sp, G *g)
...
@@ -82,7 +82,7 @@ traceback(byte *pc0, byte *sp, G *g)
// func caller(n int) (pc uint64, file string, line int, ok bool)
// func caller(n int) (pc uint64, file string, line int, ok bool)
void
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
;
uint64
pc
;
byte
*
sp
;
byte
*
sp
;
...
...
src/runtime/amd64/asm.s
View file @
918afd94
...
@@ -55,12 +55,12 @@ TEXT mainstart(SB),7,$0
...
@@ -55,12 +55,12 @@ TEXT mainstart(SB),7,$0
CALL
initdone
(
SB
)
CALL
initdone
(
SB
)
CALL
main
·
main
(
SB
)
CALL
main
·
main
(
SB
)
PUSHQ
$
0
PUSHQ
$
0
CALL
sys
·
E
xit
(
SB
)
CALL
e
xit
(
SB
)
POPQ
AX
POPQ
AX
CALL
notok
(
SB
)
CALL
notok
(
SB
)
RET
RET
TEXT
sys
·
B
reakpoint
(
SB
),7,$0
TEXT
b
reakpoint
(
SB
),7,$0
BYTE
$
0xcc
BYTE
$
0xcc
RET
RET
...
...
src/runtime/amd64/traceback.c
View file @
918afd94
...
@@ -79,7 +79,7 @@ traceback(byte *pc0, byte *sp, G *g)
...
@@ -79,7 +79,7 @@ traceback(byte *pc0, byte *sp, G *g)
// func caller(n int) (pc uint64, file string, line int, ok bool)
// func caller(n int) (pc uint64, file string, line int, ok bool)
void
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
;
uint64
pc
;
byte
*
sp
;
byte
*
sp
;
...
...
src/runtime/chan.c
View file @
918afd94
...
@@ -211,7 +211,7 @@ loop:
...
@@ -211,7 +211,7 @@ loop:
g
->
status
=
Gwaiting
;
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
sendq
,
sg
);
enqueue
(
&
c
->
sendq
,
sg
);
unlock
(
&
chanlock
);
unlock
(
&
chanlock
);
sys
·
G
osched
();
g
osched
();
lock
(
&
chanlock
);
lock
(
&
chanlock
);
sg
=
g
->
param
;
sg
=
g
->
param
;
...
@@ -237,7 +237,7 @@ asynch:
...
@@ -237,7 +237,7 @@ asynch:
g
->
status
=
Gwaiting
;
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
sendq
,
sg
);
enqueue
(
&
c
->
sendq
,
sg
);
unlock
(
&
chanlock
);
unlock
(
&
chanlock
);
sys
·
G
osched
();
g
osched
();
lock
(
&
chanlock
);
lock
(
&
chanlock
);
goto
asynch
;
goto
asynch
;
...
@@ -311,7 +311,7 @@ loop:
...
@@ -311,7 +311,7 @@ loop:
g
->
status
=
Gwaiting
;
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
recvq
,
sg
);
enqueue
(
&
c
->
recvq
,
sg
);
unlock
(
&
chanlock
);
unlock
(
&
chanlock
);
sys
·
G
osched
();
g
osched
();
lock
(
&
chanlock
);
lock
(
&
chanlock
);
sg
=
g
->
param
;
sg
=
g
->
param
;
...
@@ -339,7 +339,7 @@ asynch:
...
@@ -339,7 +339,7 @@ asynch:
g
->
status
=
Gwaiting
;
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
recvq
,
sg
);
enqueue
(
&
c
->
recvq
,
sg
);
unlock
(
&
chanlock
);
unlock
(
&
chanlock
);
sys
·
G
osched
();
g
osched
();
lock
(
&
chanlock
);
lock
(
&
chanlock
);
goto
asynch
;
goto
asynch
;
...
@@ -748,7 +748,7 @@ loop:
...
@@ -748,7 +748,7 @@ loop:
g
->
param
=
nil
;
g
->
param
=
nil
;
g
->
status
=
Gwaiting
;
g
->
status
=
Gwaiting
;
unlock
(
&
chanlock
);
unlock
(
&
chanlock
);
sys
·
G
osched
();
g
osched
();
lock
(
&
chanlock
);
lock
(
&
chanlock
);
sg
=
g
->
param
;
sg
=
g
->
param
;
...
...
src/runtime/darwin/386/signal.c
View file @
918afd94
...
@@ -33,7 +33,7 @@ sighandler(int32 sig, Siginfo *info, void *context)
...
@@ -33,7 +33,7 @@ sighandler(int32 sig, Siginfo *info, void *context)
Regs
*
r
;
Regs
*
r
;
if
(
panicking
)
// traceback already printed
if
(
panicking
)
// traceback already printed
sys_E
xit
(
2
);
e
xit
(
2
);
panicking
=
1
;
panicking
=
1
;
if
(
sig
<
0
||
sig
>=
NSIG
){
if
(
sig
<
0
||
sig
>=
NSIG
){
...
@@ -56,8 +56,8 @@ sighandler(int32 sig, Siginfo *info, void *context)
...
@@ -56,8 +56,8 @@ sighandler(int32 sig, Siginfo *info, void *context)
dumpregs
(
r
);
dumpregs
(
r
);
}
}
sys
·
B
reakpoint
();
b
reakpoint
();
sys_E
xit
(
2
);
e
xit
(
2
);
}
}
void
void
...
...
src/runtime/darwin/386/sys.s
View file @
918afd94
...
@@ -11,7 +11,7 @@ TEXT notok(SB),7,$0
...
@@ -11,7 +11,7 @@ TEXT notok(SB),7,$0
RET
RET
//
Exit
the
entire
program
(
like
C
exit
)
//
Exit
the
entire
program
(
like
C
exit
)
TEXT
sys
·
E
xit
(
SB
),7,$0
TEXT
e
xit
(
SB
),7,$0
MOVL
$
1
,
AX
MOVL
$
1
,
AX
INT
$
0x80
INT
$
0x80
CALL
notok
(
SB
)
CALL
notok
(
SB
)
...
...
src/runtime/darwin/amd64/signal.c
View file @
918afd94
...
@@ -41,7 +41,7 @@ sighandler(int32 sig, Siginfo *info, void *context)
...
@@ -41,7 +41,7 @@ sighandler(int32 sig, Siginfo *info, void *context)
Regs
*
r
;
Regs
*
r
;
if
(
panicking
)
// traceback already printed
if
(
panicking
)
// traceback already printed
sys_E
xit
(
2
);
e
xit
(
2
);
panicking
=
1
;
panicking
=
1
;
if
(
sig
<
0
||
sig
>=
NSIG
){
if
(
sig
<
0
||
sig
>=
NSIG
){
...
@@ -64,8 +64,8 @@ sighandler(int32 sig, Siginfo *info, void *context)
...
@@ -64,8 +64,8 @@ sighandler(int32 sig, Siginfo *info, void *context)
dumpregs
(
r
);
dumpregs
(
r
);
}
}
sys
·
B
reakpoint
();
b
reakpoint
();
sys_E
xit
(
2
);
e
xit
(
2
);
}
}
void
void
...
...
src/runtime/darwin/amd64/sys.s
View file @
918afd94
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
//
//
//
Exit
the
entire
program
(
like
C
exit
)
//
Exit
the
entire
program
(
like
C
exit
)
TEXT
sys
·
E
xit
(
SB
),7,$-8
TEXT
e
xit
(
SB
),7,$-8
MOVL
8
(
SP
),
DI
//
arg
1
exit
status
MOVL
8
(
SP
),
DI
//
arg
1
exit
status
MOVL
$
(
0x2000000
+
1
),
AX
//
syscall
entry
MOVL
$
(
0x2000000
+
1
),
AX
//
syscall
entry
SYSCALL
SYSCALL
...
...
src/runtime/linux/386/signal.c
View file @
918afd94
...
@@ -40,7 +40,7 @@ sighandler(int32 sig, Siginfo* info, void* context)
...
@@ -40,7 +40,7 @@ sighandler(int32 sig, Siginfo* info, void* context)
Sigcontext
*
sc
;
Sigcontext
*
sc
;
if
(
panicking
)
// traceback already printed
if
(
panicking
)
// traceback already printed
sys_E
xit
(
2
);
e
xit
(
2
);
panicking
=
1
;
panicking
=
1
;
uc
=
context
;
uc
=
context
;
...
@@ -61,8 +61,8 @@ sighandler(int32 sig, Siginfo* info, void* context)
...
@@ -61,8 +61,8 @@ sighandler(int32 sig, Siginfo* info, void* context)
dumpregs
(
sc
);
dumpregs
(
sc
);
}
}
sys
·
B
reakpoint
();
b
reakpoint
();
sys_E
xit
(
2
);
e
xit
(
2
);
}
}
void
void
...
...
src/runtime/linux/386/sys.s
View file @
918afd94
...
@@ -20,7 +20,7 @@ TEXT syscall(SB),7,$0
...
@@ -20,7 +20,7 @@ TEXT syscall(SB),7,$0
INT
$
3
//
not
reached
INT
$
3
//
not
reached
RET
RET
TEXT
sys
·
E
xit
(
SB
),7,$0
TEXT
e
xit
(
SB
),7,$0
MOVL
$
252
,
AX
//
syscall
number
MOVL
$
252
,
AX
//
syscall
number
MOVL
4
(
SP
),
BX
MOVL
4
(
SP
),
BX
INT
$
0x80
INT
$
0x80
...
...
src/runtime/linux/amd64/signal.c
View file @
918afd94
...
@@ -49,7 +49,7 @@ sighandler(int32 sig, Siginfo* info, void* context)
...
@@ -49,7 +49,7 @@ sighandler(int32 sig, Siginfo* info, void* context)
Sigcontext
*
sc
;
Sigcontext
*
sc
;
if
(
panicking
)
// traceback already printed
if
(
panicking
)
// traceback already printed
sys_E
xit
(
2
);
e
xit
(
2
);
panicking
=
1
;
panicking
=
1
;
uc
=
context
;
uc
=
context
;
...
@@ -71,8 +71,8 @@ sighandler(int32 sig, Siginfo* info, void* context)
...
@@ -71,8 +71,8 @@ sighandler(int32 sig, Siginfo* info, void* context)
dumpregs
(
sc
);
dumpregs
(
sc
);
}
}
sys
·
B
reakpoint
();
b
reakpoint
();
sys_E
xit
(
2
);
e
xit
(
2
);
}
}
void
void
...
...
src/runtime/linux/amd64/sys.s
View file @
918afd94
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
//
System
calls
and
other
sys
.
stuff
for
AMD64
,
Linux
//
System
calls
and
other
sys
.
stuff
for
AMD64
,
Linux
//
//
TEXT
sys
·
E
xit
(
SB
),7,$0-8
TEXT
e
xit
(
SB
),7,$0-8
MOVL
8
(
SP
),
DI
MOVL
8
(
SP
),
DI
MOVL
$
231
,
AX
//
exitgroup
-
force
all
os
threads
to
exi
MOVL
$
231
,
AX
//
exitgroup
-
force
all
os
threads
to
exi
SYSCALL
SYSCALL
...
...
src/runtime/proc.c
View file @
918afd94
...
@@ -129,7 +129,7 @@ initdone(void)
...
@@ -129,7 +129,7 @@ initdone(void)
}
}
void
void
sys
·
G
oexit
(
void
)
g
oexit
(
void
)
{
{
if
(
debug
>
1
){
if
(
debug
>
1
){
lock
(
&
debuglock
);
lock
(
&
debuglock
);
...
@@ -137,7 +137,7 @@ sys·Goexit(void)
...
@@ -137,7 +137,7 @@ sys·Goexit(void)
unlock
(
&
debuglock
);
unlock
(
&
debuglock
);
}
}
g
->
status
=
Gmoribund
;
g
->
status
=
Gmoribund
;
sys
·
G
osched
();
g
osched
();
}
}
void
void
...
@@ -431,7 +431,7 @@ scheduler(void)
...
@@ -431,7 +431,7 @@ scheduler(void)
case
Gmoribund
:
case
Gmoribund
:
gp
->
status
=
Gdead
;
gp
->
status
=
Gdead
;
if
(
--
sched
.
gcount
==
0
)
if
(
--
sched
.
gcount
==
0
)
sys_E
xit
(
0
);
e
xit
(
0
);
break
;
break
;
}
}
if
(
gp
->
readyonstop
){
if
(
gp
->
readyonstop
){
...
@@ -461,7 +461,7 @@ scheduler(void)
...
@@ -461,7 +461,7 @@ scheduler(void)
// before running g again. If g->status is Gmoribund,
// before running g again. If g->status is Gmoribund,
// kills off g.
// kills off g.
void
void
sys
·
G
osched
(
void
)
g
osched
(
void
)
{
{
if
(
g
==
m
->
g0
)
if
(
g
==
m
->
g0
)
throw
(
"gosched of g0"
);
throw
(
"gosched of g0"
);
...
@@ -529,7 +529,7 @@ sys·exitsyscall(void)
...
@@ -529,7 +529,7 @@ sys·exitsyscall(void)
// The scheduler will ready g and put this m to sleep.
// The scheduler will ready g and put this m to sleep.
// When the scheduler takes g awa from m,
// When the scheduler takes g awa from m,
// it will undo the sched.mcpu++ above.
// it will undo the sched.mcpu++ above.
sys
·
G
osched
();
g
osched
();
}
}
/*
/*
...
@@ -784,7 +784,7 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
...
@@ -784,7 +784,7 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
mcpy
(
sp
,
(
byte
*
)
&
arg0
,
siz
);
mcpy
(
sp
,
(
byte
*
)
&
arg0
,
siz
);
sp
-=
sizeof
(
uintptr
);
sp
-=
sizeof
(
uintptr
);
*
(
byte
**
)
sp
=
(
byte
*
)
sys
·
G
oexit
;
*
(
byte
**
)
sp
=
(
byte
*
)
g
oexit
;
sp
-=
sizeof
(
uintptr
);
// retpc used by gogo
sp
-=
sizeof
(
uintptr
);
// retpc used by gogo
newg
->
sched
.
SP
=
sp
;
newg
->
sched
.
SP
=
sp
;
...
@@ -839,3 +839,21 @@ sys·deferreturn(int32 arg0)
...
@@ -839,3 +839,21 @@ sys·deferreturn(int32 arg0)
jmpdefer
(
sp
);
jmpdefer
(
sp
);
}
}
void
runtime
·
Breakpoint
(
void
)
{
breakpoint
();
}
void
runtime
·
Goexit
(
void
)
{
goexit
();
}
void
runtime
·
Gosched
(
void
)
{
gosched
();
}
src/runtime/runtime.c
View file @
918afd94
...
@@ -25,7 +25,7 @@ sys·panicl(int32 lno)
...
@@ -25,7 +25,7 @@ sys·panicl(int32 lno)
if
(
panicking
)
{
if
(
panicking
)
{
printf
(
"double panic
\n
"
);
printf
(
"double panic
\n
"
);
sys_E
xit
(
3
);
e
xit
(
3
);
}
}
panicking
++
;
panicking
++
;
...
@@ -35,8 +35,8 @@ sys·panicl(int32 lno)
...
@@ -35,8 +35,8 @@ sys·panicl(int32 lno)
traceback
(
sys
·
getcallerpc
(
&
lno
),
sp
,
g
);
traceback
(
sys
·
getcallerpc
(
&
lno
),
sp
,
g
);
tracebackothers
(
g
);
tracebackothers
(
g
);
}
}
sys
·
B
reakpoint
();
// so we can grab it in a debugger
b
reakpoint
();
// so we can grab it in a debugger
sys_E
xit
(
2
);
e
xit
(
2
);
}
}
void
void
...
@@ -57,7 +57,7 @@ throw(int8 *s)
...
@@ -57,7 +57,7 @@ throw(int8 *s)
printf
(
"throw: %s
\n
"
,
s
);
printf
(
"throw: %s
\n
"
,
s
);
sys
·
panicl
(
-
1
);
sys
·
panicl
(
-
1
);
*
(
int32
*
)
0
=
0
;
// not reached
*
(
int32
*
)
0
=
0
;
// not reached
sys_E
xit
(
1
);
// even more not reached
e
xit
(
1
);
// even more not reached
}
}
void
void
...
@@ -136,8 +136,8 @@ rnd(uint32 n, uint32 m)
...
@@ -136,8 +136,8 @@ rnd(uint32 n, uint32 m)
static
int32
argc
;
static
int32
argc
;
static
uint8
**
argv
;
static
uint8
**
argv
;
Array
sy
s
·
Args
;
Array
o
s
·
Args
;
Array
sy
s
·
Envs
;
Array
o
s
·
Envs
;
void
void
args
(
int32
c
,
uint8
**
v
)
args
(
int32
c
,
uint8
**
v
)
...
@@ -161,15 +161,15 @@ goargs(void)
...
@@ -161,15 +161,15 @@ goargs(void)
for
(
i
=
0
;
i
<
argc
;
i
++
)
for
(
i
=
0
;
i
<
argc
;
i
++
)
gargv
[
i
]
=
gostring
(
argv
[
i
]);
gargv
[
i
]
=
gostring
(
argv
[
i
]);
sy
s
·
Args
.
array
=
(
byte
*
)
gargv
;
o
s
·
Args
.
array
=
(
byte
*
)
gargv
;
sy
s
·
Args
.
nel
=
argc
;
o
s
·
Args
.
nel
=
argc
;
sy
s
·
Args
.
cap
=
argc
;
o
s
·
Args
.
cap
=
argc
;
for
(
i
=
0
;
i
<
envc
;
i
++
)
for
(
i
=
0
;
i
<
envc
;
i
++
)
genvv
[
i
]
=
gostring
(
argv
[
argc
+
1
+
i
]);
genvv
[
i
]
=
gostring
(
argv
[
argc
+
1
+
i
]);
sy
s
·
Envs
.
array
=
(
byte
*
)
genvv
;
o
s
·
Envs
.
array
=
(
byte
*
)
genvv
;
sy
s
·
Envs
.
nel
=
envc
;
o
s
·
Envs
.
nel
=
envc
;
sy
s
·
Envs
.
cap
=
envc
;
o
s
·
Envs
.
cap
=
envc
;
}
}
byte
*
byte
*
...
@@ -182,8 +182,8 @@ getenv(int8 *s)
...
@@ -182,8 +182,8 @@ getenv(int8 *s)
bs
=
(
byte
*
)
s
;
bs
=
(
byte
*
)
s
;
len
=
findnull
(
bs
);
len
=
findnull
(
bs
);
envv
=
(
String
*
)
sy
s
·
Envs
.
array
;
envv
=
(
String
*
)
o
s
·
Envs
.
array
;
envc
=
sy
s
·
Envs
.
nel
;
envc
=
o
s
·
Envs
.
nel
;
for
(
i
=
0
;
i
<
envc
;
i
++
){
for
(
i
=
0
;
i
<
envc
;
i
++
){
if
(
envv
[
i
].
len
<=
len
)
if
(
envv
[
i
].
len
<=
len
)
continue
;
continue
;
...
...
src/runtime/runtime.h
View file @
918afd94
...
@@ -329,6 +329,10 @@ uint32 noequal(uint32, void*, void*);
...
@@ -329,6 +329,10 @@ uint32 noequal(uint32, void*, void*);
void
*
malloc
(
uintptr
size
);
void
*
malloc
(
uintptr
size
);
void
*
mallocgc
(
uintptr
size
);
void
*
mallocgc
(
uintptr
size
);
void
free
(
void
*
v
);
void
free
(
void
*
v
);
void
exit
(
int32
);
void
breakpoint
(
void
);
void
gosched
(
void
);
void
goexit
(
void
);
#pragma varargck argpos printf 1
#pragma varargck argpos printf 1
...
@@ -378,15 +382,11 @@ void notewakeup(Note*);
...
@@ -378,15 +382,11 @@ void notewakeup(Note*);
* UTF-8 characters in identifiers.
* UTF-8 characters in identifiers.
*/
*/
#ifndef __GNUC__
#ifndef __GNUC__
#define sys_Exit sys·Exit
#define sys_Gosched sys·Gosched
#define sys_memclr sys·memclr
#define sys_memclr sys·memclr
#define sys_write sys·write
#define sys_write sys·write
#define sys_Breakpoint sys·Breakpoint
#define sys_catstring sys·catstring
#define sys_catstring sys·catstring
#define sys_cmpstring sys·cmpstring
#define sys_cmpstring sys·cmpstring
#define sys_getcallerpc sys·getcallerpc
#define sys_getcallerpc sys·getcallerpc
#define sys_Goexit sys·Goexit
#define sys_indexstring sys·indexstring
#define sys_indexstring sys·indexstring
#define sys_intstring sys·intstring
#define sys_intstring sys·intstring
#define sys_mal sys·mal
#define sys_mal sys·mal
...
@@ -408,11 +408,7 @@ void notewakeup(Note*);
...
@@ -408,11 +408,7 @@ void notewakeup(Note*);
/*
/*
* low level go-called
* low level go-called
*/
*/
void
sys_Goexit
(
void
);
void
sys_Gosched
(
void
);
void
sys_Exit
(
int32
);
void
sys_write
(
int32
,
void
*
,
int32
);
void
sys_write
(
int32
,
void
*
,
int32
);
void
sys_Breakpoint
(
void
);
uint8
*
sys_mmap
(
byte
*
,
uint32
,
int32
,
int32
,
int32
,
uint32
);
uint8
*
sys_mmap
(
byte
*
,
uint32
,
int32
,
int32
,
int32
,
uint32
);
void
sys_memclr
(
byte
*
,
uint32
);
void
sys_memclr
(
byte
*
,
uint32
);
void
sys_setcallerpc
(
void
*
,
void
*
);
void
sys_setcallerpc
(
void
*
,
void
*
);
...
...
src/runtime/sema.c
View file @
918afd94
...
@@ -119,7 +119,7 @@ semsleep2(Sema *s)
...
@@ -119,7 +119,7 @@ semsleep2(Sema *s)
{
{
USED
(
s
);
USED
(
s
);
g
->
status
=
Gwaiting
;
g
->
status
=
Gwaiting
;
sys
·
G
osched
();
g
osched
();
}
}
static
int32
static
int32
...
...
src/runtime/string.c
View file @
918afd94
...
@@ -215,8 +215,6 @@ out:
...
@@ -215,8 +215,6 @@ out:
void
void
sys
·
stringiter2
(
String
s
,
int32
k
,
int32
retk
,
int32
retv
)
sys
·
stringiter2
(
String
s
,
int32
k
,
int32
retk
,
int32
retv
)
{
{
int32
l
;
if
(
k
>=
s
.
len
)
{
if
(
k
>=
s
.
len
)
{
// retk=0 is end of iteration
// retk=0 is end of iteration
retk
=
0
;
retk
=
0
;
...
...
test/235.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
type
T
chan
uint64
;
type
T
chan
uint64
;
func
M
(
f
uint64
)
(
in
,
out
T
)
{
func
M
(
f
uint64
)
(
in
,
out
T
)
{
...
@@ -65,5 +67,5 @@ func main() {
...
@@ -65,5 +67,5 @@ func main() {
x
=
min
(
xs
);
x
=
min
(
xs
);
if
x
!=
OUT
[
i
]
{
panic
(
"bad: "
,
x
,
" should be "
,
OUT
[
i
]);
}
if
x
!=
OUT
[
i
]
{
panic
(
"bad: "
,
x
,
" should be "
,
OUT
[
i
]);
}
}
}
sy
s
.
Exit
(
0
);
o
s
.
Exit
(
0
);
}
}
test/args.go
View file @
918afd94
...
@@ -6,14 +6,16 @@
...
@@ -6,14 +6,16 @@
package
main
package
main
import
"os"
func
main
()
{
func
main
()
{
if
len
(
sy
s
.
Args
)
!=
3
{
if
len
(
o
s
.
Args
)
!=
3
{
panic
(
"argc"
)
panic
(
"argc"
)
}
}
if
sy
s
.
Args
[
1
]
!=
"arg1"
{
if
o
s
.
Args
[
1
]
!=
"arg1"
{
panic
(
"arg1"
)
panic
(
"arg1"
)
}
}
if
sy
s
.
Args
[
2
]
!=
"arg2"
{
if
o
s
.
Args
[
2
]
!=
"arg2"
{
panic
(
"arg2"
)
panic
(
"arg2"
)
}
}
}
}
test/chan/fifo.go
View file @
918afd94
...
@@ -8,6 +8,8 @@
...
@@ -8,6 +8,8 @@
package
main
package
main
import
"os"
const
N
=
10
const
N
=
10
func
AsynchFifo
()
{
func
AsynchFifo
()
{
...
@@ -18,7 +20,7 @@ func AsynchFifo() {
...
@@ -18,7 +20,7 @@ func AsynchFifo() {
for
i
:=
0
;
i
<
N
;
i
++
{
for
i
:=
0
;
i
<
N
;
i
++
{
if
<-
ch
!=
i
{
if
<-
ch
!=
i
{
print
(
"bad receive
\n
"
);
print
(
"bad receive
\n
"
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
}
}
...
...
test/chan/goroutines.go
View file @
918afd94
...
@@ -20,12 +20,12 @@ func f(left, right chan int) {
...
@@ -20,12 +20,12 @@ func f(left, right chan int) {
func
main
()
{
func
main
()
{
var
n
=
10000
;
var
n
=
10000
;
if
len
(
sy
s
.
Args
)
>
1
{
if
len
(
o
s
.
Args
)
>
1
{
var
err
os
.
Error
;
var
err
os
.
Error
;
n
,
err
=
strconv
.
Atoi
(
sy
s
.
Args
[
1
]);
n
,
err
=
strconv
.
Atoi
(
o
s
.
Args
[
1
]);
if
err
!=
nil
{
if
err
!=
nil
{
print
(
"bad arg
\n
"
);
print
(
"bad arg
\n
"
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
leftmost
:=
make
(
chan
int
);
leftmost
:=
make
(
chan
int
);
...
...
test/chan/nonblock.go
View file @
918afd94
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
package
main
package
main
import
"runtime"
import
"time"
import
"time"
func
i32receiver
(
c
chan
int32
,
strobe
chan
bool
)
{
func
i32receiver
(
c
chan
int32
,
strobe
chan
bool
)
{
...
@@ -55,9 +56,9 @@ var ticker = time.Tick(10*1000); // 10 us
...
@@ -55,9 +56,9 @@ var ticker = time.Tick(10*1000); // 10 us
func
sleep
()
{
func
sleep
()
{
<-
ticker
;
<-
ticker
;
<-
ticker
;
<-
ticker
;
sys
.
Gosched
();
runtime
.
Gosched
();
sys
.
Gosched
();
runtime
.
Gosched
();
sys
.
Gosched
();
runtime
.
Gosched
();
}
}
func
main
()
{
func
main
()
{
...
...
test/chan/powser1.go
View file @
918afd94
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
package
main
package
main
import
"os"
type
rat
struct
{
type
rat
struct
{
num
,
den
int64
;
// numerator, denominator
num
,
den
int64
;
// numerator, denominator
}
}
...
@@ -623,7 +625,7 @@ func checka(U PS, a []rat, str string) {
...
@@ -623,7 +625,7 @@ func checka(U PS, a []rat, str string) {
func
main
()
{
func
main
()
{
Init
();
Init
();
if
len
(
sy
s
.
Args
)
>
1
{
// print
if
len
(
o
s
.
Args
)
>
1
{
// print
print
(
"Ones: "
);
printn
(
Ones
,
10
);
print
(
"Ones: "
);
printn
(
Ones
,
10
);
print
(
"Twos: "
);
printn
(
Twos
,
10
);
print
(
"Twos: "
);
printn
(
Twos
,
10
);
print
(
"Add: "
);
printn
(
Add
(
Ones
,
Twos
),
10
);
print
(
"Add: "
);
printn
(
Add
(
Ones
,
Twos
),
10
);
...
...
test/chan/powser2.go
View file @
918afd94
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
main
package
main
import
"os"
type
rat
struct
{
type
rat
struct
{
num
,
den
int64
;
// numerator, denominator
num
,
den
int64
;
// numerator, denominator
}
}
...
@@ -636,7 +638,7 @@ func checka(U PS, a []*rat, str string) {
...
@@ -636,7 +638,7 @@ func checka(U PS, a []*rat, str string) {
func
main
()
{
func
main
()
{
Init
();
Init
();
if
len
(
sy
s
.
Args
)
>
1
{
// print
if
len
(
o
s
.
Args
)
>
1
{
// print
print
(
"Ones: "
);
Printn
(
Ones
,
10
);
print
(
"Ones: "
);
Printn
(
Ones
,
10
);
print
(
"Twos: "
);
Printn
(
Twos
,
10
);
print
(
"Twos: "
);
Printn
(
Twos
,
10
);
print
(
"Add: "
);
Printn
(
Add
(
Ones
,
Twos
),
10
);
print
(
"Add: "
);
Printn
(
Add
(
Ones
,
Twos
),
10
);
...
...
test/chan/sieve.go
View file @
918afd94
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
package
main
package
main
import
"os"
// Send the sequence 2, 3, 4, ... to channel 'ch'.
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func
Generate
(
ch
chan
<-
int
)
{
func
Generate
(
ch
chan
<-
int
)
{
for
i
:=
2
;
;
i
++
{
for
i
:=
2
;
;
i
++
{
...
@@ -47,5 +49,5 @@ func main() {
...
@@ -47,5 +49,5 @@ func main() {
for
i
:=
0
;
i
<
len
(
a
);
i
++
{
for
i
:=
0
;
i
<
len
(
a
);
i
++
{
if
x
:=
<-
primes
;
x
!=
a
[
i
]
{
panic
(
x
,
" != "
,
a
[
i
])
}
if
x
:=
<-
primes
;
x
!=
a
[
i
]
{
panic
(
x
,
" != "
,
a
[
i
])
}
}
}
sy
s
.
Exit
(
0
);
o
s
.
Exit
(
0
);
}
}
test/char_lit.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
func
main
()
{
func
main
()
{
var
i
uint64
=
var
i
uint64
=
' '
+
' '
+
...
@@ -33,10 +35,10 @@ func main() {
...
@@ -33,10 +35,10 @@ func main() {
;
;
if
'\Ucafebabe'
!=
0xcafebabe
{
if
'\Ucafebabe'
!=
0xcafebabe
{
print
(
"cafebabe wrong
\n
"
);
print
(
"cafebabe wrong
\n
"
);
sy
s
.
Exit
(
1
)
o
s
.
Exit
(
1
)
}
}
if
i
!=
0xcc238de1
{
if
i
!=
0xcc238de1
{
print
(
"number is "
,
i
,
" should be "
,
0xcc238de1
,
"
\n
"
);
print
(
"number is "
,
i
,
" should be "
,
0xcc238de1
,
"
\n
"
);
sy
s
.
Exit
(
1
)
o
s
.
Exit
(
1
)
}
}
}
}
test/env.go
View file @
918afd94
...
@@ -12,15 +12,15 @@ func main() {
...
@@ -12,15 +12,15 @@ func main() {
ga
,
e0
:=
os
.
Getenv
(
"GOARCH"
);
ga
,
e0
:=
os
.
Getenv
(
"GOARCH"
);
if
e0
!=
nil
{
if
e0
!=
nil
{
print
(
"$GOARCH: "
,
e0
.
String
(),
"
\n
"
);
print
(
"$GOARCH: "
,
e0
.
String
(),
"
\n
"
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
if
ga
!=
"amd64"
{
if
ga
!=
"amd64"
{
print
(
"$GOARCH="
,
ga
,
"
\n
"
);
print
(
"$GOARCH="
,
ga
,
"
\n
"
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
xxx
,
e1
:=
os
.
Getenv
(
"DOES_NOT_EXIST"
);
xxx
,
e1
:=
os
.
Getenv
(
"DOES_NOT_EXIST"
);
if
e1
!=
os
.
ENOENV
{
if
e1
!=
os
.
ENOENV
{
print
(
"$DOES_NOT_EXIST="
,
xxx
,
"; err = "
,
e1
.
String
(),
"
\n
"
);
print
(
"$DOES_NOT_EXIST="
,
xxx
,
"; err = "
,
e1
.
String
(),
"
\n
"
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
test/fixedbugs/bug006.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
const
(
const
(
x
float
=
iota
;
x
float
=
iota
;
g
float
=
4.5
*
iota
;
g
float
=
4.5
*
iota
;
...
@@ -13,5 +15,5 @@ const (
...
@@ -13,5 +15,5 @@ const (
func
main
()
{
func
main
()
{
if
g
==
0.0
{
print
(
"zero
\n
"
);}
if
g
==
0.0
{
print
(
"zero
\n
"
);}
if
g
!=
4.5
{
print
(
" fail
\n
"
);
sy
s
.
Exit
(
1
);
}
if
g
!=
4.5
{
print
(
" fail
\n
"
);
o
s
.
Exit
(
1
);
}
}
}
test/fixedbugs/bug059.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
func
P
(
a
[]
string
)
string
{
func
P
(
a
[]
string
)
string
{
s
:=
"{"
;
s
:=
"{"
;
for
i
:=
0
;
i
<
2
;
i
++
{
for
i
:=
0
;
i
<
2
;
i
++
{
...
@@ -29,6 +31,6 @@ func main() {
...
@@ -29,6 +31,6 @@ func main() {
a
[
0
]
=
"x"
;
a
[
0
]
=
"x"
;
m
[
"0"
][
0
]
=
"deleted"
;
m
[
"0"
][
0
]
=
"deleted"
;
if
m
[
"0"
][
0
]
!=
"deleted"
{
if
m
[
"0"
][
0
]
!=
"deleted"
{
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
test/fixedbugs/bug060.go
View file @
918afd94
...
@@ -6,12 +6,14 @@
...
@@ -6,12 +6,14 @@
package
main
package
main
import
"os"
func
main
()
{
func
main
()
{
m
:=
make
(
map
[
int
]
int
);
m
:=
make
(
map
[
int
]
int
);
m
[
0
]
=
0
;
m
[
0
]
=
0
;
m
[
0
]
++
;
m
[
0
]
++
;
if
m
[
0
]
!=
1
{
if
m
[
0
]
!=
1
{
print
(
"map does not increment
\n
"
);
print
(
"map does not increment
\n
"
);
sy
s
.
Exit
(
1
)
o
s
.
Exit
(
1
)
}
}
}
}
test/fixedbugs/bug120.go
View file @
918afd94
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
package
main
package
main
import
"os"
import
"strconv"
;
import
"strconv"
;
type
Test
struct
{
type
Test
struct
{
...
@@ -53,6 +54,6 @@ func main() {
...
@@ -53,6 +54,6 @@ func main() {
}
}
}
}
if
!
ok
{
if
!
ok
{
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
test/fixedbugs/bug130.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
type
I
interface
{
send
(
chan
<-
int
)
}
type
I
interface
{
send
(
chan
<-
int
)
}
type
S
struct
{
v
int
}
type
S
struct
{
v
int
}
...
@@ -16,5 +18,5 @@ func main() {
...
@@ -16,5 +18,5 @@ func main() {
var
i
I
=
&
s
;
var
i
I
=
&
s
;
c
:=
make
(
chan
int
);
c
:=
make
(
chan
int
);
go
i
.
send
(
c
);
go
i
.
send
(
c
);
sy
s
.
Exit
(
<-
c
);
o
s
.
Exit
(
<-
c
);
}
}
test/fixedbugs/bug141.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
type
S
struct
{
i
int
}
type
S
struct
{
i
int
}
func
(
p
*
S
)
Get
()
int
{
return
p
.
i
}
func
(
p
*
S
)
Get
()
int
{
return
p
.
i
}
...
@@ -18,7 +20,7 @@ type Getter interface {
...
@@ -18,7 +20,7 @@ type Getter interface {
func
f1
(
p
Empty
)
{
func
f1
(
p
Empty
)
{
switch
x
:=
p
.
(
type
)
{
switch
x
:=
p
.
(
type
)
{
default
:
println
(
"failed to match interface"
);
sy
s
.
Exit
(
1
);
default
:
println
(
"failed to match interface"
);
o
s
.
Exit
(
1
);
case
Getter
:
break
;
case
Getter
:
break
;
}
}
...
...
test/if1.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
func
main
()
{
func
main
()
{
count
:=
7
;
count
:=
7
;
if
one
:=
1
;
{
if
one
:=
1
;
{
...
@@ -13,6 +15,6 @@ func main() {
...
@@ -13,6 +15,6 @@ func main() {
}
}
if
count
!=
8
{
if
count
!=
8
{
print
(
count
,
" should be 8
\n
"
);
print
(
count
,
" should be 8
\n
"
);
sy
s
.
Exit
(
1
)
o
s
.
Exit
(
1
)
}
}
}
}
test/int_lit.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
func
main
()
{
func
main
()
{
s
:=
s
:=
0
+
0
+
...
@@ -18,6 +20,6 @@ func main() {
...
@@ -18,6 +20,6 @@ func main() {
0X123
;
0X123
;
if
s
!=
788
{
if
s
!=
788
{
print
(
"s is "
,
s
,
"; should be 788
\n
"
);
print
(
"s is "
,
s
,
"; should be 788
\n
"
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
test/interface10.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
const
Value
=
1e12
const
Value
=
1e12
type
Inter
interface
{
M
()
int64
}
type
Inter
interface
{
M
()
int64
}
...
@@ -73,6 +75,6 @@ func main() {
...
@@ -73,6 +75,6 @@ func main() {
if
!
ok
{
if
!
ok
{
println
(
"BUG: interface10"
);
println
(
"BUG: interface10"
);
sy
s
.
Exit
(
1
)
o
s
.
Exit
(
1
)
}
}
}
}
test/interface4.go
View file @
918afd94
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
package
main
package
main
import
"os"
type
I
interface
{
M
()
int64
}
type
I
interface
{
M
()
int64
}
type
BigPtr
struct
{
a
,
b
,
c
,
d
int64
}
type
BigPtr
struct
{
a
,
b
,
c
,
d
int64
}
...
@@ -70,6 +72,6 @@ func main() {
...
@@ -70,6 +72,6 @@ func main() {
nonptrs
();
nonptrs
();
if
bad
{
if
bad
{
sy
s
.
Exit
(
1
)
o
s
.
Exit
(
1
)
}
}
}
}
test/interface6.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
var
fail
int
var
fail
int
func
check
(
b
bool
,
msg
string
)
{
func
check
(
b
bool
,
msg
string
)
{
...
@@ -145,6 +147,6 @@ func main() {
...
@@ -145,6 +147,6 @@ func main() {
f11
();
f11
();
f12
();
f12
();
if
fail
>
0
{
if
fail
>
0
{
sy
s
.
Exit
(
1
)
o
s
.
Exit
(
1
)
}
}
}
}
test/ken/chan.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
import
"runtime"
var
randx
int
;
var
randx
int
;
...
@@ -88,7 +90,7 @@ send(c *Chan)
...
@@ -88,7 +90,7 @@ send(c *Chan)
nproc
++
;
// total goroutines running
nproc
++
;
// total goroutines running
for
{
for
{
for
r
:=
nrand
(
10
);
r
>=
0
;
r
--
{
for
r
:=
nrand
(
10
);
r
>=
0
;
r
--
{
sys
.
Gosched
();
runtime
.
Gosched
();
}
}
c
.
sc
<-
c
.
sv
;
c
.
sc
<-
c
.
sv
;
if
c
.
send
()
{
if
c
.
send
()
{
...
@@ -119,7 +121,7 @@ recv(c *Chan)
...
@@ -119,7 +121,7 @@ recv(c *Chan)
nproc
++
;
// total goroutines running
nproc
++
;
// total goroutines running
for
{
for
{
for
r
:=
nrand
(
10
);
r
>=
0
;
r
--
{
for
r
:=
nrand
(
10
);
r
>=
0
;
r
--
{
sys
.
Gosched
();
runtime
.
Gosched
();
}
}
v
=
<-
c
.
rc
;
v
=
<-
c
.
rc
;
if
c
.
recv
(
v
)
{
if
c
.
recv
(
v
)
{
...
@@ -148,7 +150,7 @@ sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan)
...
@@ -148,7 +150,7 @@ sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan)
for
{
for
{
for
r
:=
nrand
(
5
);
r
>=
0
;
r
--
{
for
r
:=
nrand
(
5
);
r
>=
0
;
r
--
{
sys
.
Gosched
();
runtime
.
Gosched
();
}
}
select
{
select
{
...
@@ -270,9 +272,9 @@ test6(c int)
...
@@ -270,9 +272,9 @@ test6(c int)
func
func
wait
()
wait
()
{
{
sys
.
Gosched
();
runtime
.
Gosched
();
for
nproc
!=
0
{
for
nproc
!=
0
{
sys
.
Gosched
();
runtime
.
Gosched
();
}
}
}
}
...
@@ -321,7 +323,7 @@ main()
...
@@ -321,7 +323,7 @@ main()
if
tots
!=
t
||
totr
!=
t
{
if
tots
!=
t
||
totr
!=
t
{
print
(
"tots="
,
tots
,
" totr="
,
totr
,
" sb="
,
t
,
"
\n
"
);
print
(
"tots="
,
tots
,
" totr="
,
totr
,
" sb="
,
t
,
"
\n
"
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
sy
s
.
Exit
(
0
);
o
s
.
Exit
(
0
);
}
}
test/ken/chan1.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"runtime"
const
N
=
1000
;
// sent messages
const
N
=
1000
;
// sent messages
const
M
=
10
;
// receiving goroutines
const
M
=
10
;
// receiving goroutines
const
W
=
2
;
// channel buffering
const
W
=
2
;
// channel buffering
...
@@ -48,9 +50,9 @@ main()
...
@@ -48,9 +50,9 @@ main()
c
:=
make
(
chan
int
,
W
);
c
:=
make
(
chan
int
,
W
);
for
m
:=
0
;
m
<
M
;
m
++
{
for
m
:=
0
;
m
<
M
;
m
++
{
go
r
(
c
,
m
);
go
r
(
c
,
m
);
sys
.
Gosched
();
runtime
.
Gosched
();
}
}
sys
.
Gosched
();
runtime
.
Gosched
();
sys
.
Gosched
();
runtime
.
Gosched
();
s
(
c
);
s
(
c
);
}
}
test/string_lit.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
var
ecode
int
;
var
ecode
int
;
func
assert
(
a
,
b
,
c
string
)
{
func
assert
(
a
,
b
,
c
string
)
{
...
@@ -84,5 +86,5 @@ func main() {
...
@@ -84,5 +86,5 @@ func main() {
r
=
0x10ffff
+
1
;
r
=
0x10ffff
+
1
;
s
=
string
(
r
);
s
=
string
(
r
);
assert
(
s
,
"
\xef\xbf\xbd
"
,
"too-large rune"
);
assert
(
s
,
"
\xef\xbf\xbd
"
,
"too-large rune"
);
sy
s
.
Exit
(
ecode
);
o
s
.
Exit
(
ecode
);
}
}
test/stringrange.go
View file @
918afd94
...
@@ -8,6 +8,7 @@ package main
...
@@ -8,6 +8,7 @@ package main
import
(
import
(
"fmt"
;
"fmt"
;
"os"
;
"utf8"
;
"utf8"
;
)
)
...
@@ -56,6 +57,6 @@ func main() {
...
@@ -56,6 +57,6 @@ func main() {
if
!
ok
{
if
!
ok
{
fmt
.
Println
(
"BUG: stringrange"
);
fmt
.
Println
(
"BUG: stringrange"
);
sy
s
.
Exit
(
1
)
o
s
.
Exit
(
1
)
}
}
}
}
test/switch1.go
View file @
918afd94
...
@@ -6,13 +6,15 @@
...
@@ -6,13 +6,15 @@
package
main
package
main
import
"os"
func
main
()
{
func
main
()
{
i
:=
0
;
i
:=
0
;
switch
x
:=
5
;
{
switch
x
:=
5
;
{
case
i
<
x
:
case
i
<
x
:
sy
s
.
Exit
(
0
);
o
s
.
Exit
(
0
);
case
i
==
x
:
case
i
==
x
:
case
i
>
x
:
case
i
>
x
:
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
test/typeswitch.go
View file @
918afd94
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
main
package
main
import
"os"
const
(
const
(
Bool
=
iota
;
Bool
=
iota
;
Int
;
Int
;
...
@@ -31,7 +33,7 @@ var m = make(map[string]int)
...
@@ -31,7 +33,7 @@ var m = make(map[string]int)
func
assert
(
b
bool
,
s
string
)
{
func
assert
(
b
bool
,
s
string
)
{
if
!
b
{
if
!
b
{
println
(
s
);
println
(
s
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
}
}
...
...
usr/gri/pretty/godoc.go
View file @
918afd94
...
@@ -704,7 +704,7 @@ func usage() {
...
@@ -704,7 +704,7 @@ func usage() {
" godoc -http=:6060
\n
"
" godoc -http=:6060
\n
"
);
);
flag
.
PrintDefaults
();
flag
.
PrintDefaults
();
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
...
@@ -761,7 +761,7 @@ func main() {
...
@@ -761,7 +761,7 @@ func main() {
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Stderrf
(
"packagelistText.Execute: %s"
,
err
);
log
.
Stderrf
(
"packagelistText.Execute: %s"
,
err
);
}
}
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
doc
,
errors
:=
info
.
Package
.
Doc
();
doc
,
errors
:=
info
.
Package
.
Doc
();
...
@@ -770,7 +770,7 @@ func main() {
...
@@ -770,7 +770,7 @@ func main() {
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Stderrf
(
"parseerrorText.Execute: %s"
,
err
);
log
.
Stderrf
(
"parseerrorText.Execute: %s"
,
err
);
}
}
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
if
flag
.
NArg
()
>
1
{
if
flag
.
NArg
()
>
1
{
...
...
usr/gri/pretty/pretty.go
View file @
918afd94
...
@@ -41,7 +41,7 @@ func init() {
...
@@ -41,7 +41,7 @@ func init() {
func
usage
()
{
func
usage
()
{
fmt
.
Fprintf
(
os
.
Stderr
,
"usage: pretty { flags } { files }
\n
"
);
fmt
.
Fprintf
(
os
.
Stderr
,
"usage: pretty { flags } { files }
\n
"
);
flag
.
PrintDefaults
();
flag
.
PrintDefaults
();
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
...
@@ -127,12 +127,12 @@ func main() {
...
@@ -127,12 +127,12 @@ func main() {
src
,
err
:=
readFile
(
ast_txt
);
src
,
err
:=
readFile
(
ast_txt
);
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: %v
\n
"
,
ast_txt
,
err
);
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: %v
\n
"
,
ast_txt
,
err
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
ast_format
,
err
:=
format
.
Parse
(
src
,
format
.
FormatterMap
{
"isValidPos"
:
isValidPos
,
"isSend"
:
isSend
,
"isRecv"
:
isRecv
});
ast_format
,
err
:=
format
.
Parse
(
src
,
format
.
FormatterMap
{
"isValidPos"
:
isValidPos
,
"isSend"
:
isSend
,
"isRecv"
:
isRecv
});
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: format errors:
\n
%s"
,
ast_txt
,
err
);
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: format errors:
\n
%s"
,
ast_txt
,
err
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
// process files
// process files
...
@@ -166,5 +166,5 @@ func main() {
...
@@ -166,5 +166,5 @@ func main() {
}
}
}
}
sy
s
.
Exit
(
exitcode
);
o
s
.
Exit
(
exitcode
);
}
}
usr/gri/pretty/untab.go
View file @
918afd94
...
@@ -21,7 +21,7 @@ var (
...
@@ -21,7 +21,7 @@ var (
func
error
(
format
string
,
params
...
)
{
func
error
(
format
string
,
params
...
)
{
fmt
.
Printf
(
format
,
params
);
fmt
.
Printf
(
format
,
params
);
sy
s
.
Exit
(
1
);
o
s
.
Exit
(
1
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment