1254721Semaste/*  This file is part of the program psim.
2254721Semaste
3353358Sdim    Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
4353358Sdim
5353358Sdim    This program is free software; you can redistribute it and/or modify
6254721Semaste    it under the terms of the GNU General Public License as published by
7254721Semaste    the Free Software Foundation; either version 3 of the License, or
8254721Semaste    (at your option) any later version.
9254721Semaste
10254721Semaste    This program is distributed in the hope that it will be useful,
11254721Semaste    but WITHOUT ANY WARRANTY; without even the implied warranty of
12254721Semaste    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13254721Semaste    GNU General Public License for more details.
14254721Semaste
15341825Sdim    You should have received a copy of the GNU General Public License
16321369Sdim    along with this program; if not, see <http://www.gnu.org/licenses/>.
17254721Semaste
18254721Semaste    */
19254721Semaste
20254721Semaste
21254721Semaste/* Frustrating header junk */
22314564Sdim
23254721Semaste#include "build-config.h"
24314564Sdim
25314564Sdim#include <stdio.h>
26314564Sdim#include <ctype.h>
27314564Sdim#include <string.h>
28254721Semaste#include <stdlib.h>
29314564Sdim
30280031Sdim#include "ansidecl.h"
31314564Sdim#include "filter_filename.h"
32254721Semaste
33314564Sdimextern void error (const char *msg, ...)
34254721Semaste  ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
35314564Sdim
36314564Sdim#define ASSERT(EXPRESSION) \
37360784Sdimdo { \
38314564Sdim  if (!(EXPRESSION)) { \
39254721Semaste    error("%s:%d: assertion failed - %s\n", \
40341825Sdim	  filter_filename (__FILE__), __LINE__, #EXPRESSION); \
41254721Semaste  } \
42314564Sdim} while (0)
43314564Sdim
44314564Sdim#define ZALLOC(TYPE) (TYPE*)zalloc(sizeof(TYPE))
45314564Sdim#define NZALLOC(TYPE,N) ((TYPE*) zalloc (sizeof(TYPE) * (N)))
46254721Semaste
47314564Sdimextern void *zalloc
48314564Sdim(long size);
49314564Sdim
50314564Sdimextern void dumpf (int indent, const char *msg, ...)
51314564Sdim  ATTRIBUTE_PRINTF (2, 3);
52254721Semaste
53254721Semasteextern unsigned target_a2i
54314564Sdim(int ms_bit_nr,
55254721Semaste const char *a);
56254721Semaste
57254721Semasteextern unsigned i2target
58254721Semaste(int ms_bit_nr,
59296417Sdim unsigned bit);
60
61extern unsigned a2i
62(const char *a);
63
64/* Try looking for name in the map table (returning the corresponding
65   integer value).  If that fails, try converting the name into an
66   integer */
67
68typedef struct _name_map {
69  const char *name;
70  int i;
71} name_map;
72
73extern int name2i
74(const char *name,
75 const name_map *map);
76
77extern const char *i2name
78(const int i,
79 const name_map *map);
80