summaryrefslogtreecommitdiff
path: root/src/cmd/cc
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-07-30 09:01:52 -0700
committerKeith Randall <khr@golang.org>2014-07-30 09:01:52 -0700
commit698bdf4df3c249aa069717019bc15a608fe1fa2d (patch)
tree5e486901c6cbf7b0c49ddbea467b959e10eddb2d /src/cmd/cc
parent7b6f6b0583f6563313aaa0d04ccf781d156eb014 (diff)
downloadgo-698bdf4df3c249aa069717019bc15a608fe1fa2d.tar.gz
runtime: rewrite malloc in Go.
This change introduces gomallocgc, a Go clone of mallocgc. Only a few uses have been moved over, so there are still lots of uses from C. Many of these C uses will be moved over to Go (e.g. in slice.goc), but probably not all. What should remain of C's mallocgc is an open question. LGTM=rsc, dvyukov R=rsc, khr, dave, bradfitz, dvyukov CC=golang-codereviews https://codereview.appspot.com/108840046
Diffstat (limited to 'src/cmd/cc')
-rw-r--r--src/cmd/cc/godefs.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/cmd/cc/godefs.c b/src/cmd/cc/godefs.c
index 7457bd000..3755a8fc0 100644
--- a/src/cmd/cc/godefs.c
+++ b/src/cmd/cc/godefs.c
@@ -206,16 +206,36 @@ printtypename(Type *t)
Bprint(&outbuf, "uint16");
break;
case TLONG:
- Bprint(&outbuf, "int32");
+ // 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:
- Bprint(&outbuf, "uint32");
+ if(ewidth[TIND] == 4)
+ Bprint(&outbuf, "uint");
+ else
+ Bprint(&outbuf, "uint32");
break;
case TVLONG:
- Bprint(&outbuf, "int64");
+ if(ewidth[TIND] == 8)
+ Bprint(&outbuf, "int");
+ else
+ Bprint(&outbuf, "int64");
break;
case TUVLONG:
- Bprint(&outbuf, "uint64");
+ if(ewidth[TIND] == 8)
+ Bprint(&outbuf, "uint");
+ else
+ Bprint(&outbuf, "uint64");
break;
case TFLOAT:
Bprint(&outbuf, "float32");