genksyms.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. int is_extern;
  35. };
  36. typedef struct string_list **yystype;
  37. #define YYSTYPE yystype
  38. extern int cur_line;
  39. extern char *cur_filename;
  40. struct symbol *find_symbol(const char *name, enum symbol_type ns);
  41. struct symbol *add_symbol(const char *name, enum symbol_type type,
  42. struct string_list *defn, int is_extern);
  43. void export_symbol(const char *);
  44. void free_node(struct string_list *list);
  45. void free_list(struct string_list *s, struct string_list *e);
  46. struct string_list *copy_node(struct string_list *);
  47. int yylex(void);
  48. int yyparse(void);
  49. void error_with_pos(const char *, ...);
  50. /*----------------------------------------------------------------------*/
  51. #define xmalloc(size) ({ void *__ptr = malloc(size); \
  52. if(!__ptr && size != 0) { \
  53. fprintf(stderr, "out of memory\n"); \
  54. exit(1); \
  55. } \
  56. __ptr; })
  57. #define xstrdup(str) ({ char *__str = strdup(str); \
  58. if (!__str) { \
  59. fprintf(stderr, "out of memory\n"); \
  60. exit(1); \
  61. } \
  62. __str; })
  63. #endif /* genksyms.h */