summaryrefslogtreecommitdiff
path: root/src/cmd/cc/godefs.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-08-27 21:59:49 -0400
committerRuss Cox <rsc@golang.org>2014-08-27 21:59:49 -0400
commit3ed5cd831cec9e6a4c8004cbd65a3ba0b40be26c (patch)
tree54ab4c93040b82f88859c09f1135c85c2e224d95 /src/cmd/cc/godefs.c
parent6cf8ddd13fefdb19ee1cd9ee2e57cda6ac22f4d9 (diff)
downloadgo-3ed5cd831cec9e6a4c8004cbd65a3ba0b40be26c.tar.gz
cmd/cc, runtime: preserve C runtime type names in generated Go
uintptr or uint64 in the runtime C were turning into uint in the Go, bool was turning into uint8, and so on. Fix that. Also delete Go wrappers for C functions. The C functions can be called directly now (but still eventually need to be converted to Go). LGTM=bradfitz, minux, iant R=golang-codereviews, bradfitz, iant, minux CC=golang-codereviews, khr, r https://codereview.appspot.com/138740043
Diffstat (limited to 'src/cmd/cc/godefs.c')
-rw-r--r--src/cmd/cc/godefs.c53
1 files changed, 10 insertions, 43 deletions
diff --git a/src/cmd/cc/godefs.c b/src/cmd/cc/godefs.c
index 3755a8fc0..edb8a5e28 100644
--- a/src/cmd/cc/godefs.c
+++ b/src/cmd/cc/godefs.c
@@ -188,60 +188,27 @@ printtypename(Type *t)
switch(t->etype) {
case TINT:
- Bprint(&outbuf, "int32");
- break;
case TUINT:
- Bprint(&outbuf, "uint32");
- break;
case TCHAR:
- Bprint(&outbuf, "int8");
- break;
case TUCHAR:
- Bprint(&outbuf, "uint8");
- break;
case TSHORT:
- Bprint(&outbuf, "int16");
- break;
case TUSHORT:
- Bprint(&outbuf, "uint16");
- break;
case TLONG:
- // The 32/64-bit ambiguous types (int,uint,uintptr)
- // are assigned a TLONG/TULONG to distinguish them
- // from always 32-bit types which get a TINT/TUINT.
- // (See int_x/uint_x in pkg/runtime/runtime.h.)
- // For LONG and VLONG types, we generate the
- // unqualified Go type when appropriate.
- // This makes it easier to write Go code that
- // modifies objects with autogenerated-from-C types.
- if(ewidth[TIND] == 4)
- Bprint(&outbuf, "int");
- else
- Bprint(&outbuf, "int32");
- break;
case TULONG:
- if(ewidth[TIND] == 4)
- Bprint(&outbuf, "uint");
- else
- Bprint(&outbuf, "uint32");
- break;
case TVLONG:
- if(ewidth[TIND] == 8)
- Bprint(&outbuf, "int");
- else
- Bprint(&outbuf, "int64");
- break;
case TUVLONG:
- if(ewidth[TIND] == 8)
- Bprint(&outbuf, "uint");
- else
- Bprint(&outbuf, "uint64");
- break;
case TFLOAT:
- Bprint(&outbuf, "float32");
- break;
case TDOUBLE:
- Bprint(&outbuf, "float64");
+ // All names used in the runtime code should be typedefs.
+ if(t->tag != nil) {
+ if(strcmp(t->tag->name, "intgo") == 0)
+ Bprint(&outbuf, "int");
+ else if(strcmp(t->tag->name, "uintgo") == 0)
+ Bprint(&outbuf, "uint");
+ else
+ Bprint(&outbuf, "%s", t->tag->name);
+ } else
+ Bprint(&outbuf, "C.%T", t);
break;
case TUNION:
case TSTRUCT: