aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-12-04 20:24:55 -0500
committerMike Frysinger <vapier@gentoo.org>2021-12-04 22:09:26 -0500
commit20a8e078cc573f85f7262f7b87be3cf8e8a6424f (patch)
tree3566c07524f60dfdf62b80576dc9151afb37b3e6 /sim
parent671fac7c4526b61143f860c4800047c3f7ff6fc4 (diff)
downloadgdb-20a8e078cc573f85f7262f7b87be3cf8e8a6424f.zip
gdb-20a8e078cc573f85f7262f7b87be3cf8e8a6424f.tar.gz
gdb-20a8e078cc573f85f7262f7b87be3cf8e8a6424f.tar.bz2
sim: reorder header includes
We're including system headers after local headers in a bunch of places, but this leads to conflicts when our local headers happen to define symbols that show up in the system headers. Use the more standard order of: * config.h (via defs.h) * system headers * local library headers (e.g. bfd & libiberty) * sim specific headers
Diffstat (limited to 'sim')
-rw-r--r--sim/common/callback.c23
-rw-r--r--sim/common/cgen-par.c3
-rw-r--r--sim/common/cgen-scache.c4
-rw-r--r--sim/common/cgen-trace.c4
-rw-r--r--sim/common/cgen-utils.c3
-rw-r--r--sim/common/dv-cfi.c2
-rw-r--r--sim/common/dv-glue.c4
-rw-r--r--sim/common/dv-pal.c12
-rw-r--r--sim/common/dv-sockser.c17
-rwxr-xr-xsim/common/genmloop.sh3
-rw-r--r--sim/common/hw-alloc.c4
-rw-r--r--sim/common/hw-base.c9
-rw-r--r--sim/common/hw-device.c6
-rw-r--r--sim/common/hw-events.c9
-rw-r--r--sim/common/hw-handles.c4
-rw-r--r--sim/common/hw-ports.c7
-rw-r--r--sim/common/hw-properties.c4
-rw-r--r--sim/common/hw-tree.c8
-rw-r--r--sim/common/nrun.c15
-rw-r--r--sim/common/sim-arange.c7
-rw-r--r--sim/common/sim-assert.h4
-rw-r--r--sim/common/sim-basics.h2
-rw-r--r--sim/common/sim-config.c3
-rw-r--r--sim/common/sim-core.c7
-rw-r--r--sim/common/sim-cpu.c3
-rw-r--r--sim/common/sim-engine.c6
-rw-r--r--sim/common/sim-events.c11
-rw-r--r--sim/common/sim-fpu.c4
-rw-r--r--sim/common/sim-hload.c3
-rw-r--r--sim/common/sim-hw.c11
-rw-r--r--sim/common/sim-io.c10
-rw-r--r--sim/common/sim-io.h6
-rw-r--r--sim/common/sim-load.c4
-rw-r--r--sim/common/sim-memopt.c18
-rw-r--r--sim/common/sim-model.c5
-rw-r--r--sim/common/sim-module.c8
-rw-r--r--sim/common/sim-options.c15
-rw-r--r--sim/common/sim-profile.c8
-rw-r--r--sim/common/sim-reason.c4
-rw-r--r--sim/common/sim-signal.c1
-rw-r--r--sim/common/sim-trace.c18
-rw-r--r--sim/common/sim-utils.c8
-rw-r--r--sim/common/sim-watch.c14
-rw-r--r--sim/common/syscall.c14
44 files changed, 173 insertions, 162 deletions
diff --git a/sim/common/callback.c b/sim/common/callback.c
index a5f0fbe..105488d 100644
--- a/sim/common/callback.c
+++ b/sim/common/callback.c
@@ -23,26 +23,27 @@
/* This must come before any other includes. */
#include "defs.h"
-#include "ansidecl.h"
+#include <errno.h>
+#include <fcntl.h>
+/* For PIPE_BUF. */
+#include <limits.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-/* For PIPE_BUF. */
-#include <limits.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
#include <time.h>
-#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include <sys/stat.h>
-#include "sim/callback.h"
+#include <sys/types.h>
+
+#include "ansidecl.h"
/* For xmalloc. */
#include "libiberty.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include "sim/callback.h"
#ifndef PIPE_BUF
#define PIPE_BUF 512
diff --git a/sim/common/cgen-par.c b/sim/common/cgen-par.c
index b535edf..2464229 100644
--- a/sim/common/cgen-par.c
+++ b/sim/common/cgen-par.c
@@ -20,8 +20,9 @@ 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 "sim-main.h"
#include "cgen-mem.h"
#include "cgen-par.h"
diff --git a/sim/common/cgen-scache.c b/sim/common/cgen-scache.c
index c14d5d2..fd4f1f9 100644
--- a/sim/common/cgen-scache.c
+++ b/sim/common/cgen-scache.c
@@ -22,9 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define SCACHE_DEFINE_INLINE
-#include "sim-main.h"
#include <stdlib.h>
+
#include "libiberty.h"
+
+#include "sim-main.h"
#include "sim-options.h"
#include "sim-io.h"
diff --git a/sim/common/cgen-trace.c b/sim/common/cgen-trace.c
index f5483fd..f372c47 100644
--- a/sim/common/cgen-trace.c
+++ b/sim/common/cgen-trace.c
@@ -22,9 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <stdlib.h>
+
+#include "bfd.h"
#include "diagnostics.h"
#include "dis-asm.h"
-#include "bfd.h"
+
#include "sim-main.h"
#include "sim-fpu.h"
#include "sim/callback.h"
diff --git a/sim/common/cgen-utils.c b/sim/common/cgen-utils.c
index d9c3ea9..cae21ff 100644
--- a/sim/common/cgen-utils.c
+++ b/sim/common/cgen-utils.c
@@ -21,9 +21,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "bfd.h"
+#include "dis-asm.h"
+
#include "sim-main.h"
#include "sim-signal.h"
-#include "dis-asm.h"
#define MEMOPS_DEFINE_INLINE
#include "cgen-mem.h"
diff --git a/sim/common/dv-cfi.c b/sim/common/dv-cfi.c
index 02a2ced..f719ca4 100644
--- a/sim/common/dv-cfi.c
+++ b/sim/common/dv-cfi.c
@@ -25,9 +25,9 @@
/* This must come before any other includes. */
#include "defs.h"
-#include <math.h>
#include <errno.h>
#include <fcntl.h>
+#include <math.h>
#include <stdbool.h>
#include <unistd.h>
#ifdef HAVE_SYS_MMAN_H
diff --git a/sim/common/dv-glue.c b/sim/common/dv-glue.c
index 7c8e1f8..4f2bbf5 100644
--- a/sim/common/dv-glue.c
+++ b/sim/common/dv-glue.c
@@ -22,10 +22,10 @@
/* This must come before any other includes. */
#include "defs.h"
-#include "hw-main.h"
-
#include <string.h>
+#include "hw-main.h"
+
/* DEVICE
diff --git a/sim/common/dv-pal.c b/sim/common/dv-pal.c
index c60f524..3f6a95e 100644
--- a/sim/common/dv-pal.c
+++ b/sim/common/dv-pal.c
@@ -22,6 +22,12 @@
/* This must come before any other includes. */
#include "defs.h"
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#include "sim-main.h"
#include "hw-main.h"
#include "sim-io.h"
@@ -30,12 +36,6 @@
its immediate domain */
#include "hw-tree.h"
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-
/* DEVICE
diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index 477e8f6..69338f9 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -21,24 +21,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
-#include <string.h>
-#include <signal.h>
-#include <stdlib.h>
+#include <errno.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#include <netdb.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
-#include <netdb.h>
+#include <netinet/in.h>
#include <sys/select.h>
#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/types.h>
#include "sim-main.h"
#include "sim-assert.h"
diff --git a/sim/common/genmloop.sh b/sim/common/genmloop.sh
index b8a0f43..e1eb08c 100755
--- a/sim/common/genmloop.sh
+++ b/sim/common/genmloop.sh
@@ -312,8 +312,9 @@ cat << EOF
#define WANT_CPU @cpu@
#define WANT_CPU_@CPU@
-#include "sim-main.h"
#include "bfd.h"
+
+#include "sim-main.h"
#include "cgen-mem.h"
#include "cgen-ops.h"
#include "sim-assert.h"
diff --git a/sim/common/hw-alloc.c b/sim/common/hw-alloc.c
index a16666b..b3633da 100644
--- a/sim/common/hw-alloc.c
+++ b/sim/common/hw-alloc.c
@@ -20,11 +20,11 @@ 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 "hw-main.h"
#include "hw-base.h"
-#include <stdlib.h>
-
struct hw_alloc_data
{
void *alloc;
diff --git a/sim/common/hw-base.c b/sim/common/hw-base.c
index dee9359..238d3fe 100644
--- a/sim/common/hw-base.c
+++ b/sim/common/hw-base.c
@@ -22,13 +22,12 @@
/* This must come before any other includes. */
#include "defs.h"
-#include "hw-main.h"
-#include "hw-base.h"
-
-#include <string.h>
-#include <stdlib.h>
#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include "hw-main.h"
+#include "hw-base.h"
#include "hw-config.h"
struct hw_base_data
diff --git a/sim/common/hw-device.c b/sim/common/hw-device.c
index 9b743ea..b30eede 100644
--- a/sim/common/hw-device.c
+++ b/sim/common/hw-device.c
@@ -22,12 +22,12 @@
/* This must come before any other includes. */
#include "defs.h"
-#include "hw-main.h"
-#include "hw-base.h"
-
#include <stdlib.h>
#include <string.h>
+#include "hw-main.h"
+#include "hw-base.h"
+
/* Address methods */
const hw_unit *
diff --git a/sim/common/hw-events.c b/sim/common/hw-events.c
index 620b47d..301f868 100644
--- a/sim/common/hw-events.c
+++ b/sim/common/hw-events.c
@@ -20,13 +20,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <string.h>
+
#include "hw-main.h"
#include "hw-base.h"
#include "sim-events.h"
-#include <string.h>
-
/* The hw-events object is implemented using sim-events */
struct hw_event
@@ -179,10 +179,11 @@ hw_event_remain_time (struct hw *me, struct hw_event *event)
Build with `make test-hw-events' in sim/<cpu> directory*/
#if defined (MAIN)
-#include "sim-main.h"
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
+#include "sim-main.h"
static void
test_handler (struct hw *me,
diff --git a/sim/common/hw-handles.c b/sim/common/hw-handles.c
index fb878e4..62b3ca3 100644
--- a/sim/common/hw-handles.c
+++ b/sim/common/hw-handles.c
@@ -22,11 +22,11 @@
/* This must come before any other includes. */
#include "defs.h"
+#include <stdlib.h>
+
#include "hw-main.h"
#include "hw-base.h"
-#include <stdlib.h>
-
struct hw_handle_mapping
{
cell_word external;
diff --git a/sim/common/hw-ports.c b/sim/common/hw-ports.c
index fbc7278..6029814 100644
--- a/sim/common/hw-ports.c
+++ b/sim/common/hw-ports.c
@@ -20,13 +20,12 @@ 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"
-
+#include <ctype.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
+#include "hw-main.h"
+#include "hw-base.h"
struct hw_port_edge
{
diff --git a/sim/common/hw-properties.c b/sim/common/hw-properties.c
index 3836aa7..f608ba9 100644
--- a/sim/common/hw-properties.c
+++ b/sim/common/hw-properties.c
@@ -22,14 +22,14 @@
/* This must come before any other includes. */
#include "defs.h"
+#include <string.h>
+
#include "hw-main.h"
#include "hw-base.h"
#include "sim-io.h"
#include "sim-assert.h"
-#include <string.h>
-
/* property entries */
struct hw_property_data
diff --git a/sim/common/hw-tree.c b/sim/common/hw-tree.c
index 1bf4eda..2e441ce 100644
--- a/sim/common/hw-tree.c
+++ b/sim/common/hw-tree.c
@@ -22,6 +22,10 @@
/* This must come before any other includes. */
#include "defs.h"
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "hw-main.h"
#include "hw-base.h"
#include "hw-tree.h"
@@ -29,10 +33,6 @@
#include "sim-io.h"
#include "sim-assert.h"
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
/* manipulate/lookup device names */
typedef struct _name_specifier
diff --git a/sim/common/nrun.c b/sim/common/nrun.c
index 557a060..2985bda 100644
--- a/sim/common/nrun.c
+++ b/sim/common/nrun.c
@@ -21,24 +21,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
/* For strsignal. */
#include <string.h>
+#ifdef HAVE_UNISTD_H
+/* For chdir. */
+#include <unistd.h>
+#endif
+
+#include "bfd.h"
+#include "environ.h"
#include "sim-main.h"
#include "sim-signal.h"
#include "sim/callback.h"
-#include "bfd.h"
-#include "environ.h"
-
#ifndef HAVE_STRSIGNAL
/* While libiberty provides a fallback, it doesn't provide a prototype. */
extern const char *strsignal (int);
#endif
-#ifdef HAVE_UNISTD_H
-/* For chdir. */
-#include <unistd.h>
-#endif
-
static void usage (void);
extern host_callback default_callback;
diff --git a/sim/common/sim-arange.c b/sim/common/sim-arange.c
index 5a28a2c..96b1af3 100644
--- a/sim/common/sim-arange.c
+++ b/sim/common/sim-arange.c
@@ -23,13 +23,14 @@ 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 <string.h>
+
#include "libiberty.h"
+
#include "sim-basics.h"
#include "sim-arange.h"
-#include <stdlib.h>
-#include <string.h>
-
/* Insert a range. */
static void
diff --git a/sim/common/sim-assert.h b/sim/common/sim-assert.h
index c6b877b..43b0b9d 100644
--- a/sim/common/sim-assert.h
+++ b/sim/common/sim-assert.h
@@ -21,6 +21,8 @@
#ifndef SIM_ASSERT_H
#define SIM_ASSERT_H
+#include "libiberty.h"
+
/* The subtle difference between SIM_ASSERT and ASSERT is that
SIM_ASSERT passes `sd' to sim_io_error for the SIM_DESC,
ASSERT passes NULL. */
@@ -28,7 +30,6 @@
#if !defined (SIM_ASSERT)
#if defined (WITH_ASSERT)
#include "sim-io.h"
-#include "libiberty.h"
#define SIM_ASSERT(EXPRESSION) \
do \
{ \
@@ -51,7 +52,6 @@ while (0)
#if !defined (ASSERT)
#if defined (WITH_ASSERT)
#include "sim-io.h"
-#include "libiberty.h"
#define ASSERT(EXPRESSION) \
do \
{ \
diff --git a/sim/common/sim-basics.h b/sim/common/sim-basics.h
index 32995a8..f09a4f2 100644
--- a/sim/common/sim-basics.h
+++ b/sim/common/sim-basics.h
@@ -31,9 +31,9 @@
/* Basic host dependant mess - hopefully <stdio.h> + <stdarg.h> will
bring potential conflicts out in the open */
+#include <setjmp.h>
#include <stdarg.h>
#include <stdio.h>
-#include <setjmp.h>
#ifndef min
diff --git a/sim/common/sim-config.c b/sim/common/sim-config.c
index fc6b09a..d6c3075 100644
--- a/sim/common/sim-config.c
+++ b/sim/common/sim-config.c
@@ -22,9 +22,10 @@
/* This must come before any other includes. */
#include "defs.h"
+#include "bfd.h"
+
#include "sim-main.h"
#include "sim-assert.h"
-#include "bfd.h"
enum bfd_endian current_target_byte_order = BFD_ENDIAN_UNKNOWN;
diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
index 2c568dc..8d13020 100644
--- a/sim/common/sim-core.c
+++ b/sim/common/sim-core.c
@@ -26,17 +26,18 @@
/* This must come before any other includes. */
#include "defs.h"
+#include <stdlib.h>
+
+#include "libiberty.h"
+
#include "sim-main.h"
#include "sim-assert.h"
#include "sim-signal.h"
-#include "libiberty.h"
#if (WITH_HW)
#include "sim-hw.h"
#endif
-#include <stdlib.h>
-
/* "core" module install handler.
This is called via sim_module_install to install the "core"
diff --git a/sim/common/sim-cpu.c b/sim/common/sim-cpu.c
index bde3e61..49bd850 100644
--- a/sim/common/sim-cpu.c
+++ b/sim/common/sim-cpu.c
@@ -22,9 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
-#include "sim-main.h"
#include "bfd.h"
+#include "sim-main.h"
+
/* Allocate space for all cpus in the simulator.
Space for the cpu must currently exist prior to parsing ARGV. */
/* ??? wip. better solution must wait. */
diff --git a/sim/common/sim-engine.c b/sim/common/sim-engine.c
index 2a0fb72..0e06b55 100644
--- a/sim/common/sim-engine.c
+++ b/sim/common/sim-engine.c
@@ -20,13 +20,13 @@ 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>
+
#include "sim-main.h"
#include "sim-assert.h"
#include "sim-signal.h"
-#include <stdio.h>
-#include <stdlib.h>
-
/* Get the run state.
REASON/SIGRC are the values returned by sim_stop_reason.
??? Should each cpu have its own copy? */
diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c
index ee031c9..a5ec32d 100644
--- a/sim/common/sim-events.c
+++ b/sim/common/sim-events.c
@@ -26,14 +26,15 @@
/* This must come before any other includes. */
#include "defs.h"
+#include <signal.h> /* For SIGPROCMASK et al. */
+#include <stdlib.h>
+#include <string.h>
+
+#include "libiberty.h"
+
#include "sim-main.h"
#include "sim-assert.h"
#include "sim-cpu.h"
-#include "libiberty.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <signal.h> /* For SIGPROCMASK et al. */
typedef enum {
watch_invalid,
diff --git a/sim/common/sim-fpu.c b/sim/common/sim-fpu.c
index fe8ecf8..e49d2e3 100644
--- a/sim/common/sim-fpu.c
+++ b/sim/common/sim-fpu.c
@@ -38,14 +38,14 @@ 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-basics.h"
#include "sim-fpu.h"
#include "sim-io.h"
#include "sim-assert.h"
-#include <stdlib.h>
-
/* Debugging support.
If digits is -1, then print all digits. */
diff --git a/sim/common/sim-hload.c b/sim/common/sim-hload.c
index f33dcf6..c42590c 100644
--- a/sim/common/sim-hload.c
+++ b/sim/common/sim-hload.c
@@ -20,8 +20,9 @@ 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-main.h"
#include "sim-utils.h"
#include "sim-assert.h"
diff --git a/sim/common/sim-hw.c b/sim/common/sim-hw.c
index 9a3db17..1b08643 100644
--- a/sim/common/sim-hw.c
+++ b/sim/common/sim-hw.c
@@ -20,6 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "sim-main.h"
#include "sim-assert.h"
#include "sim-options.h"
@@ -32,12 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "hw-main.h"
#include "hw-base.h"
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
-
-
struct sim_hw {
struct hw *tree;
int trace_p;
diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c
index 9fdc79e..5a47f65 100644
--- a/sim/common/sim-io.c
+++ b/sim/common/sim-io.c
@@ -22,20 +22,18 @@
/* This must come before any other includes. */
#include "defs.h"
-#include "sim-main.h"
-#include "sim-io.h"
-#include "sim/callback.h"
-
#include <errno.h>
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
-
+#include <stdlib.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include <stdlib.h>
+#include "sim-main.h"
+#include "sim-io.h"
+#include "sim/callback.h"
#undef open
diff --git a/sim/common/sim-io.h b/sim/common/sim-io.h
index 9536e4b..f9fd197 100644
--- a/sim/common/sim-io.h
+++ b/sim/common/sim-io.h
@@ -23,6 +23,9 @@
#ifndef SIM_IO_H
#define SIM_IO_H
+#include <sys/stat.h>
+#include <sys/types.h>
+
/* See the file include/callbacks.h for a description */
int sim_io_init (SIM_DESC sd);
@@ -86,9 +89,6 @@ void sim_io_poll_quit (SIM_DESC sd);
/* Returns -1 and sets (host) EAGAIN if not ready. */
int sim_io_poll_read (SIM_DESC sd, int, char *, int);
-#include <sys/types.h>
-#include <sys/stat.h>
-
int sim_io_stat (SIM_DESC sd, const char *path, struct stat *buf);
int sim_io_fstat (SIM_DESC sd, int fd, struct stat *buf);
diff --git a/sim/common/sim-load.c b/sim/common/sim-load.c
index ec5df41..c91d90a 100644
--- a/sim/common/sim-load.c
+++ b/sim/common/sim-load.c
@@ -21,12 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
-#include "ansidecl.h"
-#include <stdio.h> /* for NULL */
#include <stdarg.h>
+#include <stdio.h> /* for NULL */
#include <stdlib.h>
#include <time.h>
+#include "ansidecl.h"
#include "bfd.h"
#include "sim/callback.h"
diff --git a/sim/common/sim-memopt.c b/sim/common/sim-memopt.c
index 636f6a9..093958e 100644
--- a/sim/common/sim-memopt.c
+++ b/sim/common/sim-memopt.c
@@ -20,25 +20,25 @@ 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"
-
-#include <string.h>
-#include <stdlib.h>
#include <errno.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+
+#include "sim-main.h"
+#include "sim-assert.h"
+#include "sim-options.h"
/* Memory fill byte. */
static unsigned8 fill_byte_value;
diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c
index 98dcbea..a4e2d91 100644
--- a/sim/common/sim-model.c
+++ b/sim/common/sim-model.c
@@ -20,13 +20,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include "bfd.h"
+#include "libiberty.h"
+
#include "sim-main.h"
#include "sim-model.h"
-#include "libiberty.h"
#include "sim-options.h"
#include "sim-io.h"
#include "sim-assert.h"
-#include "bfd.h"
static void model_set (sim_cpu *, const SIM_MODEL *);
diff --git a/sim/common/sim-module.c b/sim/common/sim-module.c
index d2b220ab..dfbb6f9 100644
--- a/sim/common/sim-module.c
+++ b/sim/common/sim-module.c
@@ -22,15 +22,15 @@ 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 "libiberty.h"
+
#include "sim-main.h"
#include "sim-io.h"
#include "sim-options.h"
#include "sim-assert.h"
-#include "libiberty.h"
-
-#include <stdlib.h>
-
/* List of all early/core modules.
TODO: Should trim this list by converting to sim_install_* framework. */
static MODULE_INSTALL_FN * const early_modules[] = {
diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index 8c9b7cf..5991dde 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -20,21 +20,22 @@ 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 <string.h>
-#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
+
+#include "bfd.h"
+#include "environ.h"
+#include "hashtab.h"
#include "libiberty.h"
+
+#include "sim-main.h"
#include "sim-options.h"
#include "sim-io.h"
#include "sim-assert.h"
-#include "environ.h"
#include "version.h"
-#include "hashtab.h"
-
-#include "bfd.h"
/* Add a set of options to the simulator.
TABLE is an array of OPTIONS terminated by a NULL `opt.name' entry.
diff --git a/sim/common/sim-profile.c b/sim/common/sim-profile.c
index 1459ae7..adde403 100644
--- a/sim/common/sim-profile.c
+++ b/sim/common/sim-profile.c
@@ -20,15 +20,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "sim-main.h"
#include "sim-io.h"
#include "sim-options.h"
#include "sim-assert.h"
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
#if !WITH_PROFILE_PC_P
static unsigned int _profile_stub;
# define PROFILE_PC_FREQ(p) _profile_stub
diff --git a/sim/common/sim-reason.c b/sim/common/sim-reason.c
index fa36837..27746ea 100644
--- a/sim/common/sim-reason.c
+++ b/sim/common/sim-reason.c
@@ -20,12 +20,12 @@ 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"
#include "sim-assert.h"
#include "sim-signal.h"
-#include <stdlib.h>
-
/* Generic implementation of sim_stop_reason */
void
diff --git a/sim/common/sim-signal.c b/sim/common/sim-signal.c
index d518604..0fe5e15 100644
--- a/sim/common/sim-signal.c
+++ b/sim/common/sim-signal.c
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include <signal.h>
+
#include "sim-main.h"
#include "sim-signal.h"
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
index 9ebb86d..f4712aa 100644
--- a/sim/common/sim-trace.c
+++ b/sim/common/sim-trace.c
@@ -20,21 +20,19 @@ 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"
-#include "sim-fpu.h"
-#include "sim/callback.h"
+#include <stdlib.h>
+#include <string.h>
#include "bfd.h"
-#include "libiberty.h"
-
#include "dis-asm.h"
+#include "libiberty.h"
+#include "sim-main.h"
#include "sim-assert.h"
-
-#include <string.h>
-#include <stdlib.h>
+#include "sim-io.h"
+#include "sim-options.h"
+#include "sim-fpu.h"
+#include "sim/callback.h"
#ifndef SIZE_PHASE
#define SIZE_PHASE 8
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index ff6234b..e30627b 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -21,16 +21,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include <stdlib.h>
+#include <string.h>
#include <time.h>
-#include <sys/time.h> /* needed by sys/resource.h */
-
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
-#include <string.h>
+#include <sys/time.h> /* needed by sys/resource.h */
-#include "libiberty.h"
#include "bfd.h"
+#include "libiberty.h"
+
#include "sim-main.h"
#include "sim-assert.h"
#include "sim-utils.h"
diff --git a/sim/common/sim-watch.c b/sim/common/sim-watch.c
index bc6c44b..624580d 100644
--- a/sim/common/sim-watch.c
+++ b/sim/common/sim-watch.c
@@ -20,18 +20,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "libiberty.h"
+
#include "sim-main.h"
#include "sim-options.h"
#include "sim-signal.h"
-#include "libiberty.h"
-
#include "sim-assert.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
enum {
OPTION_WATCH_DELETE = OPTION_START,
diff --git a/sim/common/syscall.c b/sim/common/syscall.c
index df9dd92..c64e78f 100644
--- a/sim/common/syscall.c
+++ b/sim/common/syscall.c
@@ -26,20 +26,22 @@
/* This must come before any other includes. */
#include "defs.h"
-#include "ansidecl.h"
-#include "libiberty.h"
+#include <errno.h>
+#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include <errno.h>
-#include <fcntl.h>
-#include <time.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "ansidecl.h"
+#include "libiberty.h"
+
#include "sim/callback.h"
#ifndef ENOSYS