genksyms.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. {
  22. SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
  23. };
  24. struct string_list
  25. {
  26. struct string_list *next;
  27. enum symbol_type tag;
  28. char *string;
  29. };
  30. struct symbol
  31. {
  32. struct symbol *hash_next;
  33. const char *name;
  34. enum symbol_type type;
  35. struct string_list *defn;
  36. struct symbol *expansion_trail;
  37. int is_extern;
  38. };
  39. typedef struct string_list **yystype;
  40. #define YYSTYPE yystype
  41. extern FILE *outfile, *debugfile;
  42. extern int cur_line;
  43. extern char *cur_filename, *output_directory;
  44. extern int flag_debug, flag_dump_defs, flag_warnings;
  45. extern int checksum_version, kernel_version;
  46. extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents;
  47. extern struct string_list *current_list, *next_list;
  48. struct symbol *find_symbol(const char *name, enum symbol_type ns);
  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. struct string_list *reset_list(void);
  53. void free_list(struct string_list *s, struct string_list *e);
  54. void free_node(struct string_list *list);
  55. struct string_list *copy_node(struct string_list *);
  56. struct string_list *copy_list(struct string_list *s, struct string_list *e);
  57. int equal_list(struct string_list *a, struct string_list *b);
  58. void print_list(FILE *, struct string_list *list);
  59. int yylex(void);
  60. int yyparse(void);
  61. void error_with_pos(const char *, ...);
  62. #define version(a,b,c) ((a << 16) | (b << 8) | (c))
  63. /*----------------------------------------------------------------------*/
  64. #define MODUTILS_VERSION "<in-kernel>"
  65. #define xmalloc(size) ({ void *__ptr = malloc(size); \
  66. if(!__ptr && size != 0) { \
  67. fprintf(stderr, "out of memory\n"); \
  68. exit(1); \
  69. } \
  70. __ptr; })
  71. #define xstrdup(str) ({ char *__str = strdup(str); \
  72. if (!__str) { \
  73. fprintf(stderr, "out of memory\n"); \
  74. exit(1); \
  75. } \
  76. __str; })
  77. #endif /* genksyms.h */