* [PATCH 1/4] sim: reorder header includes
@ 2021-12-05 3:10 Mike Frysinger
2021-12-05 3:10 ` [PATCH 2/4] sim: include stdarg.h when used Mike Frysinger
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mike Frysinger @ 2021-12-05 3:10 UTC (permalink / raw)
To: gdb-patches
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
---
include/sim/callback.h | 5 +++--
sim/common/callback.c | 23 ++++++++++++-----------
sim/common/cgen-par.c | 3 ++-
sim/common/cgen-scache.c | 4 +++-
sim/common/cgen-trace.c | 4 +++-
sim/common/cgen-utils.c | 3 ++-
sim/common/dv-cfi.c | 2 +-
sim/common/dv-glue.c | 4 ++--
sim/common/dv-pal.c | 12 ++++++------
sim/common/dv-sockser.c | 17 ++++++++---------
sim/common/genmloop.sh | 3 ++-
sim/common/hw-alloc.c | 4 ++--
sim/common/hw-base.c | 9 ++++-----
sim/common/hw-device.c | 6 +++---
sim/common/hw-events.c | 9 +++++----
sim/common/hw-handles.c | 4 ++--
sim/common/hw-ports.c | 7 +++----
sim/common/hw-properties.c | 4 ++--
sim/common/hw-tree.c | 8 ++++----
sim/common/nrun.c | 15 +++++++--------
sim/common/sim-arange.c | 7 ++++---
sim/common/sim-assert.h | 4 ++--
sim/common/sim-basics.h | 2 +-
sim/common/sim-config.c | 3 ++-
sim/common/sim-core.c | 7 ++++---
sim/common/sim-cpu.c | 3 ++-
sim/common/sim-engine.c | 6 +++---
sim/common/sim-events.c | 11 ++++++-----
sim/common/sim-fpu.c | 4 ++--
sim/common/sim-hload.c | 3 ++-
sim/common/sim-hw.c | 11 +++++------
sim/common/sim-io.c | 10 ++++------
sim/common/sim-io.h | 6 +++---
sim/common/sim-load.c | 4 ++--
sim/common/sim-memopt.c | 18 +++++++++---------
sim/common/sim-model.c | 5 +++--
sim/common/sim-module.c | 8 ++++----
sim/common/sim-options.c | 15 ++++++++-------
sim/common/sim-profile.c | 8 ++++----
sim/common/sim-reason.c | 4 ++--
sim/common/sim-signal.c | 1 +
sim/common/sim-trace.c | 18 ++++++++----------
sim/common/sim-utils.c | 8 ++++----
sim/common/sim-watch.c | 14 +++++++-------
sim/common/syscall.c | 14 ++++++++------
45 files changed, 176 insertions(+), 164 deletions(-)
diff --git a/include/sim/callback.h b/include/sim/callback.h
index a51c4de9c3aa..a6eb38ffd4e1 100644
--- a/include/sim/callback.h
+++ b/include/sim/callback.h
@@ -45,11 +45,12 @@
#ifndef SIM_CALLBACK_H
#define SIM_CALLBACK_H
-#include <ansidecl.h>
#include <stdarg.h>
#include <stdint.h>
+
+#include <ansidecl.h>
/* Needed for enum bfd_endian. */
-#include "bfd.h"
+#include <bfd.h>
\f
/* Mapping of host/target values. */
/* ??? For debugging purposes, one might want to add a string of the
diff --git a/sim/common/callback.c b/sim/common/callback.c
index a5f0fbe43558..105488db262f 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 b535edfdaec0..24642291dfb3 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 c14d5d22c6d6..fd4f1f9eb002 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 f5483fd39eaf..f372c471d34d 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 d9c3ea9aa804..cae21fff5eaf 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 02a2cedd558b..f719ca443856 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 7c8e1f877af2..4f2bbf5c308a 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 c60f524ea8ea..3f6a95e47e28 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 477e8f681af7..69338f9c6603 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 b8a0f435a09b..e1eb08c1bdfd 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 a16666b931a0..b3633da4858a 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 dee9359a7b5b..238d3fea109c 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 9b743ead1f2c..b30eede5e3b7 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 620b47d5255a..301f868ce2ee 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 fb878e492774..62b3ca38acb9 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 fbc7278ddd1f..6029814ee72f 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 3836aa73527e..f608ba943237 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 1bf4edab746b..2e441cec98b1 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 557a060e5691..2985bda08a27 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 5a28a2c0c495..96b1af3e6cd0 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 c6b877bc9101..43b0b9dc33a4 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 32995a870d13..f09a4f267205 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 fc6b09a7238d..d6c307525a89 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 2c568dc3e364..8d13020df163 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 bde3e617ce31..49bd850e87fe 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 2a0fb72d7503..0e06b55bfa12 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 ee031c9376b2..a5ec32d05c80 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 fe8ecf8a3ce5..e49d2e3238df 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 f33dcf6368a8..c42590c26947 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 9a3db171d1b3..1b086433e784 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 9fdc79e0301b..5a47f65d8e5a 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 9536e4b587a2..f9fd1978ee29 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 ec5df418d9de..c91d90a55ebf 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 636f6a9a0feb..093958e1f257 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 98dcbeae6cc1..a4e2d915e455 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 d2b220ab3fb2..dfbb6f93562b 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 8c9b7cfec370..5991ddeba3fb 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 1459ae70ab28..adde403186cc 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 fa3683793d2d..27746ea295a6 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 d51860438240..0fe5e1509f98 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 9ebb86d70e2e..f4712aae78b9 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 ff6234b1c984..e30627b88b30 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 bc6c44bcfd17..624580d9fc71 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 df9dd92e6dac..c64e78fe5f6b 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
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] sim: include stdarg.h when used
2021-12-05 3:10 [PATCH 1/4] sim: reorder header includes Mike Frysinger
@ 2021-12-05 3:10 ` Mike Frysinger
2021-12-05 3:10 ` [PATCH 3/4] sim: include stdint.h when needed Mike Frysinger
2021-12-05 3:10 ` [PATCH 4/4] sim: include ansidecl.h " Mike Frysinger
2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2021-12-05 3:10 UTC (permalink / raw)
To: gdb-patches
Avoid implicit include deps with this to help untangle sim headers
so we can get rid of arch-specific sim-main.h.
---
sim/common/cgen-trace.c | 1 +
sim/common/hw-device.c | 1 +
sim/common/hw-device.h | 1 +
sim/common/hw-events.c | 1 +
sim/common/hw-events.h | 2 ++
sim/common/hw-tree.c | 1 +
sim/common/hw-tree.h | 1 +
sim/common/sim-abort.c | 1 +
sim/common/sim-engine.c | 1 +
sim/common/sim-engine.h | 1 +
sim/common/sim-events.c | 1 +
sim/common/sim-events.h | 1 +
sim/common/sim-hw.c | 1 +
sim/common/sim-hw.h | 1 +
sim/common/sim-io.c | 1 +
sim/common/sim-io.h | 1 +
sim/common/sim-profile.c | 1 +
sim/common/sim-trace.c | 1 +
sim/common/sim-trace.h | 2 ++
sim/common/sim-utils.c | 1 +
20 files changed, 22 insertions(+)
diff --git a/sim/common/cgen-trace.c b/sim/common/cgen-trace.c
index f372c471d34d..f8f872794727 100644
--- a/sim/common/cgen-trace.c
+++ b/sim/common/cgen-trace.c
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include <errno.h>
+#include <stdarg.h>
#include <stdlib.h>
#include "bfd.h"
diff --git a/sim/common/hw-device.c b/sim/common/hw-device.c
index b30eede5e3b7..28450fad211a 100644
--- a/sim/common/hw-device.c
+++ b/sim/common/hw-device.c
@@ -22,6 +22,7 @@
/* This must come before any other includes. */
#include "defs.h"
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sim/common/hw-device.h b/sim/common/hw-device.h
index ffd627a441f0..a7e598bb40e9 100644
--- a/sim/common/hw-device.h
+++ b/sim/common/hw-device.h
@@ -23,6 +23,7 @@
#ifndef HW_DEVICE_H
#define HW_DEVICE_H
+#include <stdarg.h>
/* Introduction:
diff --git a/sim/common/hw-events.c b/sim/common/hw-events.c
index 301f868ce2ee..3337416eab7c 100644
--- a/sim/common/hw-events.c
+++ b/sim/common/hw-events.c
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <stdarg.h>
#include <string.h>
#include "hw-main.h"
diff --git a/sim/common/hw-events.h b/sim/common/hw-events.h
index 51ca5bdb2f04..7d750007c095 100644
--- a/sim/common/hw-events.h
+++ b/sim/common/hw-events.h
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef HW_EVENTS_H
#define HW_EVENTS_H
+#include <stdarg.h>
+
/* Event manager customized for hardware models.
This interface is discussed further in sim-events.h. */
diff --git a/sim/common/hw-tree.c b/sim/common/hw-tree.c
index 2e441cec98b1..c5fa1bc2806f 100644
--- a/sim/common/hw-tree.c
+++ b/sim/common/hw-tree.c
@@ -23,6 +23,7 @@
#include "defs.h"
#include <ctype.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sim/common/hw-tree.h b/sim/common/hw-tree.h
index 85c91ad96521..2f717ec8d9f4 100644
--- a/sim/common/hw-tree.h
+++ b/sim/common/hw-tree.h
@@ -23,6 +23,7 @@
#ifndef HW_TREE
#define HW_TREE
+#include <stdarg.h>
struct hw *hw_tree_create
(SIM_DESC sd,
diff --git a/sim/common/sim-abort.c b/sim/common/sim-abort.c
index 06df127c19c0..d30b9a46d683 100644
--- a/sim/common/sim-abort.c
+++ b/sim/common/sim-abort.c
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/sim/common/sim-engine.c b/sim/common/sim-engine.c
index 0e06b55bfa12..5eeef51e3456 100644
--- a/sim/common/sim-engine.c
+++ b/sim/common/sim-engine.c
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/sim/common/sim-engine.h b/sim/common/sim-engine.h
index 1feb8a6d40bb..159d96bf119e 100644
--- a/sim/common/sim-engine.h
+++ b/sim/common/sim-engine.h
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef SIM_ENGINE_H
#define SIM_ENGINE_H
+#include <stdarg.h>
typedef struct _sim_engine sim_engine;
struct _sim_engine
diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c
index a5ec32d05c80..50c8cffce910 100644
--- a/sim/common/sim-events.c
+++ b/sim/common/sim-events.c
@@ -27,6 +27,7 @@
#include "defs.h"
#include <signal.h> /* For SIGPROCMASK et al. */
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sim/common/sim-events.h b/sim/common/sim-events.h
index 3f1501ea67cd..3c30d6489f8d 100644
--- a/sim/common/sim-events.h
+++ b/sim/common/sim-events.h
@@ -23,6 +23,7 @@
#ifndef SIM_EVENTS_H
#define SIM_EVENTS_H
+#include <stdarg.h>
/* Notes:
diff --git a/sim/common/sim-hw.c b/sim/common/sim-hw.c
index 1b086433e784..0c2309c5f761 100644
--- a/sim/common/sim-hw.c
+++ b/sim/common/sim-hw.c
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <ctype.h>
#include <errno.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sim/common/sim-hw.h b/sim/common/sim-hw.h
index 82c404a0d6d3..71dc8378b1d4 100644
--- a/sim/common/sim-hw.h
+++ b/sim/common/sim-hw.h
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef SIM_HW_H
#define SIM_HW_H
+#include <stdarg.h>
/* Parse a hardware definition */
diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c
index 5a47f65d8e5a..a278d6ec127d 100644
--- a/sim/common/sim-io.c
+++ b/sim/common/sim-io.c
@@ -26,6 +26,7 @@
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#include <stdarg.h>
#include <stdlib.h>
#if HAVE_UNISTD_H
#include <unistd.h>
diff --git a/sim/common/sim-io.h b/sim/common/sim-io.h
index f9fd1978ee29..c88adcde0f7d 100644
--- a/sim/common/sim-io.h
+++ b/sim/common/sim-io.h
@@ -23,6 +23,7 @@
#ifndef SIM_IO_H
#define SIM_IO_H
+#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/sim/common/sim-profile.c b/sim/common/sim-profile.c
index adde403186cc..393a0b733ed2 100644
--- a/sim/common/sim-profile.c
+++ b/sim/common/sim-profile.c
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include <ctype.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
index f4712aae78b9..fbfa27fac6f4 100644
--- a/sim/common/sim-trace.c
+++ b/sim/common/sim-trace.c
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sim/common/sim-trace.h b/sim/common/sim-trace.h
index c73dc6d367da..f17bbc634209 100644
--- a/sim/common/sim-trace.h
+++ b/sim/common/sim-trace.h
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef SIM_TRACE_H
#define SIM_TRACE_H
+#include <stdarg.h>
+
#include "dis-asm.h"
/* Standard traceable entities. */
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index e30627b88b30..2e4edb2ca3d2 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/4] sim: include stdint.h when needed
2021-12-05 3:10 [PATCH 1/4] sim: reorder header includes Mike Frysinger
2021-12-05 3:10 ` [PATCH 2/4] sim: include stdarg.h when used Mike Frysinger
@ 2021-12-05 3:10 ` Mike Frysinger
2021-12-05 3:10 ` [PATCH 4/4] sim: include ansidecl.h " Mike Frysinger
2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2021-12-05 3:10 UTC (permalink / raw)
To: gdb-patches
Avoid implicit include deps with this to help untangle sim headers
so we can get rid of arch-specific sim-main.h.
---
sim/common/callback.c | 1 +
sim/common/sim-io.c | 1 +
sim/common/sim-io.h | 1 +
3 files changed, 3 insertions(+)
diff --git a/sim/common/callback.c b/sim/common/callback.c
index 105488db262f..ed4d51d8d398 100644
--- a/sim/common/callback.c
+++ b/sim/common/callback.c
@@ -29,6 +29,7 @@
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c
index a278d6ec127d..8c40f7a0e73e 100644
--- a/sim/common/sim-io.c
+++ b/sim/common/sim-io.c
@@ -27,6 +27,7 @@
#include <fcntl.h>
#endif
#include <stdarg.h>
+#include <stdint.h>
#include <stdlib.h>
#if HAVE_UNISTD_H
#include <unistd.h>
diff --git a/sim/common/sim-io.h b/sim/common/sim-io.h
index c88adcde0f7d..2fc22f332ccc 100644
--- a/sim/common/sim-io.h
+++ b/sim/common/sim-io.h
@@ -24,6 +24,7 @@
#define SIM_IO_H
#include <stdarg.h>
+#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 4/4] sim: include ansidecl.h when needed
2021-12-05 3:10 [PATCH 1/4] sim: reorder header includes Mike Frysinger
2021-12-05 3:10 ` [PATCH 2/4] sim: include stdarg.h when used Mike Frysinger
2021-12-05 3:10 ` [PATCH 3/4] sim: include stdint.h when needed Mike Frysinger
@ 2021-12-05 3:10 ` Mike Frysinger
2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2021-12-05 3:10 UTC (permalink / raw)
To: gdb-patches
Avoid implicit include deps with this to help untangle sim headers
so we can get rid of arch-specific sim-main.h.
---
sim/common/cgen-trace.h | 2 ++
sim/common/genmloop.sh | 1 +
sim/common/hw-device.h | 2 ++
sim/common/hw-events.h | 2 ++
sim/common/hw-tree.h | 2 ++
sim/common/sim-basics.h | 1 -
sim/common/sim-engine.h | 2 ++
sim/common/sim-events.h | 2 ++
sim/common/sim-hw.h | 2 ++
sim/common/sim-inline.h | 1 +
sim/common/sim-io.h | 2 ++
sim/common/sim-profile.c | 2 ++
sim/common/sim-syscall.c | 2 ++
sim/common/sim-trace.c | 1 +
sim/common/sim-trace.h | 1 +
sim/common/sim-utils.h | 2 ++
16 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/sim/common/cgen-trace.h b/sim/common/cgen-trace.h
index c617e7e21e12..96048b906e20 100644
--- a/sim/common/cgen-trace.h
+++ b/sim/common/cgen-trace.h
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef CGEN_TRACE_H
#define CGEN_TRACE_H
+#include "ansidecl.h"
+
void cgen_trace_insn_init (SIM_CPU *, int);
void cgen_trace_insn_fini (SIM_CPU *, const struct argbuf *, int);
void cgen_trace_insn (SIM_CPU *, const struct cgen_insn *,
diff --git a/sim/common/genmloop.sh b/sim/common/genmloop.sh
index e1eb08c1bdfd..63e01ec4d98c 100755
--- a/sim/common/genmloop.sh
+++ b/sim/common/genmloop.sh
@@ -312,6 +312,7 @@ cat << EOF
#define WANT_CPU @cpu@
#define WANT_CPU_@CPU@
+#include "ansidecl.h"
#include "bfd.h"
#include "sim-main.h"
diff --git a/sim/common/hw-device.h b/sim/common/hw-device.h
index a7e598bb40e9..711001d13c9a 100644
--- a/sim/common/hw-device.h
+++ b/sim/common/hw-device.h
@@ -25,6 +25,8 @@
#include <stdarg.h>
+#include "ansidecl.h"
+
/* Introduction:
As explained in earlier sections, the device, device instance,
diff --git a/sim/common/hw-events.h b/sim/common/hw-events.h
index 7d750007c095..0b55542ad32a 100644
--- a/sim/common/hw-events.h
+++ b/sim/common/hw-events.h
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdarg.h>
+#include "ansidecl.h"
+
/* Event manager customized for hardware models.
This interface is discussed further in sim-events.h. */
diff --git a/sim/common/hw-tree.h b/sim/common/hw-tree.h
index 2f717ec8d9f4..07a95b4177dc 100644
--- a/sim/common/hw-tree.h
+++ b/sim/common/hw-tree.h
@@ -25,6 +25,8 @@
#include <stdarg.h>
+#include "ansidecl.h"
+
struct hw *hw_tree_create
(SIM_DESC sd,
const char *device);
diff --git a/sim/common/sim-basics.h b/sim/common/sim-basics.h
index f09a4f267205..62d47e417261 100644
--- a/sim/common/sim-basics.h
+++ b/sim/common/sim-basics.h
@@ -111,7 +111,6 @@ typedef enum {
\f
/* Basic definitions - ordered so that nothing calls what comes after it. */
-#include "ansidecl.h"
#include "sim/sim.h"
#include "sim-config.h"
diff --git a/sim/common/sim-engine.h b/sim/common/sim-engine.h
index 159d96bf119e..4d77856ef7e4 100644
--- a/sim/common/sim-engine.h
+++ b/sim/common/sim-engine.h
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdarg.h>
+#include "ansidecl.h"
+
typedef struct _sim_engine sim_engine;
struct _sim_engine
{
diff --git a/sim/common/sim-events.h b/sim/common/sim-events.h
index 3c30d6489f8d..b102a959ede4 100644
--- a/sim/common/sim-events.h
+++ b/sim/common/sim-events.h
@@ -25,6 +25,8 @@
#include <stdarg.h>
+#include "ansidecl.h"
+
/* Notes:
When scheduling an event, the a delta of zero/one refers to the
diff --git a/sim/common/sim-hw.h b/sim/common/sim-hw.h
index 71dc8378b1d4..0207aa3e5fc3 100644
--- a/sim/common/sim-hw.h
+++ b/sim/common/sim-hw.h
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdarg.h>
+#include "ansidecl.h"
+
/* Parse a hardware definition */
struct hw *sim_hw_parse
diff --git a/sim/common/sim-inline.h b/sim/common/sim-inline.h
index a397e58e10f2..216f30d2b638 100644
--- a/sim/common/sim-inline.h
+++ b/sim/common/sim-inline.h
@@ -23,6 +23,7 @@
#ifndef SIM_INLINE_H
#define SIM_INLINE_H
+#include "ansidecl.h"
/* INLINE CODE SELECTION:
diff --git a/sim/common/sim-io.h b/sim/common/sim-io.h
index 2fc22f332ccc..c77b4f8189dc 100644
--- a/sim/common/sim-io.h
+++ b/sim/common/sim-io.h
@@ -28,6 +28,8 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include "ansidecl.h"
+
/* See the file include/callbacks.h for a description */
int sim_io_init (SIM_DESC sd);
diff --git a/sim/common/sim-profile.c b/sim/common/sim-profile.c
index 393a0b733ed2..f4cdf40b05b1 100644
--- a/sim/common/sim-profile.c
+++ b/sim/common/sim-profile.c
@@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <string.h>
+#include "ansidecl.h"
+
#include "sim-main.h"
#include "sim-io.h"
#include "sim-options.h"
diff --git a/sim/common/sim-syscall.c b/sim/common/sim-syscall.c
index 1e83db2ae8a4..26f57f431bfb 100644
--- a/sim/common/sim-syscall.c
+++ b/sim/common/sim-syscall.c
@@ -22,6 +22,8 @@
#include <errno.h>
+#include "ansidecl.h"
+
#include "sim-main.h"
#include "sim-syscall.h"
#include "sim/callback.h"
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
index fbfa27fac6f4..15816100d561 100644
--- a/sim/common/sim-trace.c
+++ b/sim/common/sim-trace.c
@@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <string.h>
+#include "ansidecl.h"
#include "bfd.h"
#include "dis-asm.h"
#include "libiberty.h"
diff --git a/sim/common/sim-trace.h b/sim/common/sim-trace.h
index f17bbc634209..09e900c9f571 100644
--- a/sim/common/sim-trace.h
+++ b/sim/common/sim-trace.h
@@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdarg.h>
+#include "ansidecl.h"
#include "dis-asm.h"
/* Standard traceable entities. */
diff --git a/sim/common/sim-utils.h b/sim/common/sim-utils.h
index 1af4ea206b82..20ca9fcfe231 100644
--- a/sim/common/sim-utils.h
+++ b/sim/common/sim-utils.h
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef SIM_UTILS_H
#define SIM_UTILS_H
+#include "ansidecl.h"
+
/* Memory management with an allocator that clears memory before use. */
void *zalloc (unsigned long size);
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-05 9:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-05 3:10 [PATCH 1/4] sim: reorder header includes Mike Frysinger
2021-12-05 3:10 ` [PATCH 2/4] sim: include stdarg.h when used Mike Frysinger
2021-12-05 3:10 ` [PATCH 3/4] sim: include stdint.h when needed Mike Frysinger
2021-12-05 3:10 ` [PATCH 4/4] sim: include ansidecl.h " Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).