Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
f6497cc6
Commit
f6497cc6
authored
Oct 27, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syscalls: Rewrite awk script to work with nawk.
From-SVN: r180559
parent
78968b76
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
15 deletions
+45
-15
libgo/go/syscall/mksyscall.awk
+45
-15
No files found.
libgo/go/syscall/mksyscall.awk
View file @
f6497cc6
...
...
@@ -44,33 +44,63 @@ BEGIN {
blocking
=
1
}
if
(
match
(
$0
,
"//sys(nb)?[ ]*([a-zA-Z0-9_]+)\\(([^()]*)\\) *(\\(([^()]+)\\))?"
,
gosig
)
==
0
)
{
line
=
$0
if
(
match
(
line
,
"//sys(nb)?[ ]*[a-zA-Z0-9_]+\\([^()]*\\) *(\\(([^()]+)\\))?"
)
==
0
)
{
print
"unmatched line:"
,
$0
|
"cat 1>&2"
status
=
1
next
}
gofnname
=
gosig
[
2
]
gofnparams
=
gosig
[
3
]
gofnresults
=
gosig
[
5
]
# Sets a[1] = //sysnb, a[2] == function name.
split
(
line
,
a
,
"[ (]*"
)
gofnname
=
a
[
2
]
off
=
match
(
line
,
"\\([^()]*\\)"
)
end
=
index
(
substr
(
line
,
off
,
length
(
line
)
-
off
+
1
),
")"
)
gofnparams
=
substr
(
line
,
off
+
1
,
end
-
2
)
line
=
substr
(
line
,
off
+
end
,
length
(
line
)
-
(
off
+
end
)
+
1
)
off
=
match
(
line
,
"\\([^()]*\\)"
)
if
(
off
==
0
)
{
gofnresults
=
""
}
else
{
end
=
index
(
substr
(
line
,
off
,
length
(
line
)
-
off
+
1
),
")"
)
gofnresults
=
substr
(
line
,
off
+
1
,
end
-
2
)
}
getline
line
=
$0
if
(
match
(
$0
,
"//([a-zA-Z0-9_]+)\\(([^()]*)\\) *(.*)$"
,
csig
)
==
0
)
{
if
(
match
(
line
,
"//[a-zA-Z0-9_]+\\([^()]*\\)"
)
==
0
)
{
print
"unmatched C line"
,
$0
,
"after"
,
gofnname
|
"cat 1>&2"
status
=
1
next
}
cfnname
=
csig
[
1
]
cfnparams
=
csig
[
2
]
cfnresult
=
csig
[
3
]
split
(
line
,
a
,
"[ (]*"
)
cfnname
=
substr
(
a
[
1
],
3
,
length
(
a
[
1
])
-
2
)
off
=
match
(
line
,
"\\([^()]*\\)"
)
end
=
index
(
substr
(
line
,
off
,
length
(
line
)
-
off
+
1
),
")"
)
cfnparams
=
substr
(
line
,
off
+
1
,
end
-
2
)
line
=
substr
(
line
,
off
+
end
+
1
,
length
(
line
)
-
(
off
+
end
)
+
1
)
while
(
substr
(
line
,
1
,
1
)
==
" "
)
{
line
=
substr
(
line
,
2
,
length
(
line
)
-
1
)
}
end
=
index
(
line
,
" "
)
if
(
end
!=
0
)
{
line
=
substr
(
line
,
1
,
end
)
}
cfnresult
=
line
printf
(
"// Automatically generated wrapper for %s/%s\n"
,
gofnname
,
cfnname
)
printf
(
"func c_%s(%s) %s%s__asm__(\"%s\")\n"
,
cfnname
,
cfnparams
,
cfnresult
,
cfnresult
==
""
?
""
:
" "
,
cfnname
)
printf
(
"func %s(%s) %s%s{\n"
,
gofnname
,
gofnparams
,
gosig
[
4
],
gosig
[
4
]
==
""
?
""
:
" "
)
printf
(
"func %s(%s) %s%s%s%s{\n"
,
gofnname
,
gofnparams
,
gofnresults
==
""
?
""
:
"("
,
gofnresults
,
gofnresults
==
""
?
""
:
")"
,
gofnresults
==
""
?
""
:
" "
)
if
(
blocking
)
{
print
"\tentersyscall()"
...
...
@@ -91,22 +121,22 @@ BEGIN {
args
=
args
", "
}
if
(
match
(
goargs
[
goarg
],
"^([^ ]*) ([^ ]*)$"
,
goparam
)
==
0
)
{
if
(
split
(
goargs
[
goarg
],
a
)
!=
2
)
{
print
loc
,
"bad parameter:"
,
goargs
[
goarg
]
|
"cat 1>&2"
status
=
1
next
}
goname
=
goparam
[
1
]
gotype
=
goparam
[
2
]
goname
=
a
[
1
]
gotype
=
a
[
2
]
if
(
match
(
cargs
[
carg
],
"^([^ ]*) ([^ ]*)$"
,
cparam
)
==
0
)
{
if
(
split
(
cargs
[
carg
],
a
)
!=
2
)
{
print
loc
,
"bad C parameter:"
,
cargs
[
carg
]
|
"cat 1>&2"
status
=
1
next
}
ctype
=
cparam
[
2
]
ctype
=
a
[
2
]
if
(
gotype
~
/^
\*
/
)
{
if
(
gotype
!=
ctype
)
{
...
...
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