aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/genksyms/genksyms.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@mars.ravnborg.org>2006-03-12 17:26:29 -0500
committerSam Ravnborg <sam@mars.ravnborg.org>2006-03-12 17:26:29 -0500
commitce560686947fd50b30eaf42045554797f53949dd (patch)
treeae04b6c366eec6c6ff9726a8034ffd61c269ce1b /scripts/genksyms/genksyms.c
parent78c041530ac2e65c9290137bfe3004340e0840d2 (diff)
kbuild: clean-up genksyms
o remove all inlines o declare everything static which is only used by genksyms.c o delete unused functions o delete unused variables o delete unused stuff in genksyms.h o properly ident genksyms.h Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/genksyms/genksyms.c')
-rw-r--r--scripts/genksyms/genksyms.c80
1 files changed, 26 insertions, 54 deletions
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index b798e284e1fc..5b0344e20d61 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -37,14 +37,14 @@
37#define HASH_BUCKETS 4096 37#define HASH_BUCKETS 4096
38 38
39static struct symbol *symtab[HASH_BUCKETS]; 39static struct symbol *symtab[HASH_BUCKETS];
40FILE *debugfile; 40static FILE *debugfile;
41 41
42int cur_line = 1; 42int cur_line = 1;
43char *cur_filename, *output_directory; 43char *cur_filename;
44 44
45int flag_debug, flag_dump_defs, flag_warnings; 45static int flag_debug, flag_dump_defs, flag_warnings;
46const char *arch = ""; 46static const char *arch = "";
47const char *mod_prefix = ""; 47static const char *mod_prefix = "";
48 48
49static int errors; 49static int errors;
50static int nsyms; 50static int nsyms;
@@ -55,6 +55,9 @@ static const char *const symbol_type_name[] = {
55 "normal", "typedef", "enum", "struct", "union" 55 "normal", "typedef", "enum", "struct", "union"
56}; 56};
57 57
58static int equal_list(struct string_list *a, struct string_list *b);
59static void print_list(FILE * f, struct string_list *list);
60
58/*----------------------------------------------------------------------*/ 61/*----------------------------------------------------------------------*/
59 62
60static const unsigned int crctab32[] = { 63static const unsigned int crctab32[] = {
@@ -112,27 +115,26 @@ static const unsigned int crctab32[] = {
112 0x2d02ef8dU 115 0x2d02ef8dU
113}; 116};
114 117
115static inline unsigned long 118static unsigned long partial_crc32_one(unsigned char c, unsigned long crc)
116partial_crc32_one(unsigned char c, unsigned long crc)
117{ 119{
118 return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8); 120 return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
119} 121}
120 122
121static inline unsigned long partial_crc32(const char *s, unsigned long crc) 123static unsigned long partial_crc32(const char *s, unsigned long crc)
122{ 124{
123 while (*s) 125 while (*s)
124 crc = partial_crc32_one(*s++, crc); 126 crc = partial_crc32_one(*s++, crc);
125 return crc; 127 return crc;
126} 128}
127 129
128static inline unsigned long crc32(const char *s) 130static unsigned long crc32(const char *s)
129{ 131{
130 return partial_crc32(s, 0xffffffff) ^ 0xffffffff; 132 return partial_crc32(s, 0xffffffff) ^ 0xffffffff;
131} 133}
132 134
133/*----------------------------------------------------------------------*/ 135/*----------------------------------------------------------------------*/
134 136
135static inline enum symbol_type map_to_ns(enum symbol_type t) 137static enum symbol_type map_to_ns(enum symbol_type t)
136{ 138{
137 if (t == SYM_TYPEDEF) 139 if (t == SYM_TYPEDEF)
138 t = SYM_NORMAL; 140 t = SYM_NORMAL;
@@ -147,8 +149,8 @@ struct symbol *find_symbol(const char *name, enum symbol_type ns)
147 struct symbol *sym; 149 struct symbol *sym;
148 150
149 for (sym = symtab[h]; sym; sym = sym->hash_next) 151 for (sym = symtab[h]; sym; sym = sym->hash_next)
150 if (map_to_ns(sym->type) == map_to_ns(ns) 152 if (map_to_ns(sym->type) == map_to_ns(ns) &&
151 && strcmp(name, sym->name) == 0) 153 strcmp(name, sym->name) == 0)
152 break; 154 break;
153 155
154 return sym; 156 return sym;
@@ -160,13 +162,14 @@ struct symbol *add_symbol(const char *name, enum symbol_type type,
160 unsigned long h = crc32(name) % HASH_BUCKETS; 162 unsigned long h = crc32(name) % HASH_BUCKETS;
161 struct symbol *sym; 163 struct symbol *sym;
162 164
163 for (sym = symtab[h]; sym; sym = sym->hash_next) 165 for (sym = symtab[h]; sym; sym = sym->hash_next) {
164 if (map_to_ns(sym->type) == map_to_ns(type) 166 if (map_to_ns(sym->type) == map_to_ns(type)
165 && strcmp(name, sym->name) == 0) { 167 && strcmp(name, sym->name) == 0) {
166 if (!equal_list(sym->defn, defn)) 168 if (!equal_list(sym->defn, defn))
167 error_with_pos("redefinition of %s", name); 169 error_with_pos("redefinition of %s", name);
168 return sym; 170 return sym;
169 } 171 }
172 }
170 173
171 sym = xmalloc(sizeof(*sym)); 174 sym = xmalloc(sizeof(*sym));
172 sym->name = name; 175 sym->name = name;
@@ -193,7 +196,7 @@ struct symbol *add_symbol(const char *name, enum symbol_type type,
193 196
194/*----------------------------------------------------------------------*/ 197/*----------------------------------------------------------------------*/
195 198
196inline void free_node(struct string_list *node) 199void free_node(struct string_list *node)
197{ 200{
198 free(node->string); 201 free(node->string);
199 free(node); 202 free(node);
@@ -208,7 +211,7 @@ void free_list(struct string_list *s, struct string_list *e)
208 } 211 }
209} 212}
210 213
211inline struct string_list *copy_node(struct string_list *node) 214struct string_list *copy_node(struct string_list *node)
212{ 215{
213 struct string_list *newnode; 216 struct string_list *newnode;
214 217
@@ -219,22 +222,7 @@ inline struct string_list *copy_node(struct string_list *node)
219 return newnode; 222 return newnode;
220} 223}
221 224
222struct string_list *copy_list(struct string_list *s, struct string_list *e) 225static int equal_list(struct string_list *a, struct string_list *b)
223{
224 struct string_list *h, *p;
225
226 if (s == e)
227 return NULL;
228
229 p = h = copy_node(s);
230 while ((s = s->next) != e)
231 p = p->next = copy_node(s);
232 p->next = NULL;
233
234 return h;
235}
236
237int equal_list(struct string_list *a, struct string_list *b)
238{ 226{
239 while (a && b) { 227 while (a && b) {
240 if (a->tag != b->tag || strcmp(a->string, b->string)) 228 if (a->tag != b->tag || strcmp(a->string, b->string))
@@ -246,7 +234,7 @@ int equal_list(struct string_list *a, struct string_list *b)
246 return !a && !b; 234 return !a && !b;
247} 235}
248 236
249static inline void print_node(FILE * f, struct string_list *list) 237static void print_node(FILE * f, struct string_list *list)
250{ 238{
251 switch (list->tag) { 239 switch (list->tag) {
252 case SYM_STRUCT: 240 case SYM_STRUCT:
@@ -270,7 +258,7 @@ static inline void print_node(FILE * f, struct string_list *list)
270 } 258 }
271} 259}
272 260
273void print_list(FILE * f, struct string_list *list) 261static void print_list(FILE * f, struct string_list *list)
274{ 262{
275 struct string_list **e, **b; 263 struct string_list **e, **b;
276 struct string_list *tmp, **tmp2; 264 struct string_list *tmp, **tmp2;
@@ -299,8 +287,8 @@ void print_list(FILE * f, struct string_list *list)
299 } 287 }
300} 288}
301 289
302static unsigned long 290static unsigned long expand_and_crc_list(struct string_list *list,
303expand_and_crc_list(struct string_list *list, unsigned long crc) 291 unsigned long crc)
304{ 292{
305 struct string_list **e, **b; 293 struct string_list **e, **b;
306 struct string_list *tmp, **tmp2; 294 struct string_list *tmp, **tmp2;
@@ -386,9 +374,8 @@ expand_and_crc_list(struct string_list *list, unsigned long crc)
386 cur->string); 374 cur->string);
387 } 375 }
388 376
389 crc = 377 crc = partial_crc32(symbol_type_name[cur->tag],
390 partial_crc32(symbol_type_name[cur->tag], 378 crc);
391 crc);
392 crc = partial_crc32_one(' ', crc); 379 crc = partial_crc32_one(' ', crc);
393 crc = partial_crc32(cur->string, crc); 380 crc = partial_crc32(cur->string, crc);
394 crc = partial_crc32_one(' ', crc); 381 crc = partial_crc32_one(' ', crc);
@@ -437,21 +424,6 @@ void export_symbol(const char *name)
437} 424}
438 425
439/*----------------------------------------------------------------------*/ 426/*----------------------------------------------------------------------*/
440
441void error(const char *fmt, ...)
442{
443 va_list args;
444
445 if (flag_warnings) {
446 va_start(args, fmt);
447 vfprintf(stderr, fmt, args);
448 va_end(args);
449 putc('\n', stderr);
450
451 errors++;
452 }
453}
454
455void error_with_pos(const char *fmt, ...) 427void error_with_pos(const char *fmt, ...)
456{ 428{
457 va_list args; 429 va_list args;
@@ -469,7 +441,7 @@ void error_with_pos(const char *fmt, ...)
469 } 441 }
470} 442}
471 443
472void genksyms_usage(void) 444static void genksyms_usage(void)
473{ 445{
474 fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n" 446 fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n"
475#ifdef __GNU_LIBRARY__ 447#ifdef __GNU_LIBRARY__