genksyms.h 2.1 KB

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