Skip to content

Commit 72954eb

Browse files
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/+/168337 Reviewed-by: Benny Siegert <[email protected]> Reviewed-by: Tobias Klauser <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent d34548e commit 72954eb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/cmd/cgo/gcc.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,7 +2483,9 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
24832483
// representation.
24842484
if exactWidthIntegerType.MatchString(dt.Name) {
24852485
sub := c.Type(dt.Type, pos)
2486-
u := c.exactWidthIntegerTypes[strings.TrimSuffix(dt.Name, "_t")]
2486+
goname := strings.TrimPrefix(dt.Name, "__")
2487+
goname = strings.TrimSuffix(goname, "_t")
2488+
u := c.exactWidthIntegerTypes[goname]
24872489
if sub.Size != u.Size {
24882490
fatalf("%s: unexpected size: %d vs. %d – %s", lineno(pos), sub.Size, u.Size, dtype)
24892491
}
@@ -2630,7 +2632,7 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
26302632
return t
26312633
}
26322634

2633-
var exactWidthIntegerType = regexp.MustCompile(`^u?int(8|16|32|64)_t$`)
2635+
var exactWidthIntegerType = regexp.MustCompile(`^(__)?u?int(8|16|32|64)_t$`)
26342636

26352637
// isStructUnionClass reports whether the type described by the Go syntax x
26362638
// is a struct, union, or class with a tag.

0 commit comments

Comments
 (0)