misc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* The IGEN simulator generator for GDB, the GNU Debugger.
  2. Copyright 2002-2022 Free Software Foundation, Inc.
  3. Contributed by Andrew Cagney.
  4. This file is part of GDB.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /* Frustrating header junk */
  16. enum
  17. {
  18. default_insn_bit_size = 32,
  19. max_insn_bit_size = 64,
  20. };
  21. #include <ctype.h>
  22. #include <stdint.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #if !defined (__attribute__) && (!defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
  27. #define __attribute__(arg)
  28. #endif
  29. #include "filter_host.h"
  30. typedef struct _line_ref line_ref;
  31. struct _line_ref
  32. {
  33. const char *file_name;
  34. int line_nr;
  35. };
  36. /* Error appends a new line, warning and notify do not */
  37. typedef void error_func (const line_ref *line, char *msg, ...);
  38. extern error_func error;
  39. extern error_func warning;
  40. extern error_func notify;
  41. #define ERROR(EXPRESSION) \
  42. do { \
  43. line_ref line; \
  44. line.file_name = filter_filename (__FILE__); \
  45. line.line_nr = __LINE__; \
  46. error (&line, EXPRESSION); \
  47. } while (0)
  48. #define ASSERT(EXPRESSION) \
  49. do { \
  50. if (!(EXPRESSION)) { \
  51. line_ref line; \
  52. line.file_name = filter_filename (__FILE__); \
  53. line.line_nr = __LINE__; \
  54. error(&line, "assertion failed - %s\n", #EXPRESSION); \
  55. } \
  56. } while (0)
  57. #define ZALLOC(TYPE) ((TYPE*) zalloc (sizeof(TYPE)))
  58. #define NZALLOC(TYPE,N) ((TYPE*) zalloc (sizeof(TYPE) * (N)))
  59. extern void *zalloc (long size);
  60. extern unsigned target_a2i (int ms_bit_nr, const char *a);
  61. extern unsigned i2target (int ms_bit_nr, unsigned bit);
  62. extern unsigned long long a2i (const char *a);
  63. /* Try looking for name in the map table (returning the corresponding
  64. integer value).
  65. If the the sentinal (NAME == NULL) its value if >= zero is returned
  66. as the default. */
  67. typedef struct _name_map
  68. {
  69. const char *name;
  70. int i;
  71. }
  72. name_map;
  73. extern int name2i (const char *name, const name_map * map);
  74. extern const char *i2name (const int i, const name_map * map);