Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
7d11924c
Commit
7d11924c
authored
Jun 25, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
middle dot as alpha package separator
SVN=124419
parent
206daeab
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
238 additions
and
191 deletions
+238
-191
gen.c
src/cmd/6g/gen.c
+1
-0
obj.c
src/cmd/6g/obj.c
+8
-1
lexbody
src/cmd/cc/lexbody
+13
-3
walk.c
src/cmd/gc/walk.c
+50
-23
rt0_amd64_darwin.s
src/runtime/rt0_amd64_darwin.s
+8
-8
rt0_amd64_linux.s
src/runtime/rt0_amd64_linux.s
+10
-10
rt1_amd64_darwin.c
src/runtime/rt1_amd64_darwin.c
+26
-26
rt1_amd64_linux.c
src/runtime/rt1_amd64_linux.c
+7
-7
rt2_amd64.c
src/runtime/rt2_amd64.c
+3
-3
runtime.c
src/runtime/runtime.c
+89
-88
runtime.h
src/runtime/runtime.h
+23
-22
No files found.
src/cmd/6g/gen.c
View file @
7d11924c
...
@@ -380,6 +380,7 @@ agen_inter(Node *n, Node *res)
...
@@ -380,6 +380,7 @@ agen_inter(Node *n, Node *res)
if
(
!
n
->
left
->
addable
)
{
if
(
!
n
->
left
->
addable
)
{
agen
(
n
->
left
,
&
nodr
);
agen
(
n
->
left
,
&
nodr
);
gmove
(
&
nodr
,
&
nodo
);
gmove
(
&
nodr
,
&
nodo
);
dump
(
"xxx"
,
n
->
left
);
fatal
(
"agen_inter i2s"
);
fatal
(
"agen_inter i2s"
);
}
else
{
}
else
{
cgen
(
n
->
left
,
&
nodo
);
cgen
(
n
->
left
,
&
nodo
);
...
...
src/cmd/6g/obj.c
View file @
7d11924c
...
@@ -165,6 +165,13 @@ return;
...
@@ -165,6 +165,13 @@ return;
Bterm
(
bout
);
Bterm
(
bout
);
}
}
Bputdot
(
Biobuf
*
b
)
{
// put out middle dot ·
Bputc
(
b
,
0xc2
);
Bputc
(
b
,
0xb7
);
}
void
void
zname
(
Biobuf
*
b
,
Sym
*
s
,
int
t
)
zname
(
Biobuf
*
b
,
Sym
*
s
,
int
t
)
{
{
...
@@ -177,7 +184,7 @@ zname(Biobuf *b, Sym *s, int t)
...
@@ -177,7 +184,7 @@ zname(Biobuf *b, Sym *s, int t)
for
(
n
=
s
->
opackage
;
*
n
;
n
++
)
for
(
n
=
s
->
opackage
;
*
n
;
n
++
)
Bputc
(
b
,
*
n
);
Bputc
(
b
,
*
n
);
Bput
c
(
b
,
'_'
);
Bput
dot
(
b
);
for
(
n
=
s
->
name
;
*
n
;
n
++
)
for
(
n
=
s
->
name
;
*
n
;
n
++
)
Bputc
(
b
,
*
n
);
Bputc
(
b
,
*
n
);
Bputc
(
b
,
0
);
Bputc
(
b
,
0
);
...
...
src/cmd/cc/lexbody
View file @
7d11924c
...
@@ -232,6 +232,16 @@ lookup(void)
...
@@ -232,6 +232,16 @@ lookup(void)
return s;
return s;
}
}
int
ISALPHA(int c)
{
if(isalpha(c))
return 1;
if(c >= Runeself)
return 1;
return 0;
}
long
long
yylex(void)
yylex(void)
{
{
...
@@ -259,7 +269,7 @@ l1:
...
@@ -259,7 +269,7 @@ l1:
}
}
goto l0;
goto l0;
}
}
if(
isalpha
(c))
if(
ISALPHA
(c))
goto talph;
goto talph;
if(isdigit(c))
if(isdigit(c))
goto tnum;
goto tnum;
...
@@ -275,7 +285,7 @@ l1:
...
@@ -275,7 +285,7 @@ l1:
case '.':
case '.':
c = GETC();
c = GETC();
if(
isalpha
(c)) {
if(
ISALPHA
(c)) {
cp = symb;
cp = symb;
*cp++ = '.';
*cp++ = '.';
goto aloop;
goto aloop;
...
@@ -296,7 +306,7 @@ l1:
...
@@ -296,7 +306,7 @@ l1:
aloop:
aloop:
*cp++ = c;
*cp++ = c;
c = GETC();
c = GETC();
if(
isalpha
(c) || isdigit(c) || c == '_' || c == '$')
if(
ISALPHA
(c) || isdigit(c) || c == '_' || c == '$')
goto aloop;
goto aloop;
*cp = 0;
*cp = 0;
peekc = c;
peekc = c;
...
...
src/cmd/gc/walk.c
View file @
7d11924c
...
@@ -1789,6 +1789,14 @@ badt:
...
@@ -1789,6 +1789,14 @@ badt:
return
nl
;
return
nl
;
}
}
/*
* from ascompat[te]
* evaluating actual function arguments.
* f(a,b)
* if there is exactly one function expr,
* then it is done first. otherwise must
* make temp variables
*/
Node
*
Node
*
reorder1
(
Node
*
n
)
reorder1
(
Node
*
n
)
{
{
...
@@ -1796,15 +1804,6 @@ reorder1(Node *n)
...
@@ -1796,15 +1804,6 @@ reorder1(Node *n)
Node
*
l
,
*
r
,
*
f
,
*
a
,
*
g
;
Node
*
l
,
*
r
,
*
f
,
*
a
,
*
g
;
int
c
,
t
;
int
c
,
t
;
/*
* from ascompat[te]
* evaluating actual function arguments.
* f(a,b)
* if there is exactly one function expr,
* then it is done first. otherwise must
* make temp variables
*/
l
=
listfirst
(
&
save
,
&
n
);
l
=
listfirst
(
&
save
,
&
n
);
c
=
0
;
// function calls
c
=
0
;
// function calls
t
=
0
;
// total parameters
t
=
0
;
// total parameters
...
@@ -1874,6 +1873,13 @@ more:
...
@@ -1874,6 +1873,13 @@ more:
goto
loop2
;
goto
loop2
;
}
}
/*
* from ascompat[et]
* a,b = f()
* return of a multi.
* there can be no function calls at all,
* or they will over-write the return values.
*/
Node
*
Node
*
reorder2
(
Node
*
n
)
reorder2
(
Node
*
n
)
{
{
...
@@ -1881,14 +1887,6 @@ reorder2(Node *n)
...
@@ -1881,14 +1887,6 @@ reorder2(Node *n)
Node
*
l
;
Node
*
l
;
int
c
;
int
c
;
/*
* from ascompat[et]
* a,b = f()
* return of a multi.
* there can be no function calls at all,
* or they will over-write the return values.
*/
l
=
listfirst
(
&
save
,
&
n
);
l
=
listfirst
(
&
save
,
&
n
);
c
=
0
;
c
=
0
;
...
@@ -1907,15 +1905,44 @@ loop1:
...
@@ -1907,15 +1905,44 @@ loop1:
goto
loop1
;
goto
loop1
;
}
}
/*
* from ascompat[ee]
* a,b = c,d
* simultaneous assignment. there can be
* later use of an earlier lvalue.
*/
int
vmatch
(
Node
*
l
,
Node
*
r
)
{
dump
(
"l"
,
l
);
dump
(
"r"
,
r
);
return
0
;
}
Node
*
Node
*
reorder3
(
Node
*
n
)
reorder3
(
Node
*
n
)
{
{
/*
Iter
save1
,
save2
;
* from ascompat[ee]
Node
*
l1
,
*
l2
;
* a,b = c,d
int
c1
,
c2
;
* simultaneous assignment. there can be
* later use of an earlier lvalue.
l1
=
listfirst
(
&
save1
,
&
n
);
*/
c1
=
0
;
while
(
l1
!=
N
)
{
l2
=
listfirst
(
&
save1
,
&
n
);
c2
=
0
;
while
(
l2
!=
N
)
{
if
(
c2
>
c1
)
{
if
(
vmatch
(
l1
->
left
,
l2
->
right
))
{
}
}
l2
=
listnext
(
&
save1
);
c2
++
;
}
l1
=
listnext
(
&
save1
);
c1
++
;
}
return
n
;
return
n
;
}
}
...
...
src/runtime/rt0_amd64_darwin.s
View file @
7d11924c
...
@@ -31,7 +31,7 @@ done:
...
@@ -31,7 +31,7 @@ done:
ADDQ $16, SP
ADDQ $16, SP
CALL check(SB)
CALL check(SB)
CALL main_main(SB)
CALL main_main(SB)
CALL sys
_
exit(SB)
CALL sys
·
exit(SB)
CALL notok(SB)
CALL notok(SB)
POPQ AX
POPQ AX
RET
RET
...
@@ -39,7 +39,7 @@ done:
...
@@ -39,7 +39,7 @@ done:
TEXT FLUSH(SB),1,$-8
TEXT FLUSH(SB),1,$-8
RET
RET
TEXT sys
_
exit(SB),1,$-8
TEXT sys
·
exit(SB),1,$-8
MOVL 8(SP), DI // arg 1 exit status
MOVL 8(SP), DI // arg 1 exit status
MOVL $(0x2000000+1), AX
MOVL $(0x2000000+1), AX
SYSCALL
SYSCALL
...
@@ -47,7 +47,7 @@ TEXT sys_exit(SB),1,$-8
...
@@ -47,7 +47,7 @@ TEXT sys_exit(SB),1,$-8
CALL notok(SB)
CALL notok(SB)
RET
RET
TEXT sys
_
write(SB),1,$-8
TEXT sys
·
write(SB),1,$-8
MOVL 8(SP), DI // arg 1 fid
MOVL 8(SP), DI // arg 1 fid
MOVQ 16(SP), SI // arg 2 buf
MOVQ 16(SP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count
MOVL 24(SP), DX // arg 3 count
...
@@ -57,7 +57,7 @@ TEXT sys_write(SB),1,$-8
...
@@ -57,7 +57,7 @@ TEXT sys_write(SB),1,$-8
CALL notok(SB)
CALL notok(SB)
RET
RET
TEXT sys
_
sigaction(SB),1,$-8
TEXT sys
·
sigaction(SB),1,$-8
MOVL 8(SP), DI // arg 1 sig
MOVL 8(SP), DI // arg 1 sig
MOVQ 16(SP), SI // arg 2 act
MOVQ 16(SP), SI // arg 2 act
MOVQ 24(SP), DX // arg 3 oact
MOVQ 24(SP), DX // arg 3 oact
...
@@ -76,11 +76,11 @@ TEXT sigtramp(SB),1,$24
...
@@ -76,11 +76,11 @@ TEXT sigtramp(SB),1,$24
CALL sighandler(SB)
CALL sighandler(SB)
RET
RET
TEXT sys
_
breakpoint(SB),1,$-8
TEXT sys
·
breakpoint(SB),1,$-8
BYTE $0xcc
BYTE $0xcc
RET
RET
TEXT sys
_
mmap(SB),1,$-8
TEXT sys
·
mmap(SB),1,$-8
MOVQ 8(SP), DI // arg 1 addr
MOVQ 8(SP), DI // arg 1 addr
MOVL 16(SP), SI // arg 2 len
MOVL 16(SP), SI // arg 2 len
MOVL 20(SP), DX // arg 3 prot
MOVL 20(SP), DX // arg 3 prot
...
@@ -98,7 +98,7 @@ TEXT notok(SB),1,$-8
...
@@ -98,7 +98,7 @@ TEXT notok(SB),1,$-8
MOVQ BP, (BP)
MOVQ BP, (BP)
RET
RET
TEXT sys
_
memclr(SB),1,$-8
TEXT sys
·
memclr(SB),1,$-8
MOVQ 8(SP), DI // arg 1 addr
MOVQ 8(SP), DI // arg 1 addr
MOVL 16(SP), CX // arg 2 count
MOVL 16(SP), CX // arg 2 count
ADDL $7, CX
ADDL $7, CX
...
@@ -109,7 +109,7 @@ TEXT sys_memclr(SB),1,$-8
...
@@ -109,7 +109,7 @@ TEXT sys_memclr(SB),1,$-8
STOSQ
STOSQ
RET
RET
TEXT sys
_
getcallerpc+0(SB),0,$0
TEXT sys
·
getcallerpc+0(SB),0,$0
MOVQ x+0(FP),AX
MOVQ x+0(FP),AX
MOVQ -8(AX),AX
MOVQ -8(AX),AX
RET
RET
src/runtime/rt0_amd64_linux.s
View file @
7d11924c
...
@@ -25,8 +25,8 @@ loop:
...
@@ -25,8 +25,8 @@ loop:
done:
done:
ADDQ $8, CX
ADDQ $8, CX
CALL check(SB)
CALL check(SB)
CALL main
_
main(SB)
CALL main
·
main(SB)
CALL sys
_
exit(SB)
CALL sys
·
exit(SB)
CALL notok(SB)
CALL notok(SB)
POPQ AX
POPQ AX
RET
RET
...
@@ -34,7 +34,7 @@ done:
...
@@ -34,7 +34,7 @@ done:
TEXT FLUSH(SB),1,$-8
TEXT FLUSH(SB),1,$-8
RET
RET
TEXT sys
_
exit(SB),1,$-8
TEXT sys
·
exit(SB),1,$-8
MOVL 8(SP), DI
MOVL 8(SP), DI
MOVL $60, AX
MOVL $60, AX
SYSCALL
SYSCALL
...
@@ -42,7 +42,7 @@ TEXT sys_exit(SB),1,$-8
...
@@ -42,7 +42,7 @@ TEXT sys_exit(SB),1,$-8
CALL notok(SB)
CALL notok(SB)
RET
RET
TEXT sys
_
write(SB),1,$-8
TEXT sys
·
write(SB),1,$-8
MOVL 8(SP), DI
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVQ 16(SP), SI
MOVL 24(SP), DX
MOVL 24(SP), DX
...
@@ -52,7 +52,7 @@ TEXT sys_write(SB),1,$-8
...
@@ -52,7 +52,7 @@ TEXT sys_write(SB),1,$-8
CALL notok(SB)
CALL notok(SB)
RET
RET
TEXT sys
_
rt_sigaction(SB),1,$-8
TEXT sys
·
rt_sigaction(SB),1,$-8
MOVL 8(SP), DI
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVQ 16(SP), SI
MOVQ 24(SP), DX
MOVQ 24(SP), DX
...
@@ -64,18 +64,18 @@ TEXT sys_rt_sigaction(SB),1,$-8
...
@@ -64,18 +64,18 @@ TEXT sys_rt_sigaction(SB),1,$-8
CALL notok(SB)
CALL notok(SB)
RET
RET
TEXT
sigtramp(SB),1,$24
TEXT
sigtramp(SB),1,$24
MOVQ DI,0(SP)
MOVQ DI,0(SP)
MOVQ SI,8(SP)
MOVQ SI,8(SP)
MOVQ DX,16(SP)
MOVQ DX,16(SP)
CALL sighandler(SB)
CALL sighandler(SB)
RET
RET
TEXT sys
_
breakpoint(SB),1,$-8
TEXT sys
·
breakpoint(SB),1,$-8
BYTE $0xcc
BYTE $0xcc
RET
RET
TEXT sys
_
mmap(SB),1,$-8
TEXT sys
·
mmap(SB),1,$-8
MOVQ 8(SP), DI
MOVQ 8(SP), DI
MOVL 16(SP), SI
MOVL 16(SP), SI
MOVL 20(SP), DX
MOVL 20(SP), DX
...
@@ -103,7 +103,7 @@ TEXT notok(SB),1,$-8
...
@@ -103,7 +103,7 @@ TEXT notok(SB),1,$-8
MOVQ BP, (BP)
MOVQ BP, (BP)
RET
RET
TEXT sys
_
memclr(SB),1,$-8
TEXT sys
·
memclr(SB),1,$-8
MOVQ 8(SP), DI // arg 1 addr
MOVQ 8(SP), DI // arg 1 addr
MOVL 16(SP), CX // arg 2 count
MOVL 16(SP), CX // arg 2 count
ADDL $7, CX
ADDL $7, CX
...
@@ -114,7 +114,7 @@ TEXT sys_memclr(SB),1,$-8
...
@@ -114,7 +114,7 @@ TEXT sys_memclr(SB),1,$-8
STOSQ
STOSQ
RET
RET
TEXT sys
_
getcallerpc+0(SB),0,$0
TEXT sys
·
getcallerpc+0(SB),0,$0
MOVQ x+0(FP),AX
MOVQ x+0(FP),AX
MOVQ -8(AX),AX
MOVQ -8(AX),AX
RET
RET
src/runtime/rt1_amd64_darwin.c
View file @
7d11924c
...
@@ -39,27 +39,27 @@ _STRUCT_X86_THREAD_STATE64
...
@@ -39,27 +39,27 @@ _STRUCT_X86_THREAD_STATE64
void
void
print_thread_state
(
_STRUCT_X86_THREAD_STATE64
*
ss
)
print_thread_state
(
_STRUCT_X86_THREAD_STATE64
*
ss
)
{
{
prints
(
"
\n
rax 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rax
);
prints
(
"
\n
rax 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rax
);
prints
(
"
\n
rbx 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rbx
);
prints
(
"
\n
rbx 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rbx
);
prints
(
"
\n
rcx 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rcx
);
prints
(
"
\n
rcx 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rcx
);
prints
(
"
\n
rdx 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rdx
);
prints
(
"
\n
rdx 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rdx
);
prints
(
"
\n
rdi 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rdi
);
prints
(
"
\n
rdi 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rdi
);
prints
(
"
\n
rsi 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rsi
);
prints
(
"
\n
rsi 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rsi
);
prints
(
"
\n
rbp 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rbp
);
prints
(
"
\n
rbp 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rbp
);
prints
(
"
\n
rsp 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rsp
);
prints
(
"
\n
rsp 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rsp
);
prints
(
"
\n
r8 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__r8
);
prints
(
"
\n
r8 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__r8
);
prints
(
"
\n
r9 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__r9
);
prints
(
"
\n
r9 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__r9
);
prints
(
"
\n
r10 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__r10
);
prints
(
"
\n
r10 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__r10
);
prints
(
"
\n
r11 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__r11
);
prints
(
"
\n
r11 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__r11
);
prints
(
"
\n
r12 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__r12
);
prints
(
"
\n
r12 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__r12
);
prints
(
"
\n
r13 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__r13
);
prints
(
"
\n
r13 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__r13
);
prints
(
"
\n
r14 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__r14
);
prints
(
"
\n
r14 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__r14
);
prints
(
"
\n
r15 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__r15
);
prints
(
"
\n
r15 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__r15
);
prints
(
"
\n
rip 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rip
);
prints
(
"
\n
rip 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rip
);
prints
(
"
\n
rflags 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rflags
);
prints
(
"
\n
rflags 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rflags
);
prints
(
"
\n
cs 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__cs
);
prints
(
"
\n
cs 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__cs
);
prints
(
"
\n
fs 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__fs
);
prints
(
"
\n
fs 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__fs
);
prints
(
"
\n
gs 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__gs
);
prints
(
"
\n
gs 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__gs
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
}
}
...
@@ -134,7 +134,7 @@ sighandler(int32 sig, siginfo *info, void *context)
...
@@ -134,7 +134,7 @@ sighandler(int32 sig, siginfo *info, void *context)
{
{
if
(
sig
<
0
||
sig
>=
NSIG
){
if
(
sig
<
0
||
sig
>=
NSIG
){
prints
(
"Signal "
);
prints
(
"Signal "
);
sys
_
printint
(
sig
);
sys
·
printint
(
sig
);
}
else
{
}
else
{
prints
(
sigtab
[
sig
].
name
);
prints
(
sigtab
[
sig
].
name
);
}
}
...
@@ -142,14 +142,14 @@ sighandler(int32 sig, siginfo *info, void *context)
...
@@ -142,14 +142,14 @@ sighandler(int32 sig, siginfo *info, void *context)
_STRUCT_MCONTEXT64
*
uc_mcontext
=
get_uc_mcontext
(
context
);
_STRUCT_MCONTEXT64
*
uc_mcontext
=
get_uc_mcontext
(
context
);
_STRUCT_X86_THREAD_STATE64
*
ss
=
get___ss
(
uc_mcontext
);
_STRUCT_X86_THREAD_STATE64
*
ss
=
get___ss
(
uc_mcontext
);
prints
(
"
\n
Faulting address: 0x"
);
sys
_
printpointer
(
info
->
si_addr
);
prints
(
"
\n
Faulting address: 0x"
);
sys
·
printpointer
(
info
->
si_addr
);
prints
(
"
\n
pc: 0x"
);
sys
_
printpointer
((
void
*
)
ss
->
__rip
);
prints
(
"
\n
pc: 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rip
);
prints
(
"
\n\n
"
);
prints
(
"
\n\n
"
);
traceback
((
void
*
)
ss
->
__rip
,
(
void
*
)
ss
->
__rsp
);
traceback
((
void
*
)
ss
->
__rip
,
(
void
*
)
ss
->
__rsp
);
print_thread_state
(
ss
);
print_thread_state
(
ss
);
sys
_
exit
(
2
);
sys
·
exit
(
2
);
}
}
sigaction
a
;
sigaction
a
;
...
@@ -167,6 +167,6 @@ initsig(void)
...
@@ -167,6 +167,6 @@ initsig(void)
for
(
i
=
0
;
i
<
NSIG
;
i
++
)
for
(
i
=
0
;
i
<
NSIG
;
i
++
)
if
(
sigtab
[
i
].
catch
){
if
(
sigtab
[
i
].
catch
){
sys
_
sigaction
(
i
,
&
a
,
(
void
*
)
0
);
sys
·
sigaction
(
i
,
&
a
,
(
void
*
)
0
);
}
}
}
}
src/runtime/rt1_amd64_linux.c
View file @
7d11924c
...
@@ -40,20 +40,20 @@ sighandler(int32 sig, siginfo* info, void** context) {
...
@@ -40,20 +40,20 @@ sighandler(int32 sig, siginfo* info, void** context) {
if
(
sig
<
0
||
sig
>=
NSIG
){
if
(
sig
<
0
||
sig
>=
NSIG
){
prints
(
"Signal "
);
prints
(
"Signal "
);
sys
_
printint
(
sig
);
sys
·
printint
(
sig
);
}
else
{
}
else
{
prints
(
sigtab
[
sig
].
name
);
prints
(
sigtab
[
sig
].
name
);
}
}
prints
(
"
\n
Faulting address: 0x"
);
prints
(
"
\n
Faulting address: 0x"
);
sys
_
printpointer
(
info
->
si_addr
);
sys
·
printpointer
(
info
->
si_addr
);
prints
(
"
\n
PC: 0x"
);
prints
(
"
\n
PC: 0x"
);
sys
_
printpointer
(
context
[
21
]);
sys
·
printpointer
(
context
[
21
]);
prints
(
"
\n
SP: 0x"
);
prints
(
"
\n
SP: 0x"
);
sys
_
printpointer
(
context
[
20
]);
sys
·
printpointer
(
context
[
20
]);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
traceback
(
context
[
21
],
context
[
20
]);
/* empirically discovered locations */
traceback
(
context
[
21
],
context
[
20
]);
/* empirically discovered locations */
sys
_
breakpoint
();
sys
·
breakpoint
();
sys
_
exit
(
2
);
sys
·
exit
(
2
);
}
}
sigaction
a
;
sigaction
a
;
...
@@ -69,6 +69,6 @@ initsig(void)
...
@@ -69,6 +69,6 @@ initsig(void)
for
(
i
=
0
;
i
<
NSIG
;
i
++
)
for
(
i
=
0
;
i
<
NSIG
;
i
++
)
if
(
sigtab
[
i
].
catch
){
if
(
sigtab
[
i
].
catch
){
sys
_
rt_sigaction
(
i
,
&
a
,
(
void
*
)
0
,
8
);
sys
·
rt_sigaction
(
i
,
&
a
,
(
void
*
)
0
,
8
);
}
}
}
}
src/runtime/rt2_amd64.c
View file @
7d11924c
...
@@ -22,7 +22,7 @@ traceback(uint8 *pc, uint8 *sp)
...
@@ -22,7 +22,7 @@ traceback(uint8 *pc, uint8 *sp)
name
=
"panic"
;
name
=
"panic"
;
for
(;;){
for
(;;){
prints
(
"0x"
);
prints
(
"0x"
);
sys
_
printpointer
(
pc
);
sys
·
printpointer
(
pc
);
prints
(
"?zi
\n
"
);
prints
(
"?zi
\n
"
);
/* find SP offset by stepping back through instructions to SP offset marker */
/* find SP offset by stepping back through instructions to SP offset marker */
while
(
pc
>
(
uint8
*
)
0x1000
+
sizeof
spmark
-
1
)
{
while
(
pc
>
(
uint8
*
)
0x1000
+
sizeof
spmark
-
1
)
{
...
@@ -50,7 +50,7 @@ traceback(uint8 *pc, uint8 *sp)
...
@@ -50,7 +50,7 @@ traceback(uint8 *pc, uint8 *sp)
for
(
i
=
0
;
i
<
3
;
i
++
){
for
(
i
=
0
;
i
<
3
;
i
++
){
if
(
i
!=
0
)
if
(
i
!=
0
)
prints
(
", "
);
prints
(
", "
);
sys
_
printint
(((
uint32
*
)
sp
)[
i
]);
sys
·
printint
(((
uint32
*
)
sp
)[
i
]);
}
}
prints
(
", ...)
\n
"
);
prints
(
", ...)
\n
"
);
prints
(
"
\t
"
);
prints
(
"
\t
"
);
...
@@ -60,7 +60,7 @@ traceback(uint8 *pc, uint8 *sp)
...
@@ -60,7 +60,7 @@ traceback(uint8 *pc, uint8 *sp)
if
(
i
!=
0
)
if
(
i
!=
0
)
prints
(
", "
);
prints
(
", "
);
prints
(
"0x"
);
prints
(
"0x"
);
sys
_
printpointer
(((
void
**
)
sp
)[
i
]);
sys
·
printpointer
(((
void
**
)
sp
)[
i
]);
}
}
prints
(
", ...)
\n
"
);
prints
(
", ...)
\n
"
);
/* print pc for next frame */
/* print pc for next frame */
...
...
src/runtime/runtime.c
View file @
7d11924c
...
@@ -10,23 +10,23 @@ static int32 empty = 0;
...
@@ -10,23 +10,23 @@ static int32 empty = 0;
static
string
emptystring
=
(
string
)
&
empty
;
static
string
emptystring
=
(
string
)
&
empty
;
void
void
sys
_
printbool
(
bool
v
)
sys
·
printbool
(
bool
v
)
{
{
if
(
v
)
{
if
(
v
)
{
sys
_
write
(
1
,
(
byte
*
)
"true"
,
4
);
sys
·
write
(
1
,
(
byte
*
)
"true"
,
4
);
return
;
return
;
}
}
sys
_
write
(
1
,
(
byte
*
)
"false"
,
5
);
sys
·
write
(
1
,
(
byte
*
)
"false"
,
5
);
}
}
void
void
sys
_
printfloat
(
float64
v
)
sys
·
printfloat
(
float64
v
)
{
{
sys
_
write
(
1
,
"printfloat"
,
10
);
sys
·
write
(
1
,
"printfloat"
,
10
);
}
}
void
void
sys
_
printint
(
int64
v
)
sys
·
printint
(
int64
v
)
{
{
byte
buf
[
100
];
byte
buf
[
100
];
int32
i
,
s
;
int32
i
,
s
;
...
@@ -36,7 +36,7 @@ sys_printint(int64 v)
...
@@ -36,7 +36,7 @@ sys_printint(int64 v)
v
=
-
v
;
v
=
-
v
;
s
=
1
;
s
=
1
;
if
(
v
<
0
)
{
if
(
v
<
0
)
{
sys
_
write
(
1
,
(
byte
*
)
"-oo"
,
3
);
sys
·
write
(
1
,
(
byte
*
)
"-oo"
,
3
);
return
;
return
;
}
}
}
}
...
@@ -51,11 +51,11 @@ sys_printint(int64 v)
...
@@ -51,11 +51,11 @@ sys_printint(int64 v)
i
--
;
i
--
;
buf
[
i
]
=
'-'
;
buf
[
i
]
=
'-'
;
}
}
sys
_
write
(
1
,
buf
+
i
,
nelem
(
buf
)
-
i
);
sys
·
write
(
1
,
buf
+
i
,
nelem
(
buf
)
-
i
);
}
}
void
void
sys
_
printpointer
(
void
*
p
)
sys
·
printpointer
(
void
*
p
)
{
{
uint64
v
;
uint64
v
;
byte
buf
[
100
];
byte
buf
[
100
];
...
@@ -70,14 +70,14 @@ sys_printpointer(void *p)
...
@@ -70,14 +70,14 @@ sys_printpointer(void *p)
break
;
break
;
v
=
v
/
16
;
v
=
v
/
16
;
}
}
sys
_
write
(
1
,
buf
+
i
,
nelem
(
buf
)
-
i
);
sys
·
write
(
1
,
buf
+
i
,
nelem
(
buf
)
-
i
);
}
}
void
void
sys
_
printstring
(
string
v
)
sys
·
printstring
(
string
v
)
{
{
if
(
v
!=
nil
)
if
(
v
!=
nil
)
sys
_
write
(
1
,
v
->
str
,
v
->
len
);
sys
·
write
(
1
,
v
->
str
,
v
->
len
);
}
}
int32
int32
...
@@ -93,31 +93,31 @@ findnull(int8 *s)
...
@@ -93,31 +93,31 @@ findnull(int8 *s)
void
void
prints
(
int8
*
s
)
prints
(
int8
*
s
)
{
{
sys
_
write
(
1
,
s
,
findnull
(
s
));
sys
·
write
(
1
,
s
,
findnull
(
s
));
}
}
void
void
sys
_
printpc
(
void
*
p
)
sys
·
printpc
(
void
*
p
)
{
{
prints
(
"PC=0x"
);
prints
(
"PC=0x"
);
sys
_printpointer
(
sys_
getcallerpc
(
p
));
sys
·
printpointer
(
sys
·
getcallerpc
(
p
));
}
}
/*BUG: move traceback code to architecture-dependent runtime */
/*BUG: move traceback code to architecture-dependent runtime */
void
void
sys
_
panicl
(
int32
lno
)
sys
·
panicl
(
int32
lno
)
{
{
uint8
*
sp
;
uint8
*
sp
;
prints
(
"
\n
panic on line "
);
prints
(
"
\n
panic on line "
);
sys
_
printint
(
lno
);
sys
·
printint
(
lno
);
prints
(
" "
);
prints
(
" "
);
sys
_
printpc
(
&
lno
);
sys
·
printpc
(
&
lno
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
sp
=
(
uint8
*
)
&
lno
;
sp
=
(
uint8
*
)
&
lno
;
traceback
(
sys
_
getcallerpc
(
&
lno
),
sp
);
traceback
(
sys
·
getcallerpc
(
&
lno
),
sp
);
sys
_
breakpoint
();
sys
·
breakpoint
();
sys
_
exit
(
2
);
sys
·
exit
(
2
);
}
}
dump
(
byte
*
p
,
int32
n
)
dump
(
byte
*
p
,
int32
n
)
...
@@ -126,8 +126,8 @@ dump(byte *p, int32 n)
...
@@ -126,8 +126,8 @@ dump(byte *p, int32 n)
int32
i
;
int32
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
sys
_
printpointer
((
byte
*
)(
p
[
i
]
>>
4
));
sys
·
printpointer
((
byte
*
)(
p
[
i
]
>>
4
));
sys
_
printpointer
((
byte
*
)(
p
[
i
]
&
0xf
));
sys
·
printpointer
((
byte
*
)(
p
[
i
]
&
0xf
));
if
((
i
&
15
)
==
15
)
if
((
i
&
15
)
==
15
)
prints
(
"
\n
"
);
prints
(
"
\n
"
);
else
else
...
@@ -163,7 +163,8 @@ throw(int8 *s)
...
@@ -163,7 +163,8 @@ throw(int8 *s)
prints
(
"throw: "
);
prints
(
"throw: "
);
prints
(
s
);
prints
(
s
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
sys_exit
(
1
);
*
(
int32
*
)
0
=
0
;
sys
·
exit
(
1
);
}
}
void
void
...
@@ -182,8 +183,8 @@ brk(uint32 n)
...
@@ -182,8 +183,8 @@ brk(uint32 n)
{
{
byte
*
v
;
byte
*
v
;
v
=
sys
_
mmap
(
nil
,
NHUNK
,
PROT_READ
|
PROT_WRITE
,
MAP_ANON
|
MAP_PRIVATE
,
0
,
0
);
v
=
sys
·
mmap
(
nil
,
NHUNK
,
PROT_READ
|
PROT_WRITE
,
MAP_ANON
|
MAP_PRIVATE
,
0
,
0
);
sys
_
memclr
(
v
,
n
);
sys
·
memclr
(
v
,
n
);
nmmap
+=
n
;
nmmap
+=
n
;
return
v
;
return
v
;
}
}
...
@@ -248,14 +249,14 @@ cmpstring(string s1, string s2)
...
@@ -248,14 +249,14 @@ cmpstring(string s1, string s2)
}
}
void
void
sys
_
mal
(
uint32
n
,
uint8
*
ret
)
sys
·
mal
(
uint32
n
,
uint8
*
ret
)
{
{
ret
=
mal
(
n
);
ret
=
mal
(
n
);
FLUSH
(
&
ret
);
FLUSH
(
&
ret
);
}
}
void
void
sys
_
catstring
(
string
s1
,
string
s2
,
string
s3
)
sys
·
catstring
(
string
s1
,
string
s2
,
string
s3
)
{
{
uint32
l
;
uint32
l
;
...
@@ -280,7 +281,7 @@ out:
...
@@ -280,7 +281,7 @@ out:
}
}
void
void
sys
_
cmpstring
(
string
s1
,
string
s2
,
int32
v
)
sys
·
cmpstring
(
string
s1
,
string
s2
,
int32
v
)
{
{
v
=
cmpstring
(
s1
,
s2
);
v
=
cmpstring
(
s1
,
s2
);
FLUSH
(
&
v
);
FLUSH
(
&
v
);
...
@@ -311,17 +312,17 @@ prbounds(int8* s, int32 a, int32 b, int32 c)
...
@@ -311,17 +312,17 @@ prbounds(int8* s, int32 a, int32 b, int32 c)
prints
(
s
);
prints
(
s
);
prints
(
" "
);
prints
(
" "
);
sys
_
printint
(
a
);
sys
·
printint
(
a
);
prints
(
"<"
);
prints
(
"<"
);
sys
_
printint
(
b
);
sys
·
printint
(
b
);
prints
(
">"
);
prints
(
">"
);
sys
_
printint
(
c
);
sys
·
printint
(
c
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
throw
(
"bounds"
);
throw
(
"bounds"
);
}
}
void
void
sys
_
slicestring
(
string
si
,
int32
lindex
,
int32
hindex
,
string
so
)
sys
·
slicestring
(
string
si
,
int32
lindex
,
int32
hindex
,
string
so
)
{
{
string
s
,
str
;
string
s
,
str
;
int32
l
;
int32
l
;
...
@@ -331,7 +332,7 @@ sys_slicestring(string si, int32 lindex, int32 hindex, string so)
...
@@ -331,7 +332,7 @@ sys_slicestring(string si, int32 lindex, int32 hindex, string so)
if
(
lindex
<
0
||
lindex
>
si
->
len
||
if
(
lindex
<
0
||
lindex
>
si
->
len
||
hindex
<
lindex
||
hindex
>
si
->
len
)
{
hindex
<
lindex
||
hindex
>
si
->
len
)
{
sys
_
printpc
(
&
si
);
sys
·
printpc
(
&
si
);
prints
(
" "
);
prints
(
" "
);
prbounds
(
"slice"
,
lindex
,
si
->
len
,
hindex
);
prbounds
(
"slice"
,
lindex
,
si
->
len
,
hindex
);
}
}
...
@@ -344,13 +345,13 @@ sys_slicestring(string si, int32 lindex, int32 hindex, string so)
...
@@ -344,13 +345,13 @@ sys_slicestring(string si, int32 lindex, int32 hindex, string so)
}
}
void
void
sys
_
indexstring
(
string
s
,
int32
i
,
byte
b
)
sys
·
indexstring
(
string
s
,
int32
i
,
byte
b
)
{
{
if
(
s
==
nil
)
if
(
s
==
nil
)
s
=
emptystring
;
s
=
emptystring
;
if
(
i
<
0
||
i
>=
s
->
len
)
{
if
(
i
<
0
||
i
>=
s
->
len
)
{
sys
_
printpc
(
&
s
);
sys
·
printpc
(
&
s
);
prints
(
" "
);
prints
(
" "
);
prbounds
(
"index"
,
0
,
i
,
s
->
len
);
prbounds
(
"index"
,
0
,
i
,
s
->
len
);
}
}
...
@@ -409,7 +410,7 @@ runetochar(byte *str, uint32 c)
...
@@ -409,7 +410,7 @@ runetochar(byte *str, uint32 c)
}
}
void
void
sys
_
intstring
(
int64
v
,
string
s
)
sys
·
intstring
(
int64
v
,
string
s
)
{
{
int32
l
;
int32
l
;
...
@@ -419,7 +420,7 @@ sys_intstring(int64 v, string s)
...
@@ -419,7 +420,7 @@ sys_intstring(int64 v, string s)
}
}
void
void
sys
_
byteastring
(
byte
*
a
,
int32
l
,
string
s
)
sys
·
byteastring
(
byte
*
a
,
int32
l
,
string
s
)
{
{
s
=
mal
(
sizeof
(
s
->
len
)
+
l
);
s
=
mal
(
sizeof
(
s
->
len
)
+
l
);
s
->
len
=
l
;
s
->
len
=
l
;
...
@@ -494,16 +495,16 @@ loop2:
...
@@ -494,16 +495,16 @@ loop2:
}
}
void
void
sys
_
ifaces2i
(
Sigi
*
si
,
Sigs
*
ss
,
Map
*
m
,
void
*
s
)
sys
·
ifaces2i
(
Sigi
*
si
,
Sigs
*
ss
,
Map
*
m
,
void
*
s
)
{
{
if
(
debug
)
{
if
(
debug
)
{
prints
(
"s2i sigi="
);
prints
(
"s2i sigi="
);
sys
_
printpointer
(
si
);
sys
·
printpointer
(
si
);
prints
(
" sigs="
);
prints
(
" sigs="
);
sys
_
printpointer
(
ss
);
sys
·
printpointer
(
ss
);
prints
(
" s="
);
prints
(
" s="
);
sys
_
printpointer
(
s
);
sys
·
printpointer
(
s
);
}
}
if
(
s
==
nil
)
{
if
(
s
==
nil
)
{
...
@@ -517,9 +518,9 @@ sys_ifaces2i(Sigi *si, Sigs *ss, Map *m, void *s)
...
@@ -517,9 +518,9 @@ sys_ifaces2i(Sigi *si, Sigs *ss, Map *m, void *s)
if
(
debug
)
{
if
(
debug
)
{
prints
(
" returning m="
);
prints
(
" returning m="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
" s="
);
prints
(
" s="
);
sys
_
printpointer
(
s
);
sys
·
printpointer
(
s
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
dump
((
byte
*
)
m
,
64
);
dump
((
byte
*
)
m
,
64
);
}
}
...
@@ -528,16 +529,16 @@ sys_ifaces2i(Sigi *si, Sigs *ss, Map *m, void *s)
...
@@ -528,16 +529,16 @@ sys_ifaces2i(Sigi *si, Sigs *ss, Map *m, void *s)
}
}
void
void
sys
_
ifacei2i
(
Sigi
*
si
,
Map
*
m
,
void
*
s
)
sys
·
ifacei2i
(
Sigi
*
si
,
Map
*
m
,
void
*
s
)
{
{
if
(
debug
)
{
if
(
debug
)
{
prints
(
"i2i sigi="
);
prints
(
"i2i sigi="
);
sys
_
printpointer
(
si
);
sys
·
printpointer
(
si
);
prints
(
" m="
);
prints
(
" m="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
" s="
);
prints
(
" s="
);
sys
_
printpointer
(
s
);
sys
·
printpointer
(
s
);
}
}
if
(
m
==
nil
)
{
if
(
m
==
nil
)
{
...
@@ -559,23 +560,23 @@ sys_ifacei2i(Sigi *si, Map *m, void *s)
...
@@ -559,23 +560,23 @@ sys_ifacei2i(Sigi *si, Map *m, void *s)
if
(
debug
)
{
if
(
debug
)
{
prints
(
" returning m="
);
prints
(
" returning m="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
" s="
);
prints
(
" s="
);
sys
_
printpointer
(
s
);
sys
·
printpointer
(
s
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
dump
((
byte
*
)
m
,
64
);
dump
((
byte
*
)
m
,
64
);
}
}
}
}
void
void
sys
_
ifacei2s
(
Sigs
*
ss
,
Map
*
m
,
void
*
s
)
sys
·
ifacei2s
(
Sigs
*
ss
,
Map
*
m
,
void
*
s
)
{
{
if
(
debug
)
{
if
(
debug
)
{
prints
(
"i2s m="
);
prints
(
"i2s m="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
" s="
);
prints
(
" s="
);
sys
_
printpointer
(
s
);
sys
·
printpointer
(
s
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
}
}
...
@@ -727,7 +728,7 @@ modf(float64 d, float64 *ip)
...
@@ -727,7 +728,7 @@ modf(float64 d, float64 *ip)
// func frexp(float64) (int32, float64); // break fp into exp,fract
// func frexp(float64) (int32, float64); // break fp into exp,fract
void
void
sys
_
frexp
(
float64
din
,
int32
iou
,
float64
dou
)
sys
·
frexp
(
float64
din
,
int32
iou
,
float64
dou
)
{
{
dou
=
frexp
(
din
,
&
iou
);
dou
=
frexp
(
din
,
&
iou
);
FLUSH
(
&
dou
);
FLUSH
(
&
dou
);
...
@@ -735,7 +736,7 @@ sys_frexp(float64 din, int32 iou, float64 dou)
...
@@ -735,7 +736,7 @@ sys_frexp(float64 din, int32 iou, float64 dou)
//func ldexp(int32, float64) float64; // make fp from exp,fract
//func ldexp(int32, float64) float64; // make fp from exp,fract
void
void
sys
_
ldexp
(
float64
din
,
int32
ein
,
float64
dou
)
sys
·
ldexp
(
float64
din
,
int32
ein
,
float64
dou
)
{
{
dou
=
ldexp
(
din
,
ein
);
dou
=
ldexp
(
din
,
ein
);
FLUSH
(
&
dou
);
FLUSH
(
&
dou
);
...
@@ -743,7 +744,7 @@ sys_ldexp(float64 din, int32 ein, float64 dou)
...
@@ -743,7 +744,7 @@ sys_ldexp(float64 din, int32 ein, float64 dou)
//func modf(float64) (float64, float64); // break fp into double+double
//func modf(float64) (float64, float64); // break fp into double+double
float64
float64
sys
_
modf
(
float64
din
,
float64
dou1
,
float64
dou2
)
sys
·
modf
(
float64
din
,
float64
dou1
,
float64
dou2
)
{
{
dou1
=
modf
(
din
,
&
dou2
);
dou1
=
modf
(
din
,
&
dou2
);
FLUSH
(
&
dou2
);
FLUSH
(
&
dou2
);
...
@@ -854,7 +855,7 @@ memprint(uint32 s, void *a)
...
@@ -854,7 +855,7 @@ memprint(uint32 s, void *a)
v
=
*
(
uint64
*
)
a
;
v
=
*
(
uint64
*
)
a
;
break
;
break
;
}
}
sys
_
printint
(
v
);
sys
·
printint
(
v
);
}
}
static
void
static
void
...
@@ -890,7 +891,7 @@ stringequal(uint32 s, string *a, string *b)
...
@@ -890,7 +891,7 @@ stringequal(uint32 s, string *a, string *b)
static
void
static
void
stringprint
(
uint32
s
,
string
*
a
)
stringprint
(
uint32
s
,
string
*
a
)
{
{
sys
_
printstring
(
*
a
);
sys
·
printstring
(
*
a
);
}
}
static
void
static
void
...
@@ -925,7 +926,7 @@ algarray[] =
...
@@ -925,7 +926,7 @@ algarray[] =
// keyalg uint32, valalg uint32,
// keyalg uint32, valalg uint32,
// hint uint32) (hmap *map[any]any);
// hint uint32) (hmap *map[any]any);
void
void
sys
_
newmap
(
uint32
keysize
,
uint32
valsize
,
sys
·
newmap
(
uint32
keysize
,
uint32
valsize
,
uint32
keyalg
,
uint32
valalg
,
uint32
hint
,
uint32
keyalg
,
uint32
valalg
,
uint32
hint
,
Hmap
*
ret
)
Hmap
*
ret
)
{
{
...
@@ -934,16 +935,16 @@ sys_newmap(uint32 keysize, uint32 valsize,
...
@@ -934,16 +935,16 @@ sys_newmap(uint32 keysize, uint32 valsize,
if
(
keyalg
>=
nelem
(
algarray
)
||
if
(
keyalg
>=
nelem
(
algarray
)
||
valalg
>=
nelem
(
algarray
))
{
valalg
>=
nelem
(
algarray
))
{
prints
(
"0<="
);
prints
(
"0<="
);
sys
_
printint
(
keyalg
);
sys
·
printint
(
keyalg
);
prints
(
"<"
);
prints
(
"<"
);
sys
_
printint
(
nelem
(
algarray
));
sys
·
printint
(
nelem
(
algarray
));
prints
(
"
\n
0<="
);
prints
(
"
\n
0<="
);
sys
_
printint
(
valalg
);
sys
·
printint
(
valalg
);
prints
(
"<"
);
prints
(
"<"
);
sys
_
printint
(
nelem
(
algarray
));
sys
·
printint
(
nelem
(
algarray
));
prints
(
"
\n
"
);
prints
(
"
\n
"
);
throw
(
"sys
_
newmap: key/val algorithm out of range"
);
throw
(
"sys
·
newmap: key/val algorithm out of range"
);
}
}
m
=
mal
(
sizeof
(
*
m
));
m
=
mal
(
sizeof
(
*
m
));
...
@@ -966,30 +967,30 @@ sys_newmap(uint32 keysize, uint32 valsize,
...
@@ -966,30 +967,30 @@ sys_newmap(uint32 keysize, uint32 valsize,
if
(
debug
)
{
if
(
debug
)
{
prints
(
"newmap: map="
);
prints
(
"newmap: map="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
"; keysize="
);
prints
(
"; keysize="
);
sys
_
printint
(
keysize
);
sys
·
printint
(
keysize
);
prints
(
"; valsize="
);
prints
(
"; valsize="
);
sys
_
printint
(
valsize
);
sys
·
printint
(
valsize
);
prints
(
"; keyalg="
);
prints
(
"; keyalg="
);
sys
_
printint
(
keyalg
);
sys
·
printint
(
keyalg
);
prints
(
"; valalg="
);
prints
(
"; valalg="
);
sys
_
printint
(
valalg
);
sys
·
printint
(
valalg
);
prints
(
"; valoffset="
);
prints
(
"; valoffset="
);
sys
_
printint
(
m
->
valoffset
);
sys
·
printint
(
m
->
valoffset
);
prints
(
"; ko="
);
prints
(
"; ko="
);
sys
_
printint
(
m
->
ko
);
sys
·
printint
(
m
->
ko
);
prints
(
"; vo="
);
prints
(
"; vo="
);
sys
_
printint
(
m
->
vo
);
sys
·
printint
(
m
->
vo
);
prints
(
"; po="
);
prints
(
"; po="
);
sys
_
printint
(
m
->
po
);
sys
·
printint
(
m
->
po
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
}
}
}
}
// mapaccess1(hmap *map[any]any, key any) (val any);
// mapaccess1(hmap *map[any]any, key any) (val any);
void
void
sys
_
mapaccess1
(
Hmap
*
m
,
...)
sys
·
mapaccess1
(
Hmap
*
m
,
...)
{
{
Link
*
l
;
Link
*
l
;
byte
*
ak
,
*
av
;
byte
*
ak
,
*
av
;
...
@@ -1008,8 +1009,8 @@ sys_mapaccess1(Hmap *m, ...)
...
@@ -1008,8 +1009,8 @@ sys_mapaccess1(Hmap *m, ...)
out
:
out
:
if
(
debug
)
{
if
(
debug
)
{
prints
(
"sys
_
mapaccess1: map="
);
prints
(
"sys
·
mapaccess1: map="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
"; key="
);
prints
(
"; key="
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
prints
(
"; val="
);
prints
(
"; val="
);
...
@@ -1020,7 +1021,7 @@ out:
...
@@ -1020,7 +1021,7 @@ out:
// mapaccess2(hmap *map[any]any, key any) (val any, pres bool);
// mapaccess2(hmap *map[any]any, key any) (val any, pres bool);
void
void
sys
_
mapaccess2
(
Hmap
*
m
,
...)
sys
·
mapaccess2
(
Hmap
*
m
,
...)
{
{
Link
*
l
;
Link
*
l
;
byte
*
ak
,
*
av
,
*
ap
;
byte
*
ak
,
*
av
,
*
ap
;
...
@@ -1042,20 +1043,20 @@ sys_mapaccess2(Hmap *m, ...)
...
@@ -1042,20 +1043,20 @@ sys_mapaccess2(Hmap *m, ...)
out
:
out
:
if
(
debug
)
{
if
(
debug
)
{
prints
(
"sys
_
mapaccess2: map="
);
prints
(
"sys
·
mapaccess2: map="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
"; key="
);
prints
(
"; key="
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
prints
(
"; val="
);
prints
(
"; val="
);
m
->
valalg
->
print
(
m
->
valsize
,
av
);
m
->
valalg
->
print
(
m
->
valsize
,
av
);
prints
(
"; pres="
);
prints
(
"; pres="
);
sys
_
printbool
(
*
ap
);
sys
·
printbool
(
*
ap
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
}
}
}
}
static
void
static
void
sys
_
mapassign
(
Hmap
*
m
,
byte
*
ak
,
byte
*
av
)
sys
·
mapassign
(
Hmap
*
m
,
byte
*
ak
,
byte
*
av
)
{
{
Link
*
l
;
Link
*
l
;
...
@@ -1077,7 +1078,7 @@ out:
...
@@ -1077,7 +1078,7 @@ out:
if
(
debug
)
{
if
(
debug
)
{
prints
(
"mapassign: map="
);
prints
(
"mapassign: map="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
"; key="
);
prints
(
"; key="
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
prints
(
"; val="
);
prints
(
"; val="
);
...
@@ -1088,7 +1089,7 @@ out:
...
@@ -1088,7 +1089,7 @@ out:
// mapassign1(hmap *map[any]any, key any, val any);
// mapassign1(hmap *map[any]any, key any, val any);
void
void
sys
_
mapassign1
(
Hmap
*
m
,
...)
sys
·
mapassign1
(
Hmap
*
m
,
...)
{
{
Link
**
ll
;
Link
**
ll
;
byte
*
ak
,
*
av
;
byte
*
ak
,
*
av
;
...
@@ -1096,12 +1097,12 @@ sys_mapassign1(Hmap *m, ...)
...
@@ -1096,12 +1097,12 @@ sys_mapassign1(Hmap *m, ...)
ak
=
(
byte
*
)
&
m
+
m
->
ko
;
ak
=
(
byte
*
)
&
m
+
m
->
ko
;
av
=
(
byte
*
)
&
m
+
m
->
vo
;
av
=
(
byte
*
)
&
m
+
m
->
vo
;
sys
_
mapassign
(
m
,
ak
,
av
);
sys
·
mapassign
(
m
,
ak
,
av
);
}
}
// mapassign2(hmap *map[any]any, key any, val any, pres bool);
// mapassign2(hmap *map[any]any, key any, val any, pres bool);
void
void
sys
_
mapassign2
(
Hmap
*
m
,
...)
sys
·
mapassign2
(
Hmap
*
m
,
...)
{
{
Link
**
ll
;
Link
**
ll
;
byte
*
ak
,
*
av
,
*
ap
;
byte
*
ak
,
*
av
,
*
ap
;
...
@@ -1112,7 +1113,7 @@ sys_mapassign2(Hmap *m, ...)
...
@@ -1112,7 +1113,7 @@ sys_mapassign2(Hmap *m, ...)
if
(
*
ap
==
true
)
{
if
(
*
ap
==
true
)
{
// assign
// assign
sys
_
mapassign
(
m
,
ak
,
av
);
sys
·
mapassign
(
m
,
ak
,
av
);
return
;
return
;
}
}
...
@@ -1124,7 +1125,7 @@ sys_mapassign2(Hmap *m, ...)
...
@@ -1124,7 +1125,7 @@ sys_mapassign2(Hmap *m, ...)
m
->
len
--
;
m
->
len
--
;
if
(
debug
)
{
if
(
debug
)
{
prints
(
"mapdelete (found): map="
);
prints
(
"mapdelete (found): map="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
"; key="
);
prints
(
"; key="
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
prints
(
"
\n
"
);
prints
(
"
\n
"
);
...
@@ -1135,7 +1136,7 @@ sys_mapassign2(Hmap *m, ...)
...
@@ -1135,7 +1136,7 @@ sys_mapassign2(Hmap *m, ...)
if
(
debug
)
{
if
(
debug
)
{
prints
(
"mapdelete (not found): map="
);
prints
(
"mapdelete (not found): map="
);
sys
_
printpointer
(
m
);
sys
·
printpointer
(
m
);
prints
(
"; key="
);
prints
(
"; key="
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
m
->
keyalg
->
print
(
m
->
keysize
,
ak
);
prints
(
" *** not found
\n
"
);
prints
(
" *** not found
\n
"
);
...
...
src/runtime/runtime.h
View file @
7d11924c
...
@@ -90,7 +90,8 @@ void* mal(uint32);
...
@@ -90,7 +90,8 @@ void* mal(uint32);
uint32
cmpstring
(
string
,
string
);
uint32
cmpstring
(
string
,
string
);
void
initsig
(
void
);
void
initsig
(
void
);
void
traceback
(
uint8
*
pc
,
uint8
*
sp
);
void
traceback
(
uint8
*
pc
,
uint8
*
sp
);
struct
SigTab
{
struct
SigTab
{
int32
catch
;
int32
catch
;
int8
*
name
;
int8
*
name
;
};
};
...
@@ -98,28 +99,28 @@ struct SigTab {
...
@@ -98,28 +99,28 @@ struct SigTab {
/*
/*
* low level go -called
* low level go -called
*/
*/
void
sys
_
exit
(
int32
);
void
sys
·
exit
(
int32
);
void
sys
_
write
(
int32
,
void
*
,
int32
);
void
sys
·
write
(
int32
,
void
*
,
int32
);
void
sys
_
breakpoint
(
void
);
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
_
getcallerpc
(
void
*
);
void
*
sys
·
getcallerpc
(
void
*
);
void
sys
_
sigaction
(
int64
,
void
*
,
void
*
);
void
sys
·
sigaction
(
int64
,
void
*
,
void
*
);
void
sys
_
rt_sigaction
(
int64
,
void
*
,
void
*
,
uint64
);
void
sys
·
rt_sigaction
(
int64
,
void
*
,
void
*
,
uint64
);
/*
/*
* runtime go-called
* runtime go-called
*/
*/
void
sys
_
printbool
(
bool
);
void
sys
·
printbool
(
bool
);
void
sys
_
printfloat
(
float64
);
void
sys
·
printfloat
(
float64
);
void
sys
_
printint
(
int64
);
void
sys
·
printint
(
int64
);
void
sys
_
printstring
(
string
);
void
sys
·
printstring
(
string
);
void
sys
_
printpointer
(
void
*
);
void
sys
·
printpointer
(
void
*
);
void
sys
_
catstring
(
string
,
string
,
string
);
void
sys
·
catstring
(
string
,
string
,
string
);
void
sys
_
cmpstring
(
string
,
string
,
int32
);
void
sys
·
cmpstring
(
string
,
string
,
int32
);
void
sys
_
slicestring
(
string
,
int32
,
int32
,
string
);
void
sys
·
slicestring
(
string
,
int32
,
int32
,
string
);
void
sys
_
indexstring
(
string
,
int32
,
byte
);
void
sys
·
indexstring
(
string
,
int32
,
byte
);
void
sys
_
intstring
(
int64
,
string
);
void
sys
·
intstring
(
int64
,
string
);
void
sys
_
ifaces2i
(
Sigi
*
,
Sigs
*
,
Map
*
,
void
*
);
void
sys
·
ifaces2i
(
Sigi
*
,
Sigs
*
,
Map
*
,
void
*
);
void
sys
_
ifacei2i
(
Sigi
*
,
Map
*
,
void
*
);
void
sys
·
ifacei2i
(
Sigi
*
,
Map
*
,
void
*
);
void
sys
_
ifacei2s
(
Sigs
*
,
Map
*
,
void
*
);
void
sys
·
ifacei2s
(
Sigs
*
,
Map
*
,
void
*
);
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