Commit 10b23e7f authored by Jaroslavas Počepko's avatar Jaroslavas Počepko Committed by Alex Brainman

syscall: mksyscall_windows.pl to produce packages other than syscall (for...

syscall: mksyscall_windows.pl to produce packages other than syscall (for example pkg/exp/wingui/zwinapi.go)

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4964074
parent cf6d0175
...@@ -19,11 +19,5 @@ include ../../../Make.cmd ...@@ -19,11 +19,5 @@ include ../../../Make.cmd
zwinapi.go: winapi.go zwinapi.go: winapi.go
$(GOROOT)/src/pkg/syscall/mksyscall_windows.pl $< \ $(GOROOT)/src/pkg/syscall/mksyscall_windows.pl $< \
| sed 's/^package.*syscall$$/package main/' \
| sed '/^import/a \
import "syscall"' \
| sed 's/Syscall/syscall.Syscall/' \
| sed 's/NewLazyDLL/syscall.NewLazyDLL/' \
| sed 's/EINVAL/syscall.EINVAL/' \
| gofmt \ | gofmt \
> $@ > $@
...@@ -64,6 +64,7 @@ sub parseparam($) { ...@@ -64,6 +64,7 @@ sub parseparam($) {
return ($1, $2); return ($1, $2);
} }
my $package = "";
my $text = ""; my $text = "";
my $vars = ""; my $vars = "";
my $mods = ""; my $mods = "";
...@@ -73,8 +74,12 @@ while(<>) { ...@@ -73,8 +74,12 @@ while(<>) {
s/\s+/ /g; s/\s+/ /g;
s/^\s+//; s/^\s+//;
s/\s+$//; s/\s+$//;
$package = $1 if !$package && /^package (\S+)$/;
next if !/^\/\/sys /; next if !/^\/\/sys /;
my $syscalldot = "";
$syscalldot = "syscall." if $package ne "syscall";
# Line must be of the form # Line must be of the form
# func Open(path string, mode int, perm int) (fd int, errno int) # func Open(path string, mode int, perm int) (fd int, errno int)
# Split into name, in params, out params. # Split into name, in params, out params.
...@@ -96,7 +101,7 @@ while(<>) { ...@@ -96,7 +101,7 @@ while(<>) {
my $modvname = "mod$modname"; my $modvname = "mod$modname";
if($modnames !~ /$modname/) { if($modnames !~ /$modname/) {
$modnames .= ".$modname"; $modnames .= ".$modname";
$mods .= "\t$modvname = NewLazyDLL(\"$modname.dll\")\n"; $mods .= "\t$modvname = ${syscalldot}NewLazyDLL(\"$modname.dll\")\n";
} }
# System call name. # System call name.
...@@ -165,23 +170,23 @@ while(<>) { ...@@ -165,23 +170,23 @@ while(<>) {
my $nargs = @args; my $nargs = @args;
# Determine which form to use; pad args with zeros. # Determine which form to use; pad args with zeros.
my $asm = "Syscall"; my $asm = "${syscalldot}Syscall";
if(@args <= 3) { if(@args <= 3) {
while(@args < 3) { while(@args < 3) {
push @args, "0"; push @args, "0";
} }
} elsif(@args <= 6) { } elsif(@args <= 6) {
$asm = "Syscall6"; $asm = "${syscalldot}Syscall6";
while(@args < 6) { while(@args < 6) {
push @args, "0"; push @args, "0";
} }
} elsif(@args <= 9) { } elsif(@args <= 9) {
$asm = "Syscall9"; $asm = "${syscalldot}Syscall9";
while(@args < 9) { while(@args < 9) {
push @args, "0"; push @args, "0";
} }
} elsif(@args <= 12) { } elsif(@args <= 12) {
$asm = "Syscall12"; $asm = "${syscalldot}Syscall12";
while(@args < 12) { while(@args < 12) {
push @args, "0"; push @args, "0";
} }
...@@ -247,7 +252,7 @@ while(<>) { ...@@ -247,7 +252,7 @@ while(<>) {
$body .= "\t\tif $reg != 0 {\n"; $body .= "\t\tif $reg != 0 {\n";
$body .= "\t\t\t$name = $type($reg)\n"; $body .= "\t\t\t$name = $type($reg)\n";
$body .= "\t\t} else {\n"; $body .= "\t\t} else {\n";
$body .= "\t\t\t$name = EINVAL\n"; $body .= "\t\t\t$name = ${syscalldot}EINVAL\n";
$body .= "\t\t}\n"; $body .= "\t\t}\n";
$body .= "\t} else {\n"; $body .= "\t} else {\n";
$body .= "\t\t$name = 0\n"; $body .= "\t\t$name = 0\n";
...@@ -279,9 +284,14 @@ print <<EOF; ...@@ -279,9 +284,14 @@ print <<EOF;
// $cmdline // $cmdline
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall package $package
import "unsafe" import "unsafe"
EOF
print "import \"syscall\"\n" if $package ne "syscall";
print <<EOF;
var ( var (
$mods $mods
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment