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