Skip to content

Commit 2c5925d

Browse files
committed
genksyms: Do not expand internal types
Consider structures, unions and enums defined in the source file as internal and do not expand them. This way, changes to e.g. struct serial_private in drivers/tty/serial/8250_pci.c will not affect the checksum of the pciserial_* exports.
1 parent b06fcd6 commit 2c5925d

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎scripts/genksyms/genksyms.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ static struct symbol *symtab[HASH_BUCKETS];
4040
static FILE *debugfile;
4141

4242
int cur_line = 1;
43-
char *cur_filename;
43+
char *cur_filename, *source_file;
44+
int in_source_file;
4445

4546
static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types,
4647
flag_preserve, flag_warnings;

‎scripts/genksyms/genksyms.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum symbol_status {
3737
struct string_list {
3838
struct string_list *next;
3939
enum symbol_type tag;
40+
int in_source_file;
4041
char *string;
4142
};
4243

@@ -57,7 +58,8 @@ typedef struct string_list **yystype;
5758
#define YYSTYPE yystype
5859

5960
extern int cur_line;
60-
extern char *cur_filename;
61+
extern char *cur_filename, *source_file;
62+
extern int in_source_file;
6163

6264
struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
6365
struct symbol *add_symbol(const char *name, enum symbol_type type,

‎scripts/genksyms/lex.l‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>)
116116
cur_node->tag = \
117117
find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\
118118
SYM_ENUM_CONST : SYM_NORMAL ; \
119+
cur_node->in_source_file = in_source_file; \
119120
} while (0)
120121
121122
#define APP _APP(yytext, yyleng)
@@ -166,6 +167,13 @@ repeat:
166167
cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1);
167168
cur_line = atoi(yytext+2);
168169
170+
if (!source_file) {
171+
source_file = xstrdup(cur_filename);
172+
in_source_file = 1;
173+
} else {
174+
in_source_file = (strcmp(cur_filename, source_file) == 0);
175+
}
176+
169177
goto repeat;
170178
}
171179

‎scripts/genksyms/parse.y‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ static void record_compound(struct string_list **keyw,
5858
enum symbol_type type)
5959
{
6060
struct string_list *b = *body, *i = *ident, *r;
61+
62+
if (i->in_source_file) {
63+
remove_node(keyw);
64+
(*ident)->tag = type;
65+
remove_list(body, ident);
66+
return;
67+
}
6168
r = copy_node(i); r->tag = type;
6269
r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL;
6370
add_symbol(i->string, type, b, is_extern);

0 commit comments

Comments
 (0)