Skip to content

Commit 670817b

Browse files
committed
sim: nltvals: pull target open flags out into a dedicated source file
Like we just did for pulling out the errno & signal maps, pull out the open flag map into a dedicated common file. All newlib ports are using the same map which makes it easy.
1 parent b868a23 commit 670817b

File tree

6 files changed

+106
-45
lines changed

6 files changed

+106
-45
lines changed

sim/Makefile.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ am_common_libcommon_a_OBJECTS = \
254254
common/common_libcommon_a-portability.$(OBJEXT) \
255255
common/common_libcommon_a-sim-load.$(OBJEXT) \
256256
common/common_libcommon_a-target-newlib-errno.$(OBJEXT) \
257+
common/common_libcommon_a-target-newlib-open.$(OBJEXT) \
257258
common/common_libcommon_a-target-newlib-signal.$(OBJEXT) \
258259
common/common_libcommon_a-version.$(OBJEXT)
259260
common_libcommon_a_OBJECTS = $(am_common_libcommon_a_OBJECTS)
@@ -846,6 +847,7 @@ common_libcommon_a_SOURCES = \
846847
common/portability.c \
847848
common/sim-load.c \
848849
common/target-newlib-errno.c \
850+
common/target-newlib-open.c \
849851
common/target-newlib-signal.c \
850852
common/version.c
851853

@@ -1021,6 +1023,8 @@ common/common_libcommon_a-sim-load.$(OBJEXT): common/$(am__dirstamp) \
10211023
common/$(DEPDIR)/$(am__dirstamp)
10221024
common/common_libcommon_a-target-newlib-errno.$(OBJEXT): \
10231025
common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
1026+
common/common_libcommon_a-target-newlib-open.$(OBJEXT): \
1027+
common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
10241028
common/common_libcommon_a-target-newlib-signal.$(OBJEXT): \
10251029
common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
10261030
common/common_libcommon_a-version.$(OBJEXT): common/$(am__dirstamp) \
@@ -1146,6 +1150,7 @@ distclean-compile:
11461150
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-portability.Po@am__quote@
11471151
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-sim-load.Po@am__quote@
11481152
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-errno.Po@am__quote@
1153+
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Po@am__quote@
11491154
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-signal.Po@am__quote@
11501155
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-version.Po@am__quote@
11511156
@AMDEP_TRUE@@am__include@ @am__quote@igen/$(DEPDIR)/filter.Po@am__quote@
@@ -1239,6 +1244,20 @@ common/common_libcommon_a-target-newlib-errno.obj: common/target-newlib-errno.c
12391244
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
12401245
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-errno.obj `if test -f 'common/target-newlib-errno.c'; then $(CYGPATH_W) 'common/target-newlib-errno.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-errno.c'; fi`
12411246

1247+
common/common_libcommon_a-target-newlib-open.o: common/target-newlib-open.c
1248+
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-target-newlib-open.o -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Tpo -c -o common/common_libcommon_a-target-newlib-open.o `test -f 'common/target-newlib-open.c' || echo '$(srcdir)/'`common/target-newlib-open.c
1249+
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Tpo common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Po
1250+
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='common/target-newlib-open.c' object='common/common_libcommon_a-target-newlib-open.o' libtool=no @AMDEPBACKSLASH@
1251+
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1252+
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-open.o `test -f 'common/target-newlib-open.c' || echo '$(srcdir)/'`common/target-newlib-open.c
1253+
1254+
common/common_libcommon_a-target-newlib-open.obj: common/target-newlib-open.c
1255+
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-target-newlib-open.obj -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Tpo -c -o common/common_libcommon_a-target-newlib-open.obj `if test -f 'common/target-newlib-open.c'; then $(CYGPATH_W) 'common/target-newlib-open.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-open.c'; fi`
1256+
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Tpo common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Po
1257+
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='common/target-newlib-open.c' object='common/common_libcommon_a-target-newlib-open.obj' libtool=no @AMDEPBACKSLASH@
1258+
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
1259+
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-open.obj `if test -f 'common/target-newlib-open.c'; then $(CYGPATH_W) 'common/target-newlib-open.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-open.c'; fi`
1260+
12421261
common/common_libcommon_a-target-newlib-signal.o: common/target-newlib-signal.c
12431262
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-target-newlib-signal.o -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-target-newlib-signal.Tpo -c -o common/common_libcommon_a-target-newlib-signal.o `test -f 'common/target-newlib-signal.c' || echo '$(srcdir)/'`common/target-newlib-signal.c
12441263
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-target-newlib-signal.Tpo common/$(DEPDIR)/common_libcommon_a-target-newlib-signal.Po

sim/common/Make-common.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ COMMON_OBJS_NAMES = \
232232
portability.o \
233233
sim-load.o \
234234
target-newlib-errno.o \
235+
target-newlib-open.o \
235236
target-newlib-signal.o \
236237
version.o
237238
COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)

sim/common/gentmap.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ static struct tdefs sys_tdefs[] = {
1616
{ 0, 0 }
1717
};
1818

