From 3d77bc081d16b02bb937fdd648f4e83ebc0b9b95 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Thu, 2 Mar 2017 07:23:43 -0800 Subject: [PATCH] cmd/vet/all: use SizesFor to calculate archbits Change-Id: I99706807782f11e8d24baf953424a9e292a2cbac Reviewed-on: https://go-review.googlesource.com/37668 Run-TryBot: Josh Bleecher Snyder Reviewed-by: Rob Pike TryBot-Result: Gobot Gobot --- src/cmd/vet/all/main.go | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/cmd/vet/all/main.go b/src/cmd/vet/all/main.go index 70111116597..0089d9d3efe 100644 --- a/src/cmd/vet/all/main.go +++ b/src/cmd/vet/all/main.go @@ -15,6 +15,7 @@ import ( "flag" "fmt" "go/build" + "go/types" "internal/testenv" "log" "os" @@ -108,11 +109,11 @@ type whitelist map[string]int // load adds entries from the whitelist file, if present, for os/arch to w. func (w whitelist) load(goos string, goarch string) { - // Look up whether goarch is a 32-bit or 64-bit architecture. - archbits, ok := nbits[goarch] - if !ok { - log.Fatalf("unknown bitwidth for arch %q", goarch) + sz := types.SizesFor("gc", goarch) + if sz == nil { + log.Fatalf("unknown type sizes for arch %q", goarch) } + archbits := 8 * sz.Sizeof(types.Typ[types.UnsafePointer]) // Look up whether goarch has a shared arch suffix, // such as mips64x for mips64 and mips64le. @@ -338,23 +339,6 @@ NextLine: os.Stdout.Write(buf.Bytes()) } -// nbits maps from architecture names to the number of bits in a pointer. -// TODO: figure out a clean way to avoid get this info rather than listing it here yet again. -var nbits = map[string]int{ - "386": 32, - "amd64": 64, - "amd64p32": 32, - "arm": 32, - "arm64": 64, - "mips": 32, - "mipsle": 32, - "mips64": 64, - "mips64le": 64, - "ppc64": 64, - "ppc64le": 64, - "s390x": 64, -} - // archAsmX maps architectures to the suffix usually used for their assembly files, // if different than the arch name itself. var archAsmX = map[string]string{