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
1e774d9e
Commit
1e774d9e
authored
Jun 24, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
put center dot into main_main
restore smashed arg code, lost in incorrect resolve SVN=124432
parent
7d11924c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
1 deletion
+77
-1
src/runtime/rt0_amd64_darwin.s
src/runtime/rt0_amd64_darwin.s
+1
-1
src/runtime/runtime.c
src/runtime/runtime.c
+76
-0
No files found.
src/runtime/rt0_amd64_darwin.s
View file @
1e774d9e
...
...
@@ -30,7 +30,7 @@ done:
CALL
args
(
SB
)
ADDQ
$
16
,
SP
CALL
check
(
SB
)
CALL
main
_
main
(
SB
)
CALL
main
·
main
(
SB
)
CALL
sys
·
exit
(
SB
)
CALL
notok
(
SB
)
POPQ
AX
...
...
src/runtime/runtime.c
View file @
1e774d9e
...
...
@@ -750,6 +750,82 @@ sys·modf(float64 din, float64 dou1, float64 dou2)
FLUSH
(
&
dou2
);
}
static
int32
argc
;
static
uint8
**
argv
;
static
int32
envc
;
static
uint8
**
envv
;
void
args
(
int32
c
,
uint8
**
v
)
{
argc
=
c
;
argv
=
v
;
envv
=
v
+
argc
+
1
;
// skip 0 at end of argv
for
(
envc
=
0
;
envv
[
envc
]
!=
0
;
envc
++
)
;
}
//func argc() int32; // return number of arguments
void
sys_argc
(
int32
v
)
{
v
=
argc
;
FLUSH
(
&
v
);
}
//func envc() int32; // return number of environment variables
void
sys_envc
(
int32
v
)
{
v
=
envc
;
FLUSH
(
&
v
);
}
//func argv(i) string; // return argument i
void
sys_argv
(
int32
i
,
string
s
)
{
uint8
*
str
;
int32
l
;
if
(
i
<
0
||
i
>=
argc
)
{
s
=
emptystring
;
goto
out
;
}
str
=
argv
[
i
];
l
=
findnull
((
int8
*
)
str
);
s
=
mal
(
sizeof
(
s
->
len
)
+
l
);
s
->
len
=
l
;
mcpy
(
s
->
str
,
str
,
l
);
out:
FLUSH
(
&
s
);
}
//func envv(i) string; // return argument i
void
sys_envv
(
int32
i
,
string
s
)
{
uint8
*
str
;
int32
l
;
if
(
i
<
0
||
i
>=
envc
)
{
s
=
emptystring
;
goto
out
;
}
str
=
envv
[
i
];
l
=
findnull
((
int8
*
)
str
);
s
=
mal
(
sizeof
(
s
->
len
)
+
l
);
s
->
len
=
l
;
mcpy
(
s
->
str
,
str
,
l
);
out:
FLUSH
(
&
s
);
}
check
(
void
)
{
int8
a
;
...
...
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