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