Commit 82e30c68 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cgo: rename C names for Go types to avoid conflicting with package

Fixes #3371.

R=rsc, bsiegert, r, mtj, iant
CC=golang-dev
https://golang.org/cl/6131060
parent cc9a5c3b
...@@ -736,25 +736,23 @@ func c(repr string, args ...interface{}) *TypeRepr { ...@@ -736,25 +736,23 @@ func c(repr string, args ...interface{}) *TypeRepr {
// Map predeclared Go types to Type. // Map predeclared Go types to Type.
var goTypes = map[string]*Type{ var goTypes = map[string]*Type{
"bool": {Size: 1, Align: 1, C: c("uchar")}, "bool": {Size: 1, Align: 1, C: c("GoUint8")},
"byte": {Size: 1, Align: 1, C: c("uchar")}, "byte": {Size: 1, Align: 1, C: c("GoUint8")},
"int": {Size: 4, Align: 4, C: c("int")}, "int": {Size: 4, Align: 4, C: c("GoInt")},
"uint": {Size: 4, Align: 4, C: c("uint")}, "uint": {Size: 4, Align: 4, C: c("GoUint")},
"rune": {Size: 4, Align: 4, C: c("int")}, "rune": {Size: 4, Align: 4, C: c("GoInt32")},
"int8": {Size: 1, Align: 1, C: c("schar")}, "int8": {Size: 1, Align: 1, C: c("GoInt8")},
"uint8": {Size: 1, Align: 1, C: c("uchar")}, "uint8": {Size: 1, Align: 1, C: c("GoUint8")},
"int16": {Size: 2, Align: 2, C: c("short")}, "int16": {Size: 2, Align: 2, C: c("GoInt16")},
"uint16": {Size: 2, Align: 2, C: c("ushort")}, "uint16": {Size: 2, Align: 2, C: c("GoUint16")},
"int32": {Size: 4, Align: 4, C: c("int")}, "int32": {Size: 4, Align: 4, C: c("GoInt32")},
"uint32": {Size: 4, Align: 4, C: c("uint")}, "uint32": {Size: 4, Align: 4, C: c("GoUint32")},
"int64": {Size: 8, Align: 8, C: c("int64")}, "int64": {Size: 8, Align: 8, C: c("GoInt64")},
"uint64": {Size: 8, Align: 8, C: c("uint64")}, "uint64": {Size: 8, Align: 8, C: c("GoUint64")},
"float": {Size: 4, Align: 4, C: c("float")}, "float32": {Size: 4, Align: 4, C: c("GoFloat32")},
"float32": {Size: 4, Align: 4, C: c("float")}, "float64": {Size: 8, Align: 8, C: c("GoFloat64")},
"float64": {Size: 8, Align: 8, C: c("double")}, "complex64": {Size: 8, Align: 8, C: c("GoComplex64")},
"complex": {Size: 8, Align: 8, C: c("__complex float")}, "complex128": {Size: 16, Align: 16, C: c("GoComplex128")},
"complex64": {Size: 8, Align: 8, C: c("__complex float")},
"complex128": {Size: 16, Align: 16, C: c("__complex double")},
} }
// Map an ast type to a Type. // Map an ast type to a Type.
...@@ -799,7 +797,7 @@ func (p *Package) cgoType(e ast.Expr) *Type { ...@@ -799,7 +797,7 @@ func (p *Package) cgoType(e ast.Expr) *Type {
return def return def
} }
if t.Name == "uintptr" { if t.Name == "uintptr" {
return &Type{Size: p.PtrSize, Align: p.PtrSize, C: c("uintptr")} return &Type{Size: p.PtrSize, Align: p.PtrSize, C: c("GoUintptr")}
} }
if t.Name == "string" { if t.Name == "string" {
return &Type{Size: p.PtrSize + 4, Align: p.PtrSize, C: c("GoString")} return &Type{Size: p.PtrSize + 4, Align: p.PtrSize, C: c("GoString")}
...@@ -930,13 +928,21 @@ Slice GoBytes(char *p, int n) { ...@@ -930,13 +928,21 @@ Slice GoBytes(char *p, int n) {
` `
const gccExportHeaderProlog = ` const gccExportHeaderProlog = `
typedef unsigned int uint; typedef int GoInt;
typedef signed char schar; typedef unsigned int GoUint;
typedef unsigned char uchar; typedef signed char GoInt8;
typedef unsigned short ushort; typedef unsigned char GoUint8;
typedef long long int64; typedef short GoInt16;
typedef unsigned long long uint64; typedef unsigned short GoUint16;
typedef __SIZE_TYPE__ uintptr; typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef __SIZE_TYPE__ GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
typedef __complex float GoComplex64;
typedef __complex double GoComplex128;
typedef struct { char *p; int n; } GoString; typedef struct { char *p; int n; } GoString;
typedef void *GoMap; typedef void *GoMap;
......
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