1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:14:46 -07:00

cmd/vet: add amd64p32 (nacl) support to asmdecl check

Also add 'ErrorString', for checking Plan 9's package syscall.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/93410045
This commit is contained in:
Russ Cox 2014-05-19 12:31:38 -04:00
parent d8a81d8377
commit 322a5f1b4c

View File

@ -33,6 +33,7 @@ type asmArch struct {
name string
ptrSize int
intSize int
maxAlign int
bigEndian bool
}
@ -55,14 +56,16 @@ type asmVar struct {
}
var (
asmArch386 = asmArch{"386", 4, 4, false}
asmArchArm = asmArch{"arm", 4, 4, false}
asmArchAmd64 = asmArch{"amd64", 8, 8, false}
asmArch386 = asmArch{"386", 4, 4, 4, false}
asmArchArm = asmArch{"arm", 4, 4, 4, false}
asmArchAmd64 = asmArch{"amd64", 8, 8, 8, false}
asmArchAmd64p32 = asmArch{"amd64p32", 4, 4, 8, false}
arches = []*asmArch{
&asmArch386,
&asmArchArm,
&asmArchAmd64,
&asmArchAmd64p32,
}
)
@ -234,13 +237,13 @@ func (f *File) asmParseDecl(decl *ast.FuncDecl) map[string]*asmFunc {
case "int32", "uint32", "float32":
size = 4
case "int64", "uint64", "float64":
align = arch.ptrSize
align = arch.maxAlign
size = 8
case "int", "uint":
size = arch.intSize
case "uintptr", "iword", "Word", "Errno", "unsafe.Pointer":
size = arch.ptrSize
case "string":
case "string", "ErrorString":
size = arch.ptrSize * 2
align = arch.ptrSize
kind = asmString
@ -403,7 +406,7 @@ func (f *File) asmParseDecl(decl *ast.FuncDecl) map[string]*asmFunc {
offset = 0
addParams(decl.Type.Params.List)
if decl.Type.Results != nil && len(decl.Type.Results.List) > 0 {
offset += -offset & (arch.ptrSize - 1)
offset += -offset & (arch.maxAlign - 1)
addParams(decl.Type.Results.List)
}
fn.size = offset