diff options
| author | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-03-12 17:26:29 -0500 |
|---|---|---|
| committer | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-03-12 17:26:29 -0500 |
| commit | ce560686947fd50b30eaf42045554797f53949dd (patch) | |
| tree | ae04b6c366eec6c6ff9726a8034ffd61c269ce1b /scripts | |
| parent | 78c041530ac2e65c9290137bfe3004340e0840d2 (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')
| -rw-r--r-- | scripts/genksyms/genksyms.c | 80 | ||||
| -rw-r--r-- | scripts/genksyms/genksyms.h | 57 |
2 files changed, 43 insertions, 94 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 | ||
| 39 | static struct symbol *symtab[HASH_BUCKETS]; | 39 | static struct symbol *symtab[HASH_BUCKETS]; |
| 40 | FILE *debugfile; | 40 | static FILE *debugfile; |
| 41 | 41 | ||
| 42 | int cur_line = 1; | 42 | int cur_line = 1; |
| 43 | char *cur_filename, *output_directory; | 43 | char *cur_filename; |
| 44 | 44 | ||
| 45 | int flag_debug, flag_dump_defs, flag_warnings; | 45 | static int flag_debug, flag_dump_defs, flag_warnings; |
| 46 | const char *arch = ""; | 46 | static const char *arch = ""; |
| 47 | const char *mod_prefix = ""; | 47 | static const char *mod_prefix = ""; |
| 48 | 48 | ||
| 49 | static int errors; | 49 | static int errors; |
| 50 | static int nsyms; | 50 | static 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 | ||
| 58 | static int equal_list(struct string_list *a, struct string_list *b); | ||
| 59 | static void print_list(FILE * f, struct string_list *list); | ||
| 60 | |||
| 58 | /*----------------------------------------------------------------------*/ | 61 | /*----------------------------------------------------------------------*/ |
| 59 | 62 | ||
| 60 | static const unsigned int crctab32[] = { | 63 | static const unsigned int crctab32[] = { |
| @@ -112,27 +115,26 @@ static const unsigned int crctab32[] = { | |||
| 112 | 0x2d02ef8dU | 115 | 0x2d02ef8dU |
| 113 | }; | 116 | }; |
| 114 | 117 | ||
| 115 | static inline unsigned long | 118 | static unsigned long partial_crc32_one(unsigned char c, unsigned long crc) |
| 116 | partial_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 | ||
| 121 | static inline unsigned long partial_crc32(const char *s, unsigned long crc) | 123 | static 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 | ||
| 128 | static inline unsigned long crc32(const char *s) | 130 | static 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 | ||
| 135 | static inline enum symbol_type map_to_ns(enum symbol_type t) | 137 | static 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 | ||
| 196 | inline void free_node(struct string_list *node) | 199 | void 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 | ||
| 211 | inline struct string_list *copy_node(struct string_list *node) | 214 | struct 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 | ||
| 222 | struct string_list *copy_list(struct string_list *s, struct string_list *e) | 225 | static 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 | |||
| 237 | int 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 | ||
| 249 | static inline void print_node(FILE * f, struct string_list *list) | 237 | static 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 | ||
| 273 | void print_list(FILE * f, struct string_list *list) | 261 | static 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 | ||
| 302 | static unsigned long | 290 | static unsigned long expand_and_crc_list(struct string_list *list, |
| 303 | expand_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; |
