misc.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* This file is part of the program psim.
  2. Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /* Frustrating header junk */
  15. #include "build-config.h"
  16. #include <stdio.h>
  17. #include <ctype.h>
  18. #ifdef HAVE_STRING_H
  19. #include <string.h>
  20. #else
  21. #ifdef HAVE_STRINGS_H
  22. #include <strings.h>
  23. #endif
  24. #endif
  25. #ifdef HAVE_STDLIB_H
  26. #include <stdlib.h>
  27. #endif
  28. #if !defined (__attribute__) && (!defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
  29. #define __attribute__(arg)
  30. #endif
  31. #include "filter_filename.h"
  32. extern void error
  33. (char *msg, ...);
  34. #define ASSERT(EXPRESSION) \
  35. do { \
  36. if (!(EXPRESSION)) { \
  37. error("%s:%d: assertion failed - %s\n", \
  38. filter_filename (__FILE__), __LINE__, #EXPRESSION); \
  39. } \
  40. } while (0)
  41. #define ZALLOC(TYPE) (TYPE*)zalloc(sizeof(TYPE))
  42. #define NZALLOC(TYPE,N) ((TYPE*) zalloc (sizeof(TYPE) * (N)))
  43. extern void *zalloc
  44. (long size);
  45. extern void dumpf
  46. (int indent, char *msg, ...);
  47. extern unsigned target_a2i
  48. (int ms_bit_nr,
  49. const char *a);
  50. extern unsigned i2target
  51. (int ms_bit_nr,
  52. unsigned bit);
  53. extern unsigned a2i
  54. (const char *a);
  55. /* Try looking for name in the map table (returning the corresponding
  56. integer value). If that fails, try converting the name into an
  57. integer */
  58. typedef struct _name_map {
  59. const char *name;
  60. int i;
  61. } name_map;
  62. extern int name2i
  63. (const char *name,
  64. const name_map *map);
  65. extern const char *i2name
  66. (const int i,
  67. const name_map *map);