]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/common/gentmap.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / sim / common / gentmap.c
1 /* Generate targ-vals.h and targ-map.c. */
2
3 #include <stdio.h>
4
5 struct tdefs {
6 char *symbol;
7 int value;
8 };
9
10 static struct tdefs errno_tdefs[] = {
11 #define errno_defs
12 #include "targ-vals.def"
13 #undef errno_defs
14 { 0, 0 }
15 };
16
17 static struct tdefs open_tdefs[] = {
18 #define open_defs
19 #include "targ-vals.def"
20 #undef open_defs
21 { 0, 0 }
22 };
23
24 static void
25 gen_targ_vals_h ()
26 {
27 struct tdefs *t;
28
29 printf ("/* Target header values needed by the simulator and gdb. */\n");
30 printf ("/* This file is machine generated by gentmap.c. */\n\n");
31
32 printf ("#ifndef TARG_VALS_H\n");
33 printf ("#define TARG_VALS_H\n\n");
34
35 printf ("/* errno values */\n");
36 for (t = &errno_tdefs[0]; t->symbol; ++t)
37 printf ("#define TARGET_%s %d\n", t->symbol, t->value);
38 printf ("\n");
39
40 printf ("/* open flag values */\n");
41 for (t = &open_tdefs[0]; t->symbol; ++t)
42 printf ("#define TARGET_%s 0x%x\n", t->symbol, t->value);
43 printf ("\n");
44
45 printf ("#endif /* TARG_VALS_H */\n");
46 }
47
48 static void
49 gen_targ_map_c ()
50 {
51 struct tdefs *t;
52
53 printf ("/* Target value mapping utilities needed by the simulator and gdb. */\n");
54 printf ("/* This file is machine generated by gentmap.c. */\n\n");
55
56 printf ("#include <errno.h>\n");
57 printf ("#include <fcntl.h>\n");
58 printf ("#include \"ansidecl.h\"\n");
59 printf ("#include \"callback.h\"\n");
60 printf ("#include \"targ-vals.h\"\n");
61 printf ("\n");
62
63 printf ("/* errno mapping table */\n");
64 printf ("target_defs_map errno_map[] = {\n");
65 for (t = &errno_tdefs[0]; t->symbol; ++t)
66 {
67 printf ("#ifdef %s\n", t->symbol);
68 printf (" { %s, TARGET_%s },\n", t->symbol, t->symbol);
69 printf ("#endif\n");
70 }
71 printf (" { 0, 0 }\n");
72 printf ("};\n\n");
73
74 printf ("/* open flags mapping table */\n");
75 printf ("target_defs_map open_map[] = {\n");
76 for (t = &open_tdefs[0]; t->symbol; ++t)
77 {
78 printf ("#ifdef %s\n", t->symbol);
79 printf (" { %s, TARGET_%s },\n", t->symbol, t->symbol);
80 printf ("#endif\n");
81 }
82 printf (" { -1, -1 }\n");
83 printf ("};\n\n");
84 }
85
86 int
87 main (argc, argv)
88 int argc;
89 char *argv[];
90 {
91 if (argc != 2)
92 abort ();
93
94 if (strcmp (argv[1], "-h") == 0)
95 gen_targ_vals_h ();
96 else if (strcmp (argv[1], "-c") == 0)
97 gen_targ_map_c ();
98 else
99 abort ();
100
101 exit (0);
102 }