Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org>
To: "CHIGOT, CLEMENT" <clement.chigot@atos.net>
Cc: Nick Clifton <nickc@redhat.com>,
	gdb-patches@sourceware.org, binutils@sourceware.org
Subject: Re: sim/ppc PAGE_SIZE redefinition
Date: Thu, 17 Jun 2021 19:06:57 -0400	[thread overview]
Message-ID: <YMvVkUQ4sHgyAVPE@vapier> (raw)
In-Reply-To: <PA4PR02MB66860C617F013F3B3CC8F07AEA0E9@PA4PR02MB6686.eurprd02.prod.outlook.com>

On 17 Jun 2021 12:00, CHIGOT, CLEMENT via Binutils wrote:
> > > I'm not able to build "sim/ppc" anymore on AIX.
> > 
> > The sim sources are part of gdb, not the binutils ...
> 
> Oh, I wasn't aware of that. 
> Note that it's still being built even when --disable-gdb is provided 
> to the configure.  
> 
> >> or is it safe to
> >> rename it PAGE_SIZE_1k or something like that ?
> >
> > It really depends upon how the simulator sources are going to use the constant.
> > But it would probably be best if the value used inside the simulator matched
> > the system value.  That way you are unlikely to run into host-vs-sim emulation
> > issues.  All of which is a fancy to way to say that the best solutions is
> > probably to patch semantics.h to only define PAGE_SIZE if it is not already
> > defined.
> 
> That's what I've done locally. But I don't know anything about sim. The tests 
> on AIX aren't even building. On linux/ppc64le, it seems ok though. I can 
> submit the patch, but I want to be sure that this is the correct way to fix that.

the PAGE_SIZE here has no relationship to the host system.  it's just used for
a single cpu hardware quirk.  so we can safely rename it to anything else.
-mike

From a49dd19e81deb6d6c4af0fcadd94be1574f0b7dc Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Thu, 17 Jun 2021 19:03:32 -0400
Subject: [PATCH] sim: ppc: avoid "PAGE_SIZE" name

This define is used for a particular target and depends on the
simulated CPU hardware.  It has no relation to the host CPU that
the sim is running on.  So rename the common "PAGE_SIZE" here to
better reflect its usage and avoid conflicts with system headers.
---
 sim/ppc/ChangeLog        | 5 +++++
 sim/ppc/igen.c           | 2 +-
 sim/ppc/ppc-instructions | 6 +++---
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog
index 05178aa427b5..280234af869e 100644
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+	* igen.c (gen_semantics_h): Rename PAGE_SIZE to MPC860C0_PAGE_SIZE.
+	* ppc-instructions: Likewise.
+
 2021-06-16  Mike Frysinger  <vapier@gentoo.org>
 
 	* configure.ac: Delete AC_EXEEXT call.
diff --git a/sim/ppc/igen.c b/sim/ppc/igen.c
index 0bf3b58ca26d..f0ff06b31c41 100644
--- a/sim/ppc/igen.c
+++ b/sim/ppc/igen.c
@@ -182,7 +182,7 @@ gen_semantics_h(insn_table *table,
   lf_printf(file, "\n");
   if ((code & generate_calls)) {
     lf_printf(file, "extern int option_mpc860c0;\n");
-    lf_printf(file, "#define PAGE_SIZE 0x1000\n");
+    lf_printf(file, "#define MPC860C0_PAGE_SIZE 0x1000\n");
     lf_printf(file, "\n");
     lf_printf(file, "PSIM_EXTERN_SEMANTICS(void)\n");
     lf_printf(file, "semantic_init(device* root);\n");
diff --git a/sim/ppc/ppc-instructions b/sim/ppc/ppc-instructions
index 70aa04e2210e..2278b6263765 100644
--- a/sim/ppc/ppc-instructions
+++ b/sim/ppc/ppc-instructions
@@ -1537,7 +1537,7 @@ void::function::invalid_zero_divide_operation:cpu *processor, unsigned_word cia,
 	  If this is a forward branch and it is near the end of a page,
 	  we've detected a problematic branch. */
 	  if (succeed && NIA > CIA) {
-	    if (PAGE_SIZE - (CIA & (PAGE_SIZE-1)) <= option_mpc860c0)
+	    if (MPC860C0_PAGE_SIZE - (CIA & (MPC860C0_PAGE_SIZE-1)) <= option_mpc860c0)
 	      program_interrupt(processor, cia, mpc860c0_instruction_program_interrupt);
 	  }
 	}
@@ -1579,7 +1579,7 @@ void::function::invalid_zero_divide_operation:cpu *processor, unsigned_word cia,
 	  If this is a forward branch and it is near the end of a page,
 	  we've detected a problematic branch. */
 	  if (succeed && NIA > CIA) {
-	    if (PAGE_SIZE - (CIA & (PAGE_SIZE-1)) <= option_mpc860c0)
+	    if (MPC860C0_PAGE_SIZE - (CIA & (MPC860C0_PAGE_SIZE-1)) <= option_mpc860c0)
 	      program_interrupt(processor, cia, mpc860c0_instruction_program_interrupt);
 	  }
 	}
@@ -1610,7 +1610,7 @@ void::function::invalid_zero_divide_operation:cpu *processor, unsigned_word cia,
 	  If this is a forward branch and it is near the end of a page,
 	  we've detected a problematic branch. */
 	  if (succeed && NIA > CIA) {
-	    if (PAGE_SIZE - (CIA & (PAGE_SIZE-1)) <= option_mpc860c0)
+	    if (MPC860C0_PAGE_SIZE - (CIA & (MPC860C0_PAGE_SIZE-1)) <= option_mpc860c0)
 	      program_interrupt(processor, cia, mpc860c0_instruction_program_interrupt);
 	  }
 	}
-- 
2.31.1

           reply	other threads:[~2021-06-17 23:09 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <PA4PR02MB66860C617F013F3B3CC8F07AEA0E9@PA4PR02MB6686.eurprd02.prod.outlook.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YMvVkUQ4sHgyAVPE@vapier \
    --to=gdb-patches@sourceware.org \
    --cc=binutils@sourceware.org \
    --cc=clement.chigot@atos.net \
    --cc=nickc@redhat.com \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox