From 2c29882f833f634d776b19fa15a1f1bad70bf447 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sat, 4 Dec 2021 21:04:41 -0500
Subject: [PATCH] sim: include stdarg.h when used

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 f372c471d34..f8f87279472 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 b30eede5e3b..28450fad211 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 ffd627a441f..a7e598bb40e 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 301f868ce2e..3337416eab7 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 51ca5bdb2f0..7d750007c09 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 2e441cec98b..c5fa1bc2806 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 85c91ad9652..2f717ec8d9f 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 06df127c19c..d30b9a46d68 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 0e06b55bfa1..5eeef51e345 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 1feb8a6d40b..159d96bf119 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 a5ec32d05c8..50c8cffce91 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 3f1501ea67c..3c30d6489f8 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 1b086433e78..0c2309c5f76 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 82c404a0d6d..71dc8378b1d 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 5a47f65d8e5..a278d6ec127 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 f9fd1978ee2..c88adcde0f7 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 adde403186c..393a0b733ed 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 f4712aae78b..fbfa27fac6f 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 c73dc6d367d..f17bbc63420 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 e30627b88b3..2e4edb2ca3d 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>