^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Generate kernel symbol version hashes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Copyright 1996, 1997 Linux International.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) New implementation contributed by Richard Henderson <rth@tamu.edu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Based on original work by Bjorn Ekwall <bj0rn@blox.se>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) This file is part of the Linux modutils.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifndef MODUTILS_GENKSYMS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define MODUTILS_GENKSYMS_H 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) enum symbol_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) SYM_ENUM_CONST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) enum symbol_status {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) STATUS_UNCHANGED, STATUS_DEFINED, STATUS_MODIFIED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct string_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct string_list *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) enum symbol_type tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int in_source_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) char *string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct symbol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct symbol *hash_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) enum symbol_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct string_list *defn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct symbol *expansion_trail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct symbol *visited;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int is_extern;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int is_declared;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) enum symbol_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int is_override;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) typedef struct string_list **yystype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define YYSTYPE yystype
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) extern int cur_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) extern char *cur_filename, *source_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern int in_source_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct symbol *add_symbol(const char *name, enum symbol_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct string_list *defn, int is_extern);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) void export_symbol(const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void free_node(struct string_list *list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void free_list(struct string_list *s, struct string_list *e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct string_list *copy_node(struct string_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct string_list *copy_list_range(struct string_list *start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct string_list *end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int yylex(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int yyparse(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) void error_with_pos(const char *, ...) __attribute__ ((format(printf, 1, 2)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /*----------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define xmalloc(size) ({ void *__ptr = malloc(size); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if(!__ptr && size != 0) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) fprintf(stderr, "out of memory\n"); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) exit(1); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) __ptr; })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define xstrdup(str) ({ char *__str = strdup(str); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (!__str) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) fprintf(stderr, "out of memory\n"); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) exit(1); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) __str; })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #endif /* genksyms.h */