genksyms.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <stdio.h>
  11. enum symbol_type {
  12. SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION,
  13. SYM_ENUM_CONST
  14. };
  15. enum symbol_status {
  16. STATUS_UNCHANGED, STATUS_DEFINED, STATUS_MODIFIED
  17. };
  18. struct string_list {
  19. struct string_list *next;
  20. enum symbol_type tag;
  21. int in_source_file;
  22. char *string;
  23. };
  24. struct symbol {
  25. struct symbol *hash_next;
  26. const char *name;
  27. enum symbol_type type;
  28. struct string_list *defn;
  29. struct symbol *expansion_trail;
  30. struct symbol *visited;
  31. int is_extern;
  32. int is_declared;
  33. enum symbol_status status;
  34. int is_override;
  35. };
  36. typedef struct string_list **yystype;
  37. #define YYSTYPE yystype
  38. extern int cur_line;
  39. extern char *cur_filename, *source_file;
  40. extern int in_source_file;
  41. struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
  42. struct symbol *add_symbol(const char *name, enum symbol_type type,
  43. struct string_list *defn, int is_extern);
  44. void export_symbol(const char *);
  45. void free_node(struct string_list *list);
  46. void free_list(struct string_list *s, struct string_list *e);
  47. struct string_list *copy_node(struct string_list *);
  48. struct string_list *copy_list_range(struct string_list *start,
  49. struct string_list *end);
  50. int yylex(void);
  51. int yyparse(void);
  52. void error_with_pos(const char *, ...) __attribute__ ((format(printf, 1, 2)));
  53. /*----------------------------------------------------------------------*/
  54. #define xmalloc(size) ({ void *__ptr = malloc(size); \
  55. if(!__ptr && size != 0) { \
  56. fprintf(stderr, "out of memory\n"); \
  57. exit(1); \
  58. } \
  59. __ptr; })
  60. #define xstrdup(str) ({ char *__str = strdup(str); \
  61. if (!__str) { \
  62. fprintf(stderr, "out of memory\n"); \
  63. exit(1); \
  64. } \
  65. __str; })
  66. #endif /* genksyms.h */