mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-20 11:34:02 +08:00
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>
This commit is contained in:
parent
78c041530a
commit
ce56068694
@ -37,14 +37,14 @@
|
|||||||
#define HASH_BUCKETS 4096
|
#define HASH_BUCKETS 4096
|
||||||
|
|
||||||
static struct symbol *symtab[HASH_BUCKETS];
|
static struct symbol *symtab[HASH_BUCKETS];
|
||||||
FILE *debugfile;
|
static FILE *debugfile;
|
||||||
|
|
||||||
int cur_line = 1;
|
int cur_line = 1;
|
||||||
char *cur_filename, *output_directory;
|
char *cur_filename;
|
||||||
|
|
||||||
int flag_debug, flag_dump_defs, flag_warnings;
|
static int flag_debug, flag_dump_defs, flag_warnings;
|
||||||
const char *arch = "";
|
static const char *arch = "";
|
||||||
const char *mod_prefix = "";
|
static const char *mod_prefix = "";
|
||||||
|
|
||||||
static int errors;
|
static int errors;
|
||||||
static int nsyms;
|
static int nsyms;
|
||||||
@ -55,6 +55,9 @@ static const char *const symbol_type_name[] = {
|
|||||||
"normal", "typedef", "enum", "struct", "union"
|
"normal", "typedef", "enum", "struct", "union"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int equal_list(struct string_list *a, struct string_list *b);
|
||||||
|
static void print_list(FILE * f, struct string_list *list);
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static const unsigned int crctab32[] = {
|
static const unsigned int crctab32[] = {
|
||||||
@ -112,27 +115,26 @@ static const unsigned int crctab32[] = {
|
|||||||
0x2d02ef8dU
|
0x2d02ef8dU
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline unsigned long
|
static unsigned long partial_crc32_one(unsigned char c, unsigned long crc)
|
||||||
partial_crc32_one(unsigned char c, unsigned long crc)
|
|
||||||
{
|
{
|
||||||
return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
|
return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long partial_crc32(const char *s, unsigned long crc)
|
static unsigned long partial_crc32(const char *s, unsigned long crc)
|
||||||
{
|
{
|
||||||
while (*s)
|
while (*s)
|
||||||
crc = partial_crc32_one(*s++, crc);
|
crc = partial_crc32_one(*s++, crc);
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long crc32(const char *s)
|
static unsigned long crc32(const char *s)
|
||||||
{
|
{
|
||||||
return partial_crc32(s, 0xffffffff) ^ 0xffffffff;
|
return partial_crc32(s, 0xffffffff) ^ 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static inline enum symbol_type map_to_ns(enum symbol_type t)
|
static enum symbol_type map_to_ns(enum symbol_type t)
|
||||||
{
|
{
|
||||||
if (t == SYM_TYPEDEF)
|
if (t == SYM_TYPEDEF)
|
||||||
t = SYM_NORMAL;
|
t = SYM_NORMAL;
|
||||||
@ -147,8 +149,8 @@ struct symbol *find_symbol(const char *name, enum symbol_type ns)
|
|||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
|
|
||||||
for (sym = symtab[h]; sym; sym = sym->hash_next)
|
for (sym = symtab[h]; sym; sym = sym->hash_next)
|
||||||
if (map_to_ns(sym->type) == map_to_ns(ns)
|
if (map_to_ns(sym->type) == map_to_ns(ns) &&
|
||||||
&& strcmp(name, sym->name) == 0)
|
strcmp(name, sym->name) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
return sym;
|
return sym;
|
||||||
@ -160,13 +162,14 @@ struct symbol *add_symbol(const char *name, enum symbol_type type,
|
|||||||
unsigned long h = crc32(name) % HASH_BUCKETS;
|
unsigned long h = crc32(name) % HASH_BUCKETS;
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
|
|
||||||
for (sym = symtab[h]; sym; sym = sym->hash_next)
|
for (sym = symtab[h]; sym; sym = sym->hash_next) {
|
||||||
if (map_to_ns(sym->type) == map_to_ns(type)
|
if (map_to_ns(sym->type) == map_to_ns(type)
|
||||||
&& strcmp(name, sym->name) == 0) {
|
&& strcmp(name, sym->name) == 0) {
|
||||||
if (!equal_list(sym->defn, defn))
|
if (!equal_list(sym->defn, defn))
|
||||||
error_with_pos("redefinition of %s", name);
|
error_with_pos("redefinition of %s", name);
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sym = xmalloc(sizeof(*sym));
|
sym = xmalloc(sizeof(*sym));
|
||||||
sym->name = name;
|
sym->name = name;
|
||||||
@ -193,7 +196,7 @@ struct symbol *add_symbol(const char *name, enum symbol_type type,
|
|||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
inline void free_node(struct string_list *node)
|
void free_node(struct string_list *node)
|
||||||
{
|
{
|
||||||
free(node->string);
|
free(node->string);
|
||||||
free(node);
|
free(node);
|
||||||
@ -208,7 +211,7 @@ void free_list(struct string_list *s, struct string_list *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline struct string_list *copy_node(struct string_list *node)
|
struct string_list *copy_node(struct string_list *node)
|
||||||
{
|
{
|
||||||
struct string_list *newnode;
|
struct string_list *newnode;
|
||||||
|
|
||||||
@ -219,22 +222,7 @@ inline struct string_list *copy_node(struct string_list *node)
|
|||||||
return newnode;
|
return newnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct string_list *copy_list(struct string_list *s, struct string_list *e)
|
static int equal_list(struct string_list *a, struct string_list *b)
|
||||||
{
|
|
||||||
struct string_list *h, *p;
|
|
||||||
|
|
||||||
if (s == e)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
p = h = copy_node(s);
|
|
||||||
while ((s = s->next) != e)
|
|
||||||
p = p->next = copy_node(s);
|
|
||||||
p->next = NULL;
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
int equal_list(struct string_list *a, struct string_list *b)
|
|
||||||
{
|
{
|
||||||
while (a && b) {
|
while (a && b) {
|
||||||
if (a->tag != b->tag || strcmp(a->string, b->string))
|
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)
|
|||||||
return !a && !b;
|
return !a && !b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void print_node(FILE * f, struct string_list *list)
|
static void print_node(FILE * f, struct string_list *list)
|
||||||
{
|
{
|
||||||
switch (list->tag) {
|
switch (list->tag) {
|
||||||
case SYM_STRUCT:
|
case SYM_STRUCT:
|
||||||
@ -270,7 +258,7 @@ static inline void print_node(FILE * f, struct string_list *list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_list(FILE * f, struct string_list *list)
|
static void print_list(FILE * f, struct string_list *list)
|
||||||
{
|
{
|
||||||
struct string_list **e, **b;
|
struct string_list **e, **b;
|
||||||
struct string_list *tmp, **tmp2;
|
struct string_list *tmp, **tmp2;
|
||||||
@ -299,8 +287,8 @@ void print_list(FILE * f, struct string_list *list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long
|
static unsigned long expand_and_crc_list(struct string_list *list,
|
||||||
expand_and_crc_list(struct string_list *list, unsigned long crc)
|
unsigned long crc)
|
||||||
{
|
{
|
||||||
struct string_list **e, **b;
|
struct string_list **e, **b;
|
||||||
struct string_list *tmp, **tmp2;
|
struct string_list *tmp, **tmp2;
|
||||||
@ -386,9 +374,8 @@ expand_and_crc_list(struct string_list *list, unsigned long crc)
|
|||||||
cur->string);
|
cur->string);
|
||||||
}
|
}
|
||||||
|
|
||||||
crc =
|
crc = partial_crc32(symbol_type_name[cur->tag],
|
||||||
partial_crc32(symbol_type_name[cur->tag],
|
crc);
|
||||||
crc);
|
|
||||||
crc = partial_crc32_one(' ', crc);
|
crc = partial_crc32_one(' ', crc);
|
||||||
crc = partial_crc32(cur->string, crc);
|
crc = partial_crc32(cur->string, crc);
|
||||||
crc = partial_crc32_one(' ', crc);
|
crc = partial_crc32_one(' ', crc);
|
||||||
@ -437,21 +424,6 @@ void export_symbol(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
void error(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
if (flag_warnings) {
|
|
||||||
va_start(args, fmt);
|
|
||||||
vfprintf(stderr, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
putc('\n', stderr);
|
|
||||||
|
|
||||||
errors++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void error_with_pos(const char *fmt, ...)
|
void error_with_pos(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -469,7 +441,7 @@ void error_with_pos(const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void genksyms_usage(void)
|
static void genksyms_usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n"
|
fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n"
|
||||||
#ifdef __GNU_LIBRARY__
|
#ifdef __GNU_LIBRARY__
|
||||||
|
@ -20,74 +20,51 @@
|
|||||||
along with this program; if not, write to the Free Software Foundation,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
|
||||||
#ifndef MODUTILS_GENKSYMS_H
|
#ifndef MODUTILS_GENKSYMS_H
|
||||||
#define MODUTILS_GENKSYMS_H 1
|
#define MODUTILS_GENKSYMS_H 1
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
enum symbol_type {
|
||||||
enum symbol_type
|
SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
|
||||||
{
|
|
||||||
SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct string_list
|
struct string_list {
|
||||||
{
|
struct string_list *next;
|
||||||
struct string_list *next;
|
enum symbol_type tag;
|
||||||
enum symbol_type tag;
|
char *string;
|
||||||
char *string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct symbol
|
struct symbol {
|
||||||
{
|
struct symbol *hash_next;
|
||||||
struct symbol *hash_next;
|
const char *name;
|
||||||
const char *name;
|
enum symbol_type type;
|
||||||
enum symbol_type type;
|
struct string_list *defn;
|
||||||
struct string_list *defn;
|
struct symbol *expansion_trail;
|
||||||
struct symbol *expansion_trail;
|
int is_extern;
|
||||||
int is_extern;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct string_list **yystype;
|
typedef struct string_list **yystype;
|
||||||
#define YYSTYPE yystype
|
#define YYSTYPE yystype
|
||||||
|
|
||||||
extern FILE *outfile, *debugfile;
|
|
||||||
|
|
||||||
extern int cur_line;
|
extern int cur_line;
|
||||||
extern char *cur_filename, *output_directory;
|
extern char *cur_filename;
|
||||||
|
|
||||||
extern int flag_debug, flag_dump_defs, flag_warnings;
|
|
||||||
extern int checksum_version, kernel_version;
|
|
||||||
|
|
||||||
extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents;
|
|
||||||
extern struct string_list *current_list, *next_list;
|
|
||||||
|
|
||||||
|
|
||||||
struct symbol *find_symbol(const char *name, enum symbol_type ns);
|
struct symbol *find_symbol(const char *name, enum symbol_type ns);
|
||||||
struct symbol *add_symbol(const char *name, enum symbol_type type,
|
struct symbol *add_symbol(const char *name, enum symbol_type type,
|
||||||
struct string_list *defn, int is_extern);
|
struct string_list *defn, int is_extern);
|
||||||
void export_symbol(const char *);
|
void export_symbol(const char *);
|
||||||
|
|
||||||
struct string_list *reset_list(void);
|
|
||||||
void free_list(struct string_list *s, struct string_list *e);
|
|
||||||
void free_node(struct string_list *list);
|
void free_node(struct string_list *list);
|
||||||
|
void free_list(struct string_list *s, struct string_list *e);
|
||||||
struct string_list *copy_node(struct string_list *);
|
struct string_list *copy_node(struct string_list *);
|
||||||
struct string_list *copy_list(struct string_list *s, struct string_list *e);
|
|
||||||
int equal_list(struct string_list *a, struct string_list *b);
|
|
||||||
void print_list(FILE *, struct string_list *list);
|
|
||||||
|
|
||||||
int yylex(void);
|
int yylex(void);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
|
|
||||||
void error_with_pos(const char *, ...);
|
void error_with_pos(const char *, ...);
|
||||||
|
|
||||||
#define version(a,b,c) ((a << 16) | (b << 8) | (c))
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define MODUTILS_VERSION "<in-kernel>"
|
|
||||||
|
|
||||||
#define xmalloc(size) ({ void *__ptr = malloc(size); \
|
#define xmalloc(size) ({ void *__ptr = malloc(size); \
|
||||||
if(!__ptr && size != 0) { \
|
if(!__ptr && size != 0) { \
|
||||||
fprintf(stderr, "out of memory\n"); \
|
fprintf(stderr, "out of memory\n"); \
|
||||||
@ -101,4 +78,4 @@ void error_with_pos(const char *, ...);
|
|||||||
} \
|
} \
|
||||||
__str; })
|
__str; })
|
||||||
|
|
||||||
#endif /* genksyms.h */
|
#endif /* genksyms.h */
|
||||||
|
Loading…
Reference in New Issue
Block a user