From 72954ebcfdeb5354e43ed781061d46e48137bfc0 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 19 Mar 2019 06:51:14 -0700 Subject: [PATCH] cmd/cgo: accept __uint8_t as the uint8_t type This works around the NetBSD which defines the type using "#define" rather than typedef. Fixes #30918 Updates #29878 Change-Id: I8998eba52139366ae46762bdad5fcae85f9b4027 Reviewed-on: https://go-review.googlesource.com/c/go/+/168337 Reviewed-by: Benny Siegert Reviewed-by: Tobias Klauser Reviewed-by: Brad Fitzpatrick Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot --- src/cmd/cgo/gcc.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 3932489093..941f1db832 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -2483,7 +2483,9 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type { // representation. if exactWidthIntegerType.MatchString(dt.Name) { sub := c.Type(dt.Type, pos) - u := c.exactWidthIntegerTypes[strings.TrimSuffix(dt.Name, "_t")] + goname := strings.TrimPrefix(dt.Name, "__") + goname = strings.TrimSuffix(goname, "_t") + u := c.exactWidthIntegerTypes[goname] if sub.Size != u.Size { fatalf("%s: unexpected size: %d vs. %d – %s", lineno(pos), sub.Size, u.Size, dtype) } @@ -2630,7 +2632,7 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type { return t } -var exactWidthIntegerType = regexp.MustCompile(`^u?int(8|16|32|64)_t$`) +var exactWidthIntegerType = regexp.MustCompile(`^(__)?u?int(8|16|32|64)_t$`) // isStructUnionClass reports whether the type described by the Go syntax x // is a struct, union, or class with a tag. -- 2.50.0