genksyms.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. };
  23. struct string_list {
  24. struct string_list *next;
  25. enum symbol_type tag;
  26. char *string;
  27. };
  28. struct symbol {
  29. struct symbol *hash_next;
  30. const char *name;
  31. enum symbol_type type;
  32. struct string_list *defn;
  33. struct symbol *expansion_trail;
  34. struct symbol *visited;
  35. int is_extern;
  36. };
  37. typedef struct string_list **yystype;
  38. #define YYSTYPE yystype
  39. extern int cur_line;
  40. extern char *cur_filename;
  41. struct symbol *find_symbol(const char *name, enum symbol_type ns);
  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. int yylex(void);
  49. int yyparse(void);
  50. void error_with_pos(const char *, ...);
  51. /*----------------------------------------------------------------------*/
  52. #define xmalloc(size) ({ void *__ptr = malloc(size); \
  53. if(!__ptr && size != 0) { \
  54. fprintf(stderr, "out of memory\n"); \
  55. exit(1); \
  56. } \
  57. __ptr; })
  58. #define xstrdup(str) ({ char *__str = strdup(str); \
  59. if (!__str) { \
  60. fprintf(stderr, "out of memory\n"); \
  61. exit(1); \
  62. } \
  63. __str; })
  64. #endif /* genksyms.h */