f2fs: Provide a splice-read wrapper
[linux-block.git] / scripts / genksyms / genksyms.h
CommitLineData
1a59d1b8 1/* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4
LT
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
1a59d1b8 10 */
1da177e4 11
1da177e4
LT
12#ifndef MODUTILS_GENKSYMS_H
13#define MODUTILS_GENKSYMS_H 1
14
15#include <stdio.h>
16
ce560686 17enum symbol_type {
e37ddb82
MM
18 SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION,
19 SYM_ENUM_CONST
1da177e4
LT
20};
21
64e6c1e1
AG
22enum symbol_status {
23 STATUS_UNCHANGED, STATUS_DEFINED, STATUS_MODIFIED
24};
25
ce560686
SR
26struct string_list {
27 struct string_list *next;
28 enum symbol_type tag;
2c5925d6 29 int in_source_file;
ce560686 30 char *string;
1da177e4
LT
31};
32
ce560686
SR
33struct symbol {
34 struct symbol *hash_next;
35 const char *name;
36 enum symbol_type type;
37 struct string_list *defn;
38 struct symbol *expansion_trail;
15fde675 39 struct symbol *visited;
ce560686 40 int is_extern;
64e6c1e1
AG
41 int is_declared;
42 enum symbol_status status;
5dae9a55 43 int is_override;
1da177e4
LT
44};
45
46typedef struct string_list **yystype;
47#define YYSTYPE yystype
48
1da177e4 49extern int cur_line;
ab37d5a4 50extern char *cur_filename;
2c5925d6 51extern int in_source_file;
1da177e4 52
01762c4e 53struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
1da177e4 54struct symbol *add_symbol(const char *name, enum symbol_type type,
ce560686 55 struct string_list *defn, int is_extern);
1da177e4
LT
56void export_symbol(const char *);
57
1da177e4 58void free_node(struct string_list *list);
ce560686 59void free_list(struct string_list *s, struct string_list *e);
1da177e4 60struct string_list *copy_node(struct string_list *);
e37ddb82
MM
61struct string_list *copy_list_range(struct string_list *start,
62 struct string_list *end);
1da177e4
LT
63
64int yylex(void);
65int yyparse(void);
66
3def0344 67void error_with_pos(const char *, ...) __attribute__ ((format(printf, 1, 2)));
1da177e4 68
1da177e4 69/*----------------------------------------------------------------------*/
1da177e4
LT
70#define xmalloc(size) ({ void *__ptr = malloc(size); \
71 if(!__ptr && size != 0) { \
72 fprintf(stderr, "out of memory\n"); \
73 exit(1); \
74 } \
75 __ptr; })
76#define xstrdup(str) ({ char *__str = strdup(str); \
77 if (!__str) { \
78 fprintf(stderr, "out of memory\n"); \
79 exit(1); \
80 } \
81 __str; })
82
ce560686 83#endif /* genksyms.h */