Commit 72954ebc authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/cgo: accept __uint8_t as the uint8_t type

This works around the NetBSD <stdint.h> 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/+/168337Reviewed-by: default avatarBenny Siegert <bsiegert@gmail.com>
Reviewed-by: default avatarTobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent d34548e0
...@@ -2483,7 +2483,9 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type { ...@@ -2483,7 +2483,9 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
// representation. // representation.
if exactWidthIntegerType.MatchString(dt.Name) { if exactWidthIntegerType.MatchString(dt.Name) {
sub := c.Type(dt.Type, pos) 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 { if sub.Size != u.Size {
fatalf("%s: unexpected size: %d vs. %d – %s", lineno(pos), sub.Size, u.Size, dtype) 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 { ...@@ -2630,7 +2632,7 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
return t 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 // isStructUnionClass reports whether the type described by the Go syntax x
// is a struct, union, or class with a tag. // is a struct, union, or class with a tag.
......
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