Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30618
b: refs/heads/master
c: 15fde67
h: refs/heads/master
v: v3
  • Loading branch information
Andreas Gruenbacher authored and Sam Ravnborg committed Jun 24, 2006
1 parent 4a0806c commit 2894171
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3041e47e8b08d51188b2cbdbd9c1e6f43314c8f1
refs/heads/master: 15fde6751886fd972a64ed65ba49db309919c504
5 changes: 4 additions & 1 deletion trunk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,8 @@ clean: archclean $(clean-dirs)
$(call cmd,rmfiles)
@find . $(RCS_FIND_IGNORE) \
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-o -name '*.symtypes' \) \
-type f -print | xargs rm -f

# mrproper - Delete all generated files, including .config
Expand Down Expand Up @@ -1311,6 +1312,8 @@ endif
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.o: %.S prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.symtypes: %.c prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)

# Modules
/ %/: prepare scripts FORCE
Expand Down
12 changes: 11 additions & 1 deletion trunk/scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $<
%.i: %.c FORCE
$(call if_changed_dep,cc_i_c)

quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
cmd_cc_symtypes_c = \
$(CPP) -D__GENKSYMS__ $(c_flags) $< \
| $(GENKSYMS) -T $@ >/dev/null; \
test -s $@ || rm -f $@

%.symtypes : %.c FORCE
$(call if_changed_dep,cc_symtypes_c)

# C (.c) files
# The C file is compiled and updated dependency information is generated.
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
Expand All @@ -166,7 +175,8 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
cmd_modversions = \
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
$(CPP) -D__GENKSYMS__ $(c_flags) $< \
| $(GENKSYMS) -a $(ARCH) \
| $(GENKSYMS) $(if $(KBUILD_SYMTYPES), \
-T $(@D)/$(@F:.o=.symtypes)) -a $(ARCH) \
> $(@D)/.tmp_$(@F:.o=.ver); \
\
$(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
Expand Down
77 changes: 51 additions & 26 deletions trunk/scripts/genksyms/genksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ static FILE *debugfile;
int cur_line = 1;
char *cur_filename;

static int flag_debug, flag_dump_defs, flag_warnings;
static int flag_debug, flag_dump_defs, flag_dump_types, flag_warnings;
static const char *arch = "";
static const char *mod_prefix = "";

static int errors;
static int nsyms;

static struct symbol *expansion_trail;
static struct symbol *visited_symbols;

static const char *const symbol_type_name[] = {
"normal", "typedef", "enum", "struct", "union"
Expand Down Expand Up @@ -176,6 +177,7 @@ struct symbol *add_symbol(const char *name, enum symbol_type type,
sym->type = type;
sym->defn = defn;
sym->expansion_trail = NULL;
sym->visited = NULL;
sym->is_extern = is_extern;

sym->hash_next = symtab[h];
Expand Down Expand Up @@ -236,26 +238,11 @@ static int equal_list(struct string_list *a, struct string_list *b)

static void print_node(FILE * f, struct string_list *list)
{
switch (list->tag) {
case SYM_STRUCT:
putc('s', f);
goto printit;
case SYM_UNION:
putc('u', f);
goto printit;
case SYM_ENUM:
putc('e', f);
goto printit;
case SYM_TYPEDEF:
putc('t', f);
goto printit;

printit:
if (list->tag != SYM_NORMAL) {
putc(symbol_type_name[list->tag][0], f);
putc('#', f);
case SYM_NORMAL:
fputs(list->string, f);
break;
}
fputs(list->string, f);
}

static void print_list(FILE * f, struct string_list *list)
Expand Down Expand Up @@ -287,9 +274,9 @@ static void print_list(FILE * f, struct string_list *list)
}
}

static unsigned long expand_and_crc_list(struct string_list *list,
unsigned long crc)
static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
{
struct string_list *list = sym->defn;
struct string_list **e, **b;
struct string_list *tmp, **tmp2;
int elem = 1;
Expand Down Expand Up @@ -332,7 +319,7 @@ static unsigned long expand_and_crc_list(struct string_list *list,
} else {
subsym->expansion_trail = expansion_trail;
expansion_trail = subsym;
crc = expand_and_crc_list(subsym->defn, crc);
crc = expand_and_crc_sym(subsym, crc);
}
break;

Expand Down Expand Up @@ -382,12 +369,22 @@ static unsigned long expand_and_crc_list(struct string_list *list,
} else {
subsym->expansion_trail = expansion_trail;
expansion_trail = subsym;
crc = expand_and_crc_list(subsym->defn, crc);
crc = expand_and_crc_sym(subsym, crc);
}
break;
}
}

{
static struct symbol **end = &visited_symbols;

if (!sym->visited) {
*end = sym;
end = &sym->visited;
sym->visited = (struct symbol *)-1L;
}
}

return crc;
}

Expand All @@ -406,7 +403,7 @@ void export_symbol(const char *name)

expansion_trail = (struct symbol *)-1L;

crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff;
crc = expand_and_crc_sym(sym, 0xffffffff) ^ 0xffffffff;

sym = expansion_trail;
while (sym != (struct symbol *)-1L) {
Expand Down Expand Up @@ -464,6 +461,7 @@ static void genksyms_usage(void)

int main(int argc, char **argv)
{
FILE *dumpfile = NULL;
int o;

#ifdef __GNU_LIBRARY__
Expand All @@ -473,15 +471,16 @@ int main(int argc, char **argv)
{"warnings", 0, 0, 'w'},
{"quiet", 0, 0, 'q'},
{"dump", 0, 0, 'D'},
{"dump-types", 1, 0, 'T'},
{"version", 0, 0, 'V'},
{"help", 0, 0, 'h'},
{0, 0, 0, 0}
};

while ((o = getopt_long(argc, argv, "a:dwqVDk:p:",
while ((o = getopt_long(argc, argv, "a:dwqVDT:k:p:",
&long_opts[0], NULL)) != EOF)
#else /* __GNU_LIBRARY__ */
while ((o = getopt(argc, argv, "a:dwqVDk:p:")) != EOF)
while ((o = getopt(argc, argv, "a:dwqVDT:k:p:")) != EOF)
#endif /* __GNU_LIBRARY__ */
switch (o) {
case 'a':
Expand All @@ -502,6 +501,14 @@ int main(int argc, char **argv)
case 'D':
flag_dump_defs = 1;
break;
case 'T':
flag_dump_types = 1;
dumpfile = fopen(optarg, "w");
if (!dumpfile) {
perror(optarg);
return 1;
}
break;
case 'h':
genksyms_usage();
return 0;
Expand All @@ -524,6 +531,24 @@ int main(int argc, char **argv)

yyparse();

if (flag_dump_types && visited_symbols) {
while (visited_symbols != (struct symbol *)-1L) {
struct symbol *sym = visited_symbols;

if (sym->type != SYM_NORMAL) {
putc(symbol_type_name[sym->type][0], dumpfile);
putc('#', dumpfile);
}
fputs(sym->name, dumpfile);
putc(' ', dumpfile);
print_list(dumpfile, sym->defn);
putc('\n', dumpfile);

visited_symbols = sym->visited;
sym->visited = NULL;
}
}

if (flag_debug) {
fprintf(debugfile, "Hash table occupancy %d/%d = %g\n",
nsyms, HASH_BUCKETS,
Expand Down
1 change: 1 addition & 0 deletions trunk/scripts/genksyms/genksyms.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct symbol {
enum symbol_type type;
struct string_list *defn;
struct symbol *expansion_trail;
struct symbol *visited;
int is_extern;
};

Expand Down

0 comments on commit 2894171

Please sign in to comment.