sim: igen: add missing newline to various error messages
[binutils-gdb.git] / sim / igen / misc.h
1 /* The IGEN simulator generator for GDB, the GNU Debugger.
2
3 Copyright 2002-2022 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 3 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, see <http://www.gnu.org/licenses/>. */
21
22
23
24 /* Frustrating header junk */
25
26 enum
27 {
28 default_insn_bit_size = 32,
29 max_insn_bit_size = 64,
30 };
31
32
33 #include <ctype.h>
34 #include <stdint.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 #if !defined (__attribute__) && (!defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
40 #define __attribute__(arg)
41 #endif
42
43
44
45 #include "filter_host.h"
46
47 typedef struct _line_ref line_ref;
48 struct _line_ref
49 {
50 const char *file_name;
51 int line_nr;
52 };
53
54 /* Error appends a new line, warning and notify do not */
55 typedef void error_func (const line_ref *line, char *msg, ...);
56
57 extern error_func error;
58 extern error_func warning;
59 extern error_func notify;
60
61
62 #define ERROR(EXPRESSION) \
63 do { \
64 line_ref line; \
65 line.file_name = filter_filename (__FILE__); \
66 line.line_nr = __LINE__; \
67 error (&line, EXPRESSION "\n"); \
68 } while (0)
69
70 #define ASSERT(EXPRESSION) \
71 do { \
72 if (!(EXPRESSION)) { \
73 line_ref line; \
74 line.file_name = filter_filename (__FILE__); \
75 line.line_nr = __LINE__; \
76 error (&line, "assertion failed - %s\n", #EXPRESSION); \
77 } \
78 } while (0)
79
80 #define ZALLOC(TYPE) ((TYPE*) zalloc (sizeof(TYPE)))
81 #define NZALLOC(TYPE,N) ((TYPE*) zalloc (sizeof(TYPE) * (N)))
82
83 extern void *zalloc (long size);
84
85 extern unsigned target_a2i (int ms_bit_nr, const char *a);
86
87 extern unsigned i2target (int ms_bit_nr, unsigned bit);
88
89 extern unsigned long long a2i (const char *a);
90
91
92 /* Try looking for name in the map table (returning the corresponding
93 integer value).
94
95 If the the sentinal (NAME == NULL) its value if >= zero is returned
96 as the default. */
97
98 typedef struct _name_map
99 {
100 const char *name;
101 int i;
102 }
103 name_map;
104
105 extern int name2i (const char *name, const name_map * map);
106
107 extern const char *i2name (const int i, const name_map * map);