Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

+20 -2
+2 -1
scripts/genksyms/genksyms.c
··· 40 40 static FILE *debugfile; 41 41 42 42 int cur_line = 1; 43 - char *cur_filename; 43 + char *cur_filename, *source_file; 44 + int in_source_file; 44 45 45 46 static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, 46 47 flag_preserve, flag_warnings;
+3 -1
scripts/genksyms/genksyms.h
··· 37 37 struct string_list { 38 38 struct string_list *next; 39 39 enum symbol_type tag; 40 + int in_source_file; 40 41 char *string; 41 42 }; 42 43 ··· 58 57 #define YYSTYPE yystype 59 58 60 59 extern int cur_line; 61 - extern char *cur_filename; 60 + extern char *cur_filename, *source_file; 61 + extern int in_source_file; 62 62 63 63 struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact); 64 64 struct symbol *add_symbol(const char *name, enum symbol_type type,
+8
scripts/genksyms/lex.l
··· 116 116 cur_node->tag = \ 117 117 find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\ 118 118 SYM_ENUM_CONST : SYM_NORMAL ; \ 119 + cur_node->in_source_file = in_source_file; \ 119 120 } while (0) 120 121 121 122 #define APP _APP(yytext, yyleng) ··· 166 165 *e = '\0'; 167 166 cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1); 168 167 cur_line = atoi(yytext+2); 168 + 169 + if (!source_file) { 170 + source_file = xstrdup(cur_filename); 171 + in_source_file = 1; 172 + } else { 173 + in_source_file = (strcmp(cur_filename, source_file) == 0); 174 + } 169 175 170 176 goto repeat; 171 177 }
+7
scripts/genksyms/parse.y
··· 58 58 enum symbol_type type) 59 59 { 60 60 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 + } 61 68 r = copy_node(i); r->tag = type; 62 69 r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; 63 70 add_symbol(i->string, type, b, is_extern);