public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: common, microblaze, mn10300: handle signal.h defining REC_PC.
@ 2023-01-14 23:28 Mark Wielaard
  2023-01-15  0:22 ` Mike Frysinger
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Wielaard @ 2023-01-14 23:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Sam James, Mike Frysinger, Mark Wielaard

signal.h isn't needed in microblaze and mn10300 interp.c
so don't include it.

In common sim-events.c, sim-signal.c, nrun.c and dv-sockser.c we
do need signal.h, but check whether REG_PC is defined (and then
undefine it) before including the sim headers.

It breaks the build on sparc because signal.h indirectly
includes /usr/include/sys/ucontext.h and defines REG_PC,
which is also defined in microblaze-opcm.h
---
 sim/common/dv-sockser.c | 6 ++++++
 sim/common/nrun.c       | 6 ++++++
 sim/common/sim-events.c | 6 ++++++
 sim/common/sim-signal.c | 6 ++++++
 sim/microblaze/interp.c | 1 -
 sim/mn10300/interp.c    | 2 --
 6 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index fba2775f2e8..db6ab8fc4be 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -39,6 +39,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/time.h>
 #include <sys/types.h>
 
+/* signal.h might indirectly have defined some REG_ macros
+   which are also defined in the sim headers.  */
+#ifdef REG_PC
+#undef REG_PC
+#endif
+
 #include "sim-main.h"
 #include "sim-assert.h"
 #include "sim-options.h"
diff --git a/sim/common/nrun.c b/sim/common/nrun.c
index 4c011627bb8..6ad2b19fb0d 100644
--- a/sim/common/nrun.c
+++ b/sim/common/nrun.c
@@ -29,6 +29,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "bfd.h"
 #include "environ.h"
 
+/* signal.h might indirectly have defined some REG_ macros
+   which are also defined in the sim headers.  */
+#ifdef REG_PC
+#undef REG_PC
+#endif
+
 #include "sim-main.h"
 #include "sim-signal.h"
 #include "sim/callback.h"
diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c
index e2afe2be6c5..ce3a5dc1652 100644
--- a/sim/common/sim-events.c
+++ b/sim/common/sim-events.c
@@ -33,6 +33,12 @@
 
 #include "libiberty.h"
 
+/* signal.h might indirectly have defined some REG_ macros
+   which are also defined in the sim headers.  */
+#ifdef REG_PC
+#undef REG_PC
+#endif
+
 #include "sim-main.h"
 #include "sim-assert.h"
 #include "sim-cpu.h"
diff --git a/sim/common/sim-signal.c b/sim/common/sim-signal.c
index 9c4e261fa21..94d5d9d51c9 100644
--- a/sim/common/sim-signal.c
+++ b/sim/common/sim-signal.c
@@ -22,6 +22,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <signal.h>
 
+/* signal.h might indirectly have defined some REG_ macros
+   which are also defined in the sim headers.  */
+#ifdef REG_PC
+#undef REG_PC
+#endif
+
 #include "sim-main.h"
 #include "sim-signal.h"
 
diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
index a4f505e77a8..f53c1d7d65b 100644
--- a/sim/microblaze/interp.c
+++ b/sim/microblaze/interp.c
@@ -19,7 +19,6 @@
 /* This must come before any other includes.  */
 #include "defs.h"
 
-#include <signal.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
diff --git a/sim/mn10300/interp.c b/sim/mn10300/interp.c
index 2915551253f..07c3b8c900f 100644
--- a/sim/mn10300/interp.c
+++ b/sim/mn10300/interp.c
@@ -1,8 +1,6 @@
 /* This must come before any other includes.  */
 #include "defs.h"
 
-#include <signal.h>
-
 #include "sim-main.h"
 #include "sim-options.h"
 #include "sim-hw.h"
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-15 17:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-14 23:28 [PATCH] sim: common, microblaze, mn10300: handle signal.h defining REC_PC Mark Wielaard
2023-01-15  0:22 ` Mike Frysinger
2023-01-15  0:58   ` Sam James
2023-01-15  8:07     ` Mike Frysinger
2023-01-15 17:48   ` Mark Wielaard

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).