genksyms.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. enum symbol_status {
  24. STATUS_UNCHANGED, STATUS_DEFINED, STATUS_MODIFIED
  25. };
  26. struct string_list {
  27. struct string_list *next;
  28. enum symbol_type tag;
  29. char *string;
  30. };
  31. struct symbol {
  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. struct symbol *visited;
  38. int is_extern;
  39. int is_declared;
  40. enum symbol_status status;
  41. int is_override;
  42. };
  43. typedef struct string_list **yystype;
  44. #define YYSTYPE yystype
  45. extern int cur_line;
  46. extern char *cur_filename;
  47. struct symbol *find_symbol(const char *name, enum symbol_type ns);
  48. struct symbol *add_symbol(const char *name, enum symbol_type type,
  49. struct string_list *defn, int is_extern);
  50. void export_symbol(const char *);
  51. void free_node(struct string_list *list);
  52. void free_list(struct string_list *s, struct string_list *e);
  53. struct string_list *copy_node(struct string_list *);
  54. int yylex(void);
  55. int yyparse(void);
  56. void error_with_pos(const char *, ...);
  57. /*----------------------------------------------------------------------*/
  58. #define xmalloc(size) ({ void *__ptr = malloc(size); \
  59. if(!__ptr && size != 0) { \
  60. fprintf(stderr, "out of memory\n"); \
  61. exit(1); \
  62. } \
  63. __ptr; })
  64. #define xstrdup(str) ({ char *__str = strdup(str); \
  65. if (!__str) { \
  66. fprintf(stderr, "out of memory\n"); \
  67. exit(1); \
  68. } \
  69. __str; })
  70. #endif /* genksyms.h */