aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-05-01 18:05:23 -0400
committerMike Frysinger <vapier@gentoo.org>2021-05-16 22:38:41 -0400
commit6df01ab8ab8509b04f86d7da069ec2d25eb31bf9 (patch)
tree21a00924bc74b7d5ec239a133d223f9d52f1dd67 /sim/common
parent681eb80f1217f66c83dec4a3db83577a2a09f74a (diff)
downloadgdb-6df01ab8ab8509b04f86d7da069ec2d25eb31bf9.zip
gdb-6df01ab8ab8509b04f86d7da069ec2d25eb31bf9.tar.gz
gdb-6df01ab8ab8509b04f86d7da069ec2d25eb31bf9.tar.bz2
sim: switch config.h usage to defs.h
The defs.h header will take care of including the various config.h headers. For now, it's just config.h, but we'll add more when we integrate gnulib in. This header should be used instead of config.h, and should be the first include in every .c file. We won't rely on the old behavior where we expected files to include the port's sim-main.h which then includes the common sim-basics.h which then includes config.h. We have a ton of code that includes things before sim-main.h, and it sometimes needs to be that way. Creating a dedicated header avoids the ordering mess and implicit inclusion that shows up otherwise.
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/ChangeLog21
-rw-r--r--sim/common/callback.c6
-rw-r--r--sim/common/cgen-accfp.c3
-rw-r--r--sim/common/cgen-fpu.c3
-rw-r--r--sim/common/cgen-par.c3
-rw-r--r--sim/common/cgen-run.c3
-rw-r--r--sim/common/cgen-scache.c3
-rw-r--r--sim/common/cgen-trace.c4
-rw-r--r--sim/common/cgen-utils.c4
-rw-r--r--sim/common/defs.h30
-rw-r--r--sim/common/dv-cfi.c3
-rw-r--r--sim/common/dv-core.c2
-rw-r--r--sim/common/dv-glue.c2
-rw-r--r--sim/common/dv-pal.c4
-rw-r--r--sim/common/dv-sockser.c4
-rwxr-xr-xsim/common/genmloop.sh3
-rw-r--r--sim/common/gentmap.c2
-rw-r--r--sim/common/hw-alloc.c2
-rw-r--r--sim/common/hw-base.c2
-rw-r--r--sim/common/hw-device.c2
-rw-r--r--sim/common/hw-events.c2
-rw-r--r--sim/common/hw-handles.c2
-rw-r--r--sim/common/hw-instances.c2
-rw-r--r--sim/common/hw-ports.c2
-rw-r--r--sim/common/hw-properties.c3
-rw-r--r--sim/common/hw-tree.c2
-rw-r--r--sim/common/nrun.c4
-rw-r--r--sim/common/sim-abort.c3
-rw-r--r--sim/common/sim-arange.c3
-rw-r--r--sim/common/sim-basics.h4
-rw-r--r--sim/common/sim-bits.c3
-rw-r--r--sim/common/sim-close.c3
-rw-r--r--sim/common/sim-command.c3
-rw-r--r--sim/common/sim-config.c2
-rw-r--r--sim/common/sim-core.c3
-rw-r--r--sim/common/sim-cpu.c3
-rw-r--r--sim/common/sim-endian.c3
-rw-r--r--sim/common/sim-engine.c3
-rw-r--r--sim/common/sim-events.c3
-rw-r--r--sim/common/sim-fpu.c3
-rw-r--r--sim/common/sim-hload.c3
-rw-r--r--sim/common/sim-hrw.c3
-rw-r--r--sim/common/sim-hw.c3
-rw-r--r--sim/common/sim-info.c3
-rw-r--r--sim/common/sim-inline.c3
-rw-r--r--sim/common/sim-io.c4
-rw-r--r--sim/common/sim-load.c6
-rw-r--r--sim/common/sim-memopt.c3
-rw-r--r--sim/common/sim-model.c3
-rw-r--r--sim/common/sim-module.c4
-rw-r--r--sim/common/sim-options.c4
-rw-r--r--sim/common/sim-profile.c3
-rw-r--r--sim/common/sim-reason.c3
-rw-r--r--sim/common/sim-reg.c3
-rw-r--r--sim/common/sim-resume.c3
-rw-r--r--sim/common/sim-run.c3
-rw-r--r--sim/common/sim-signal.c3
-rw-r--r--sim/common/sim-stop.c3
-rw-r--r--sim/common/sim-syscall.c3
-rw-r--r--sim/common/sim-trace.c3
-rw-r--r--sim/common/sim-utils.c3
-rw-r--r--sim/common/sim-watch.c4
-rw-r--r--sim/common/syscall.c6
63 files changed, 215 insertions, 26 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index b221166..1d875bb 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,24 @@
+2021-05-16 Mike Frysinger <vapier@gentoo.org>
+
+ * callback.c: Replace config.h include with defs.h.
+ * cgen-accfp.c, cgen-fpu.c, cgen-par.c, cgen-run.c, cgen-scache.c,
+ dv-core.c, dv-glue.c, genmloop.sh, hw-alloc.c, hw-base.c, hw-device.c,
+ hw-events.c, hw-handles.c, hw-instances.c, hw-ports.c,
+ hw-properties.c, hw-tree.c, sim-abort.c, sim-arange.c, sim-bits.c,
+ sim-close.c, sim-command.c, sim-config.c, sim-core.c, sim-cpu.c,
+ sim-endian.c, sim-engine.c, sim-events.c, sim-fpu.c, sim-hload.c,
+ sim-hrw.c, sim-hw.c, sim-info.c, sim-inline.c, sim-model.c,
+ sim-profile.c, sim-reason.c, sim-reg.c, sim-resume.c, sim-run.c,
+ sim-signal.c, sim-stop.c, sim-trace.c, sim-utils.c: Include defs.h.
+ * cgen-trace.c, cgen-utils.c, dv-cfi.c, dv-pal.c, dv-sockser.c,
+ nrun.c, sim-basics.h, sim-load.c, sim-memopt.c, sim-module.c,
+ sim-options.c, sim-syscall.c, sim-watch.c, syscall.c: Replace
+ config.h include with defs.h.
+ * gentmap.c (gen_targ_map_c): Replace config.h with defs.h.
+ * sim-io.c: Include defs.h.
+ (open): Undefine.
+ * defs.h: New file.
+
2021-05-15 Mike Frysinger <vapier@gentoo.org>
* nrun.c: Include environ.h.
diff --git a/sim/common/callback.c b/sim/common/callback.c
index 24ea470..f2587a4 100644
--- a/sim/common/callback.c
+++ b/sim/common/callback.c
@@ -20,9 +20,9 @@
/* This file provides a standard way for targets to talk to the host OS
level. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "ansidecl.h"
#include <stdarg.h>
#include <stdio.h>
diff --git a/sim/common/cgen-accfp.c b/sim/common/cgen-accfp.c
index d6cd751..345cfe8 100644
--- a/sim/common/cgen-accfp.c
+++ b/sim/common/cgen-accfp.c
@@ -11,6 +11,9 @@
- proper rounding
*/
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-fpu.h"
diff --git a/sim/common/cgen-fpu.c b/sim/common/cgen-fpu.c
index 3a8d519..1b035ea 100644
--- a/sim/common/cgen-fpu.c
+++ b/sim/common/cgen-fpu.c
@@ -1,6 +1,9 @@
/* CGEN fpu support
Copyright (C) 1999 Cygnus Solutions. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-fpu.h"
diff --git a/sim/common/cgen-par.c b/sim/common/cgen-par.c
index 4cf0388..b535edf 100644
--- a/sim/common/cgen-par.c
+++ b/sim/common/cgen-par.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include <stdlib.h>
#include "cgen-mem.h"
diff --git a/sim/common/cgen-run.c b/sim/common/cgen-run.c
index 1458c4e..443b62a 100644
--- a/sim/common/cgen-run.c
+++ b/sim/common/cgen-run.c
@@ -33,6 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
When the framework is more modular, this can be.
*/
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/cgen-scache.c b/sim/common/cgen-scache.c
index 56df075f..f1c7571 100644
--- a/sim/common/cgen-scache.c
+++ b/sim/common/cgen-scache.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#define SCACHE_DEFINE_INLINE
#include "sim-main.h"
diff --git a/sim/common/cgen-trace.c b/sim/common/cgen-trace.c
index ea0399f..66250c0 100644
--- a/sim/common/cgen-trace.c
+++ b/sim/common/cgen-trace.c
@@ -17,7 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
#include <errno.h>
#include <stdlib.h>
#include "dis-asm.h"
diff --git a/sim/common/cgen-utils.c b/sim/common/cgen-utils.c
index 602abcb..890ed02 100644
--- a/sim/common/cgen-utils.c
+++ b/sim/common/cgen-utils.c
@@ -17,7 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "bfd.h"
#include "sim-main.h"
#include "dis-asm.h"
diff --git a/sim/common/defs.h b/sim/common/defs.h
new file mode 100644
index 0000000..3a0737c
--- /dev/null
+++ b/sim/common/defs.h
@@ -0,0 +1,30 @@
+/* The configure generated header settings.
+
+ Copyright 2002-2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file should be included by every .c file before any other header. */
+
+#ifndef DEFS_H
+#define DEFS_H
+
+#ifdef HAVE_CONFIG_H
+
+/* Include sim's various configure tests. */
+#include "config.h"
+
+#endif
+
+#endif
diff --git a/sim/common/dv-cfi.c b/sim/common/dv-cfi.c
index b865227..02a2ced 100644
--- a/sim/common/dv-cfi.c
+++ b/sim/common/dv-cfi.c
@@ -22,7 +22,8 @@
/* TODO: support vendor query tables. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
#include <math.h>
#include <errno.h>
diff --git a/sim/common/dv-core.c b/sim/common/dv-core.c
index be56aa4..c596da4 100644
--- a/sim/common/dv-core.c
+++ b/sim/common/dv-core.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "sim-main.h"
#include "hw-main.h"
diff --git a/sim/common/dv-glue.c b/sim/common/dv-glue.c
index 8bda326..7c8e1f8 100644
--- a/sim/common/dv-glue.c
+++ b/sim/common/dv-glue.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
diff --git a/sim/common/dv-pal.c b/sim/common/dv-pal.c
index dd4ab4f..c60f524 100644
--- a/sim/common/dv-pal.c
+++ b/sim/common/dv-pal.c
@@ -19,7 +19,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "hw-main.h"
#include "sim-io.h"
diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index 73c473b..ef652f6 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -18,7 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* FIXME: will obviously need to evolve.
- connectionless sockets might be more appropriate. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include <string.h>
diff --git a/sim/common/genmloop.sh b/sim/common/genmloop.sh
index 460a26c..fa4e7b9 100755
--- a/sim/common/genmloop.sh
+++ b/sim/common/genmloop.sh
@@ -301,6 +301,9 @@ exec 1>tmp-mloop-$$.cin
cat << EOF
/* This file is generated by the genmloop script. DO NOT EDIT! */
+/* This must come before any other includes. */
+#include "defs.h"
+
/* Enable switch() support in cgen headers. */
#define SEM_IN_SWITCH
diff --git a/sim/common/gentmap.c b/sim/common/gentmap.c
index 8085c35..254ec3f 100644
--- a/sim/common/gentmap.c
+++ b/sim/common/gentmap.c
@@ -67,7 +67,7 @@ gen_targ_map_c (void)
printf ("/* Target value mapping utilities needed by the simulator and gdb. */\n");
printf ("/* This file is machine generated by gentmap.c. */\n\n");
- printf ("#include \"config.h\"\n");
+ printf ("#include \"defs.h\"\n");
printf ("#include <errno.h>\n");
printf ("#include <fcntl.h>\n");
printf ("#include \"ansidecl.h\"\n");
diff --git a/sim/common/hw-alloc.c b/sim/common/hw-alloc.c
index 141dc21..a16666b 100644
--- a/sim/common/hw-alloc.c
+++ b/sim/common/hw-alloc.c
@@ -17,6 +17,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/hw-base.c b/sim/common/hw-base.c
index af8b181..af4cc50 100644
--- a/sim/common/hw-base.c
+++ b/sim/common/hw-base.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/hw-device.c b/sim/common/hw-device.c
index bc91264..9b743ea 100644
--- a/sim/common/hw-device.c
+++ b/sim/common/hw-device.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/hw-events.c b/sim/common/hw-events.c
index 81628f0..620b47d 100644
--- a/sim/common/hw-events.c
+++ b/sim/common/hw-events.c
@@ -17,6 +17,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/hw-handles.c b/sim/common/hw-handles.c
index bbd08f6..fb878e4 100644
--- a/sim/common/hw-handles.c
+++ b/sim/common/hw-handles.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/hw-instances.c b/sim/common/hw-instances.c
index 6227c0a..9d78619 100644
--- a/sim/common/hw-instances.c
+++ b/sim/common/hw-instances.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/hw-ports.c b/sim/common/hw-ports.c
index 50e2cbc..fbc7278 100644
--- a/sim/common/hw-ports.c
+++ b/sim/common/hw-ports.c
@@ -17,6 +17,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/hw-properties.c b/sim/common/hw-properties.c
index 11a371c..3836aa7 100644
--- a/sim/common/hw-properties.c
+++ b/sim/common/hw-properties.c
@@ -19,6 +19,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/hw-tree.c b/sim/common/hw-tree.c
index 4d50ec6..1bf4eda 100644
--- a/sim/common/hw-tree.c
+++ b/sim/common/hw-tree.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "hw-main.h"
#include "hw-base.h"
diff --git a/sim/common/nrun.c b/sim/common/nrun.c
index 8a1b3c1..2cccff6 100644
--- a/sim/common/nrun.c
+++ b/sim/common/nrun.c
@@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Need to be before general includes, to pick up e.g. _GNU_SOURCE. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "defs.h"
#include <signal.h>
#include <stdlib.h>
diff --git a/sim/common/sim-abort.c b/sim/common/sim-abort.c
index bf05504..06df127 100644
--- a/sim/common/sim-abort.c
+++ b/sim/common/sim-abort.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include <stdio.h>
#include <stdlib.h>
diff --git a/sim/common/sim-arange.c b/sim/common/sim-arange.c
index a40dabb..5a28a2c 100644
--- a/sim/common/sim-arange.c
+++ b/sim/common/sim-arange.c
@@ -20,6 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _SIM_ARANGE_C_
#define _SIM_ARANGE_C_
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "libiberty.h"
#include "sim-basics.h"
#include "sim-arange.h"
diff --git a/sim/common/sim-basics.h b/sim/common/sim-basics.h
index 7d9c831..25c1193 100644
--- a/sim/common/sim-basics.h
+++ b/sim/common/sim-basics.h
@@ -26,9 +26,7 @@
/* Basic configuration */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "defs.h"
/* Basic host dependant mess - hopefully <stdio.h> + <stdarg.h> will
bring potential conflicts out in the open */
diff --git a/sim/common/sim-bits.c b/sim/common/sim-bits.c
index 9e9063c..4be0752 100644
--- a/sim/common/sim-bits.c
+++ b/sim/common/sim-bits.c
@@ -23,6 +23,9 @@
#ifndef _SIM_BITS_C_
#define _SIM_BITS_C_
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-basics.h"
#include "sim-assert.h"
#include "sim-io.h"
diff --git a/sim/common/sim-close.c b/sim/common/sim-close.c
index e64d59e..c774d45 100644
--- a/sim/common/sim-close.c
+++ b/sim/common/sim-close.c
@@ -18,6 +18,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-module.h"
#include "sim/sim.h"
diff --git a/sim/common/sim-command.c b/sim/common/sim-command.c
index d49ac8a..b5ba2c0 100644
--- a/sim/common/sim-command.c
+++ b/sim/common/sim-command.c
@@ -18,6 +18,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-options.h"
#include "sim-utils.h"
diff --git a/sim/common/sim-config.c b/sim/common/sim-config.c
index 2acd1e4..df99d6a 100644
--- a/sim/common/sim-config.c
+++ b/sim/common/sim-config.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
index 222f9fd..6604f31 100644
--- a/sim/common/sim-core.c
+++ b/sim/common/sim-core.c
@@ -23,6 +23,9 @@
#ifndef SIM_CORE_C
#define SIM_CORE_C
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
#include "libiberty.h"
diff --git a/sim/common/sim-cpu.c b/sim/common/sim-cpu.c
index 552e48c..587a3e8 100644
--- a/sim/common/sim-cpu.c
+++ b/sim/common/sim-cpu.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include <stdlib.h>
#include "sim-main.h"
diff --git a/sim/common/sim-endian.c b/sim/common/sim-endian.c
index 395b487..5f0e46a 100644
--- a/sim/common/sim-endian.c
+++ b/sim/common/sim-endian.c
@@ -23,6 +23,9 @@
#ifndef _SIM_ENDIAN_C_
#define _SIM_ENDIAN_C_
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-basics.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-engine.c b/sim/common/sim-engine.c
index fcdf284..a5f84af 100644
--- a/sim/common/sim-engine.c
+++ b/sim/common/sim-engine.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c
index 60e4c55..5a5798d 100644
--- a/sim/common/sim-events.c
+++ b/sim/common/sim-events.c
@@ -23,6 +23,9 @@
#ifndef _SIM_EVENTS_C_
#define _SIM_EVENTS_C_
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
#include "sim-cpu.h"
diff --git a/sim/common/sim-fpu.c b/sim/common/sim-fpu.c
index bff5b08..fe8ecf8 100644
--- a/sim/common/sim-fpu.c
+++ b/sim/common/sim-fpu.c
@@ -35,6 +35,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef SIM_FPU_C
#define SIM_FPU_C
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-basics.h"
#include "sim-fpu.h"
diff --git a/sim/common/sim-hload.c b/sim/common/sim-hload.c
index 243437d..f33dcf6 100644
--- a/sim/common/sim-hload.c
+++ b/sim/common/sim-hload.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "bfd.h"
#include "sim-utils.h"
diff --git a/sim/common/sim-hrw.c b/sim/common/sim-hrw.c
index 920cc16..3df91d2 100644
--- a/sim/common/sim-hrw.c
+++ b/sim/common/sim-hrw.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-hw.c b/sim/common/sim-hw.c
index 984817f..95d9504 100644
--- a/sim/common/sim-hw.c
+++ b/sim/common/sim-hw.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
#include "sim-options.h"
diff --git a/sim/common/sim-info.c b/sim/common/sim-info.c
index 7dcb656..3c92c87 100644
--- a/sim/common/sim-info.c
+++ b/sim/common/sim-info.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-inline.c b/sim/common/sim-inline.c
index 93ea6f0..7c3edd0 100644
--- a/sim/common/sim-inline.c
+++ b/sim/common/sim-inline.c
@@ -26,6 +26,9 @@
#undef SIM_INLINE_P
#define SIM_INLINE_P 1
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-inline.h"
#include "sim-main.h"
diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c
index edef26e..b5e874b 100644
--- a/sim/common/sim-io.c
+++ b/sim/common/sim-io.c
@@ -19,6 +19,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include "sim-main.h"
#include "sim-io.h"
@@ -35,6 +37,8 @@
#include <stdlib.h>
+#undef open
+
/* Define the rate at which the simulator should poll the host
for a quit. */
#ifndef POLL_QUIT_INTERVAL
diff --git a/sim/common/sim-load.c b/sim/common/sim-load.c
index b9d85ca..3ea50e7 100644
--- a/sim/common/sim-load.c
+++ b/sim/common/sim-load.c
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
as it is used by simulators that don't use it [though that doesn't mean
to suggest that they shouldn't :-)]. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "ansidecl.h"
#include <stdio.h> /* for NULL */
#include <stdarg.h>
diff --git a/sim/common/sim-memopt.c b/sim/common/sim-memopt.c
index a102d74..636f6a9 100644
--- a/sim/common/sim-memopt.c
+++ b/sim/common/sim-memopt.c
@@ -17,7 +17,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c
index 5596656..e1af9d4 100644
--- a/sim/common/sim-model.c
+++ b/sim/common/sim-model.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-model.h"
#include "libiberty.h"
diff --git a/sim/common/sim-module.c b/sim/common/sim-module.c
index 3bb7db0..97d619c 100644
--- a/sim/common/sim-module.c
+++ b/sim/common/sim-module.c
@@ -19,7 +19,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-io.h"
#include "sim-options.h"
diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index ff325e6..06bd582 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -17,7 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include <string.h>
#include <stdlib.h>
diff --git a/sim/common/sim-profile.c b/sim/common/sim-profile.c
index 455e1a2..f2d65e0 100644
--- a/sim/common/sim-profile.c
+++ b/sim/common/sim-profile.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-io.h"
#include "sim-options.h"
diff --git a/sim/common/sim-reason.c b/sim/common/sim-reason.c
index 0f128c2..73a5765 100644
--- a/sim/common/sim-reason.c
+++ b/sim/common/sim-reason.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-reg.c b/sim/common/sim-reg.c
index 457ac22..ee34088 100644
--- a/sim/common/sim-reg.c
+++ b/sim/common/sim-reg.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-resume.c b/sim/common/sim-resume.c
index 6fe9a42..8f854da 100644
--- a/sim/common/sim-resume.c
+++ b/sim/common/sim-resume.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-run.c b/sim/common/sim-run.c
index 54f6286..f2e477e 100644
--- a/sim/common/sim-run.c
+++ b/sim/common/sim-run.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-signal.c b/sim/common/sim-signal.c
index 9596847..f9fef4c 100644
--- a/sim/common/sim-signal.c
+++ b/sim/common/sim-signal.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include <signal.h>
#include "sim-main.h"
diff --git a/sim/common/sim-stop.c b/sim/common/sim-stop.c
index 305c455..aa48fc3 100644
--- a/sim/common/sim-stop.c
+++ b/sim/common/sim-stop.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-syscall.c b/sim/common/sim-syscall.c
index 9dbc71a..0f7601c 100644
--- a/sim/common/sim-syscall.c
+++ b/sim/common/sim-syscall.c
@@ -17,7 +17,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
#include <errno.h>
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
index 26d9556..b8224e0 100644
--- a/sim/common/sim-trace.c
+++ b/sim/common/sim-trace.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-io.h"
#include "sim-options.h"
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index 86ab059..abb87f8 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -17,6 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-watch.c b/sim/common/sim-watch.c
index 8630b06..fa035b3 100644
--- a/sim/common/sim-watch.c
+++ b/sim/common/sim-watch.c
@@ -17,7 +17,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "sim-main.h"
#include "sim-options.h"
#include "libiberty.h"
diff --git a/sim/common/syscall.c b/sim/common/syscall.c
index 0a1d3f4..4e76d20 100644
--- a/sim/common/syscall.c
+++ b/sim/common/syscall.c
@@ -23,9 +23,9 @@
tree, nor should it live in the gdb source tree. K&R C must be
supported. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+/* This must come before any other includes. */
+#include "defs.h"
+
#include "ansidecl.h"
#include "libiberty.h"
#include <stdarg.h>