summaryrefslogtreecommitdiff
path: root/src/cmd/godefs/main.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-06-30 15:34:22 +0200
committerOndřej Surý <ondrej@sury.org>2011-06-30 15:34:22 +0200
commitd39f5aa373a4422f7a5f3ee764fb0f6b0b719d61 (patch)
tree1833f8b72a4b3a8f00d0d143b079a8fcad01c6ae /src/cmd/godefs/main.c
parent8652e6c371b8905498d3d314491d36c58d5f68d5 (diff)
downloadgolang-upstream/58.tar.gz
Imported Upstream version 58upstream/58
Diffstat (limited to 'src/cmd/godefs/main.c')
-rw-r--r--src/cmd/godefs/main.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/cmd/godefs/main.c b/src/cmd/godefs/main.c
index d4163421d..6a8630179 100644
--- a/src/cmd/godefs/main.c
+++ b/src/cmd/godefs/main.c
@@ -181,7 +181,7 @@ main(int argc, char **argv)
char **av, *q, *r, *tofree, *name;
char nambuf[100];
Biobuf *bin, *bout;
- Type *t;
+ Type *t, *tt;
Field *f;
int orig_output_fd;
@@ -373,8 +373,16 @@ Continue:
prefix = prefixlen(t);
for(j=0; j<t->nf; j++) {
f = &t->f[j];
- if(f->type->kind == 0)
- continue;
+ if(f->type->kind == 0 && f->size <= 64 && (f->size&(f->size-1)) == 0) {
+ // unknown type but <= 64 bits and bit size is a power of two.
+ // could be enum - make Uint64 and then let it reduce
+ tt = emalloc(sizeof *tt);
+ *tt = *f->type;
+ f->type = tt;
+ tt->kind = Uint64;
+ while(tt->kind > Uint8 && kindsize[tt->kind] > f->size)
+ tt->kind -= 2;
+ }
// padding
if(t->kind == Struct || lang == &go) {
if(f->offset%8 != 0 || f->size%8 != 0) {