public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: add checks to core headers to prevent incorrect common building
@ 2021-11-28 19:28 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2021-11-28 19:28 UTC (permalink / raw)
  To: gdb-patches

Some of the core sim headers rely on the SIM_AC_OPTION_BITSIZE macro
which can change the size of core types.  Since these haven't been
unified across ports, add checks to make sure they aren't accidentally
included when building for all ports.  This caught the sim-load file
using poisoned headers that it didn't actually need.
---
 sim/common/sim-config.h | 3 +++
 sim/common/sim-load.c   | 3 +--
 sim/common/sim-types.h  | 4 ++++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/sim/common/sim-config.h b/sim/common/sim-config.h
index aae08e71c585..88bdedf687dc 100644
--- a/sim/common/sim-config.h
+++ b/sim/common/sim-config.h
@@ -23,6 +23,9 @@
 #ifndef SIM_CONFIG_H
 #define SIM_CONFIG_H
 
+#ifdef SIM_COMMON_BUILD
+#error "This header is unusable in common builds due to reliance on SIM_AC_OPTION_BITSIZE"
+#endif
 
 /* Host dependant:
 
diff --git a/sim/common/sim-load.c b/sim/common/sim-load.c
index 3ea50e7fbcde..ec5df418d9de 100644
--- a/sim/common/sim-load.c
+++ b/sim/common/sim-load.c
@@ -27,12 +27,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <stdlib.h>
 #include <time.h>
 
-#include "sim-basics.h"
 #include "bfd.h"
-#include "sim-utils.h"
 
 #include "sim/callback.h"
 #include "sim/sim.h"
+#include "sim-utils.h"
 
 static void eprintf (host_callback *, const char *, ...);
 static void xprintf (host_callback *, const char *, ...);
diff --git a/sim/common/sim-types.h b/sim/common/sim-types.h
index 8e1c9ada920d..5fd0a1dcff22 100644
--- a/sim/common/sim-types.h
+++ b/sim/common/sim-types.h
@@ -23,6 +23,10 @@
 #ifndef SIM_TYPES_H
 #define SIM_TYPES_H
 
+#ifdef SIM_COMMON_BUILD
+#error "This header is unusable in common builds due to reliance on SIM_AC_OPTION_BITSIZE"
+#endif
+
 #include <stdint.h>
 
 /* INTEGER QUANTITIES:
-- 
2.33.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-28 19:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-28 19:28 [PATCH] sim: add checks to core headers to prevent incorrect common building 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).