genksyms.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Generate kernel symbol version hashes.
  2. Copyright 1996, 1997 Linux International.
  3. New implementation contributed by Richard Henderson <rth@tamu.edu>
  4. Based on original work by Bjorn Ekwall <bj0rn@blox.se>
  5. This file is part of the Linux modutils.
  6. This program is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation; either version 2 of the License, or (at your
  9. option) any later version.
  10. This program is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software Foundation,
  16. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. #ifndef MODUTILS_GENKSYMS_H
  18. #define MODUTILS_GENKSYMS_H 1
  19. #include <stdio.h>
  20. enum symbol_type {
  21. SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION,
  22. SYM_ENUM_CONST
  23. };
  24. enum symbol_status {
  25. STATUS_UNCHANGED, STATUS_DEFINED, STATUS_MODIFIED
  26. };
  27. struct string_list {
  28. struct string_list *next;
  29. enum symbol_type tag;
  30. char *string;
  31. };
  32. struct symbol {
  33. struct symbol *hash_next;
  34. const char *name;
  35. enum symbol_type type;
  36. struct string_list *defn;
  37. struct symbol *expansion_trail;
  38. struct symbol *visited;
  39. int is_extern;
  40. int is_declared;
  41. enum symbol_status status;
  42. int is_override;
  43. };
  44. typedef struct string_list **yystype;
  45. #define YYSTYPE yystype
  46. extern int cur_line;
  47. extern char *cur_filename;
  48. struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
  49. struct symbol *add_symbol(const char *name, enum symbol_type type,
  50. struct string_list *defn, int is_extern);
  51. void export_symbol(const char *);
  52. void free_node(struct string_list *list);
  53. void free_list(struct string_list *s, struct string_list *e);
  54. struct string_list *copy_node(struct string_list *);
  55. struct string_list *copy_list_range(struct string_list *start,
  56. struct string_list *end);
  57. int yylex(void);
  58. int yyparse(void);
  59. void error_with_pos(const char *, ...);
  60. /*----------------------------------------------------------------------*/
  61. #define xmalloc(size) ({ void *__ptr = malloc(size); \
  62. if(!__ptr && size != 0) { \
  63. fprintf(stderr, "out of memory\n"); \
  64. exit(1); \
  65. } \
  66. __ptr; })
  67. #define xstrdup(str) ({ char *__str = strdup(str); \
  68. if (!__str) { \
  69. fprintf(stderr, "out of memory\n"); \
  70. exit(1); \
  71. } \
  72. __str; })
  73. #endif /* genksyms.h */