19-
static struct tdefs open_tdefs[] = {
20-
#define open_defs
21-
#include "nltvals.def"
22-
#undef open_defs
23-
{ 0, 0 }
24-
};
25-
2619
static void
2720
gen_targ_vals_h (void)
2821
{
@@ -51,7 +44,6 @@ gen_targ_map_c (void)
5144
printf ("/* This file is machine generated by gentmap.c. */\n\n");
5245

5346
printf ("#include \"defs.h\"\n");
54-
printf ("#include <fcntl.h>\n");
5547
printf ("#include \"ansidecl.h\"\n");
5648
printf ("#include \"sim/callback.h\"\n");
5749
printf ("#include \"targ-vals.h\"\n");
@@ -68,18 +60,6 @@ gen_targ_map_c (void)
6860
}
6961
printf (" { 0, -1, -1 }\n");
7062
printf ("};\n\n");
71-
72-
printf ("/* open flags mapping table */\n");
73-
printf ("CB_TARGET_DEFS_MAP cb_init_open_map[] = {\n");
74-
for (t = &open_tdefs[0]; t->symbol; ++t)
75-
{
76-
printf ("#define TARGET_%s 0x%x\n", t->symbol, t->value);
77-
printf ("#ifdef %s\n", t->symbol);
78-
printf (" { \"%s\", %s, TARGET_%s },\n", t->symbol, t->symbol, t->symbol);
79-
printf ("#endif\n");
80-
}
81-
printf (" { 0, -1, -1 }\n");
82-
printf ("};\n\n");
8363
}
8464

8565
int

sim/common/local.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ noinst_LIBRARIES += %D%/libcommon.a
3737
%D%/portability.c \
3838
%D%/sim-load.c \
3939
%D%/target-newlib-errno.c \
40+
%D%/target-newlib-open.c \
4041
%D%/target-newlib-signal.c \
4142
%D%/version.c
4243

sim/common/nltvals.def

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
/* Newlib/libgloss macro values needed by remote target support. */
22
/* This file is machine generated by gennltvals.py. */
3-
#ifdef open_defs
4-
/* from fcntl.h */
5-
/* from sys/fcntl.h */
6-
/* from sys/_default_fcntl.h */
7-
/* begin open target macros */
8-
{ "O_ACCMODE", (0|1|2) },
9-
{ "O_APPEND", 0x0008 },
10-
{ "O_CLOEXEC", 0x40000 },
11-
{ "O_CREAT", 0x0200 },
12-
{ "O_DIRECT", 0x80000 },
13-
{ "O_DIRECTORY", 0x200000 },
14-
{ "O_EXCL", 0x0800 },
15-
{ "O_EXEC", 0x400000 },
16-
{ "O_NOCTTY", 0x8000 },
17-
{ "O_NOFOLLOW", 0x100000 },
18-
{ "O_NONBLOCK", 0x4000 },
19-
{ "O_RDONLY", 0 },
20-
{ "O_RDWR", 2 },
21-
{ "O_SEARCH", 0x400000 },
22-
{ "O_SYNC", 0x2000 },
23-
{ "O_TRUNC", 0x0400 },
24-
{ "O_WRONLY", 1 },
25-
#undef open_defs
26-
/* end open target macros */
27-
#endif
283
#ifdef NL_TARGET_cr16
294
#ifdef sys_defs
305
/* from syscall.h */

sim/common/target-newlib-open.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/* Target errno mappings for newlib/libgloss environment.
2+
Copyright 1995-2021 Free Software Foundation, Inc.
3+
Contributed by Mike Frysinger.
4+
5+
This file is part of simulators.
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation; either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
19+
20+
/* This must come before any other includes. */
21+
#include "defs.h"
22+
23+
#include <fcntl.h>
24+
25+
#include "sim/callback.h"
26+
27+
/* This file is kept up-to-date via the gennltvals.py script. Do not edit
28+
anything between the START & END comment blocks below. */
29+
30+
CB_TARGET_DEFS_MAP cb_init_open_map[] = {
31+
/* gennltvals: START */
32+
#ifdef O_ACCMODE
33+
{ "O_ACCMODE", O_ACCMODE, (0|1|2) },
34+
#endif
35+
#ifdef O_APPEND
36+
{ "O_APPEND", O_APPEND, 0x0008 },
37+
#endif
38+
#ifdef O_CLOEXEC
39+
{ "O_CLOEXEC", O_CLOEXEC, 0x40000 },
40+
#endif
41+
#ifdef O_CREAT
42+
{ "O_CREAT", O_CREAT, 0x0200 },
43+
#endif
44+
#ifdef O_DIRECT
45+
{ "O_DIRECT", O_DIRECT, 0x80000 },
46+
#endif
47+
#ifdef O_DIRECTORY
48+
{ "O_DIRECTORY", O_DIRECTORY, 0x200000 },
49+
#endif
50+
#ifdef O_EXCL
51+
{ "O_EXCL", O_EXCL, 0x0800 },
52+
#endif
53+
#ifdef O_EXEC
54+
{ "O_EXEC", O_EXEC, 0x400000 },
55+
#endif
56+
#ifdef O_NOCTTY
57+
{ "O_NOCTTY", O_NOCTTY, 0x8000 },
58+
#endif
59+
#ifdef O_NOFOLLOW
60+
{ "O_NOFOLLOW", O_NOFOLLOW, 0x100000 },
61+
#endif
62+
#ifdef O_NONBLOCK
63+
{ "O_NONBLOCK", O_NONBLOCK, 0x4000 },
64+
#endif
65+
#ifdef O_RDONLY
66+
{ "O_RDONLY", O_RDONLY, 0 },
67+
#endif
68+
#ifdef O_RDWR
69+
{ "O_RDWR", O_RDWR, 2 },
70+
#endif
71+
#ifdef O_SEARCH
72+
{ "O_SEARCH", O_SEARCH, 0x400000 },
73+
#endif
74+
#ifdef O_SYNC
75+
{ "O_SYNC", O_SYNC, 0x2000 },
76+
#endif
77+
#ifdef O_TRUNC
78+
{ "O_TRUNC", O_TRUNC, 0x0400 },
79+
#endif
80+
#ifdef O_WRONLY
81+
{ "O_WRONLY", O_WRONLY, 1 },
82+
#endif
83+
/* gennltvals: END */
84+
{ NULL, -1, -1 },
85+
};

0 commit comments

Comments
 (0)