summaryrefslogtreecommitdiff
path: root/src/cmd/godefs
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-01-17 12:40:45 +0100
committerOndřej Surý <ondrej@sury.org>2011-01-17 12:40:45 +0100
commit3e45412327a2654a77944249962b3652e6142299 (patch)
treebc3bf69452afa055423cbe0c5cfa8ca357df6ccf /src/cmd/godefs
parentc533680039762cacbc37db8dc7eed074c3e497be (diff)
downloadgolang-upstream/2011.01.12.tar.gz
Imported Upstream version 2011.01.12upstream/2011.01.12
Diffstat (limited to 'src/cmd/godefs')
-rw-r--r--src/cmd/godefs/Makefile14
-rw-r--r--src/cmd/godefs/main.c10
-rw-r--r--src/cmd/godefs/stabs.c13
3 files changed, 20 insertions, 17 deletions
diff --git a/src/cmd/godefs/Makefile b/src/cmd/godefs/Makefile
index 49244f152..b5c76fb0f 100644
--- a/src/cmd/godefs/Makefile
+++ b/src/cmd/godefs/Makefile
@@ -2,7 +2,8 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
-include ../../Make.conf
+include ../../Make.inc
+O:=$(HOST_O)
TARG=godefs
OFILES=\
@@ -12,13 +13,4 @@ OFILES=\
HFILES=a.h
-$(TARG): $(OFILES)
- $(LD) -o $(TARG) -L"$(GOROOT)"/lib $(OFILES) -lbio -l9
-
-clean:
- rm -f *.$O $(TARG)
-
-install: $(TARG)
- cp $(TARG) "$(GOBIN)"/$(TARG)
-
-$(OFILES): $(HFILES)
+include ../../Make.ccmd
diff --git a/src/cmd/godefs/main.c b/src/cmd/godefs/main.c
index 6ff542f48..69ee1be5d 100644
--- a/src/cmd/godefs/main.c
+++ b/src/cmd/godefs/main.c
@@ -82,7 +82,7 @@
#include "a.h"
-#ifdef __MINGW32__
+#ifdef _WIN32
int
spawn(char *prog, char **argv)
{
@@ -133,7 +133,7 @@ Lang go =
"type %s struct {\n",
"type %s struct {\n",
- "\tPad%d [%d]byte;\n",
+ "\tPad_godefs_%d [%d]byte;\n",
"}\n",
gotypefmt,
@@ -150,7 +150,7 @@ Lang c =
"typedef struct %s %s;\nstruct %s {\n",
"typedef union %s %s;\nunion %s {\n",
- "\tbyte pad%d[%d];\n",
+ "\tbyte pad_godefs_%d[%d];\n",
"};\n",
ctypefmt,
@@ -373,6 +373,8 @@ Continue:
prefix = prefixlen(t);
for(j=0; j<t->nf; j++) {
f = &t->f[j];
+ if(f->type->kind == 0)
+ continue;
// padding
if(t->kind == Struct || lang == &go) {
if(f->offset%8 != 0 || f->size%8 != 0) {
@@ -391,7 +393,7 @@ Continue:
if(cutprefix(name))
name += prefix;
if(strcmp(name, "") == 0) {
- snprint(nambuf, sizeof nambuf, "Pad%d", npad++);
+ snprint(nambuf, sizeof nambuf, "Pad_godefs_%d", npad++);
name = nambuf;
}
Bprint(bout, "\t%#lT;\n", name, f->type);
diff --git a/src/cmd/godefs/stabs.c b/src/cmd/godefs/stabs.c
index 8d3be1913..1bc96d4c8 100644
--- a/src/cmd/godefs/stabs.c
+++ b/src/cmd/godefs/stabs.c
@@ -363,13 +363,22 @@ parsedef(char **pp, char *name)
return nil;
}
+ while(f->type->kind == Typedef)
+ f->type = f->type->type;
+ 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;
+ }
+
// rewrite
// uint32 x : 8;
// into
// uint8 x;
// hooray for bitfields.
- while(f->type->kind == Typedef)
- f->type = f->type->type;
while(Int16 <= f->type->kind && f->type->kind <= Uint64 && kindsize[f->type->kind] > f->size) {
tt = emalloc(sizeof *tt);
*tt = *f->type;