2002-11-21 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / sim / igen / misc.h
1 /* The IGEN simulator generator for GDB, the GNU Debugger.
2
3 Copyright 2002 Free Software Foundation, Inc.
4
5 Contributed by Andrew Cagney.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
23
24
25
26 /* Frustrating header junk */
27
28 #include "config.h"
29
30
31 enum {
32 default_insn_bit_size = 32,
33 max_insn_bit_size = 64,
34 };
35
36
37 /* Define a 64bit data type */
38
39 #if defined __GNUC__ || defined _WIN32
40 #ifdef __GNUC__
41
42 typedef long long signed64;
43 typedef unsigned long long unsigned64;
44
45 #else /* _WIN32 */
46
47 typedef __int64 signed64;
48 typedef unsigned __int64 unsigned64;
49
50 #endif /* _WIN32 */
51 #else /* Not GNUC or WIN32 */
52 /* Not supported */
53 #endif
54
55
56 #include <stdio.h>
57 #include <ctype.h>
58
59 #ifdef HAVE_STRING_H
60 #include <string.h>
61 #else
62 #ifdef HAVE_STRINGS_H
63 #include <strings.h>
64 #endif
65 #endif
66
67 #ifdef HAVE_STDLIB_H
68 #include <stdlib.h>
69 #endif
70
71 #if !defined (__attribute__) && (!defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
72 #define __attribute__(arg)
73 #endif
74
75
76
77 #include "filter_host.h"
78
79 typedef struct _line_ref line_ref;
80 struct _line_ref {
81 const char *file_name;
82 int line_nr;
83 };
84
85 /* Error appends a new line, warning and notify do not */
86 typedef void error_func
87 (const line_ref *line,
88 char *msg,
89 ...);
90
91 extern error_func error;
92 extern error_func warning;
93 extern error_func notify;
94
95
96 #define ERROR(EXPRESSION) \
97 do { \
98 line_ref line; \
99 line.file_name = filter_filename (__FILE__); \
100 line.line_nr = __LINE__; \
101 error (&line, EXPRESSION); \
102 } while (0)
103
104 #define ASSERT(EXPRESSION) \
105 do { \
106 if (!(EXPRESSION)) { \
107 line_ref line; \
108 line.file_name = filter_filename (__FILE__); \
109 line.line_nr = __LINE__; \
110 error(&line, "assertion failed - %s\n", #EXPRESSION); \
111 } \
112 } while (0)
113
114 #define ZALLOC(TYPE) ((TYPE*) zalloc (sizeof(TYPE)))
115 #define NZALLOC(TYPE,N) ((TYPE*) zalloc (sizeof(TYPE) * (N)))
116 #if 0
117 #define STRDUP(STRING) (strcpy (zalloc (strlen (STRING) + 1), (STRING)))
118 #define STRNDUP(STRING,LEN) (strncpy (zalloc ((LEN) + 1), (STRING), (LEN)))
119 #endif
120
121 extern void *zalloc
122 (long size);
123
124 extern unsigned target_a2i
125 (int ms_bit_nr,
126 const char *a);
127
128 extern unsigned i2target
129 (int ms_bit_nr,
130 unsigned bit);
131
132 extern unsigned long long a2i
133 (const char *a);
134
135
136 /* Try looking for name in the map table (returning the corresponding
137 integer value).
138
139 If the the sentinal (NAME == NULL) its value if >= zero is returned
140 as the default. */
141
142 typedef struct _name_map {
143 const char *name;
144 int i;
145 } name_map;
146
147 extern int name2i
148 (const char *name,
149 const name_map *map);
150
151 extern const char *i2name
152 (const int i,
153 const name_map *map);
This page took 0.044091 seconds and 5 git commands to generate.