]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: accept __uint8_t as the uint8_t type
authorIan Lance Taylor <iant@golang.org>
Tue, 19 Mar 2019 13:51:14 +0000 (06:51 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 19 Mar 2019 14:48:00 +0000 (14:48 +0000)
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 <bsiegert@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/cgo/gcc.go

index 393248909344ab070ddfd6d67a9cf9db04ed9382..941f1db832aa392bf8b9b9326808ca187880732b 100644 (file)
@@ -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.