genksyms.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. int in_source_file;
  31. char *string;
  32. };
  33. struct 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;
  39. struct symbol *visited;
  40. int is_extern;
  41. int is_declared;
  42. enum symbol_status status;
  43. int is_override;
  44. };
  45. typedef struct string_list **yystype;
  46. #define YYSTYPE yystype
  47. extern int cur_line;
  48. extern char *cur_filename, *source_file;
  49. extern int in_source_file;
  50. struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
  51. struct symbol *add_symbol(const char *name, enum symbol_type type,
  52. struct string_list *defn, int is_extern);
  53. void export_symbol(const char *);
  54. void free_node(struct string_list *list);
  55. void free_list(struct string_list *s, struct string_list *e);
  56. struct string_list *copy_node(struct string_list *);
  57. struct string_list *copy_list_range(struct string_list *start,
  58. struct string_list *end);
  59. int yylex(void);
  60. int yyparse(void);
  61. void error_with_pos(const char *, ...) __attribute__ ((format(printf, 1, 2)));
  62. /*----------------------------------------------------------------------*/
  63. #define xmalloc(size) ({ void *__ptr = malloc(size); \
  64. if(!__ptr && size != 0) { \
  65. fprintf(stderr, "out of memory\n"); \
  66. exit(1); \
  67. } \
  68. __ptr; })
  69. #define xstrdup(str) ({ char *__str = strdup(str); \
  70. if (!__str) { \
  71. fprintf(stderr, "out of memory\n"); \
  72. exit(1); \
  73. } \
  74. __str; })
  75. #endif /* genksyms.h */