Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch][sh] mac.l insn endian issue
@ 2008-02-01 10:26 Andrew STUBBS
  2008-02-01 22:40 ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew STUBBS @ 2008-02-01 10:26 UTC (permalink / raw)
  To: GDB Patches

[-- Attachment #1: Type: text/plain, Size: 151 bytes --]

Hi all,

The mac.l simulator implementation is broken on big endian hosts, such 
as Sparc Solaris.

The attached patch should fix the problem.

Andrew

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1208 bytes --]

2008-01-31  Antony King  <antony.king@st.com>

	Fix INSbl28170:
	* interp.c (macl): Fix non-portable implementation.

--- sim/sh/interp.c@@/main/INSIGHT-6.6-ST-1.0-int/1	2007-08-17 15:11:45.000000000 +0100
+++ sim/sh/interp.c	2008-01-31 18:33:16.000000000 +0000
@@ -1433,14 +1433,9 @@
      int m, n;
 {
   long tempm, tempn;
-  long prod, macl, mach, sum;
-  long long ans,ansl,ansh,t;
-  unsigned long long high,low,combine;
-  union mac64
-  {
-    long m[2]; /* mach and macl*/
-    long long m64; /* 64 bit MAC */
-  }mac64;
+  long macl, mach;
+  long long ans;
+  long long mac64;
 
   tempm = RSLAT (regs[m]);
   regs[m] += 4;
@@ -1451,15 +1446,15 @@
   mach = MACH;
   macl = MACL;
 
-  mac64.m[0] = macl;
-  mac64.m[1] = mach;
+  mac64 = ((long long) macl & 0xffffffff) |
+          ((long long) mach & 0xffffffff) << 32;
 
   ans = (long long) tempm * (long long) tempn; /* Multiply 32bit * 32bit */
 
-  mac64.m64 += ans; /* Accumulate   64bit + 64 bit */
+  mac64 += ans; /* Accumulate 64bit + 64 bit */
 
-  macl = mac64.m[0];
-  mach = mac64.m[1];
+  macl = (long) (mac64 & 0xffffffff);
+  mach = (long) ((mac64 >> 32) & 0xffffffff);
 
   if (S)  /* Store only 48 bits of the result */
     {

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

* Re: [patch][sh] mac.l insn endian issue
  2008-02-01 10:26 [patch][sh] mac.l insn endian issue Andrew STUBBS
@ 2008-02-01 22:40 ` Jim Blandy
  2008-02-04 11:54   ` Andrew STUBBS
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2008-02-01 22:40 UTC (permalink / raw)
  To: Andrew STUBBS; +Cc: GDB Patches

I don't think long long is guaranteed to be 64 bits long, but this is
certainly better than what's there now.  (I gather that STMicro has a
blanket assignment.)  So this looks okay to me.  Should Antony add
himself to the write-after-approval list?


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

* Re: [patch][sh] mac.l insn endian issue
  2008-02-01 22:40 ` Jim Blandy
@ 2008-02-04 11:54   ` Andrew STUBBS
  2008-02-04 13:40     ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew STUBBS @ 2008-02-04 11:54 UTC (permalink / raw)
  To: Jim Blandy; +Cc: GDB Patches

Jim Blandy wrote:
> I don't think long long is guaranteed to be 64 bits long, but this is
> certainly better than what's there now.  (I gather that STMicro has a
> blanket assignment.)  So this looks okay to me.  Should Antony add
> himself to the write-after-approval list?

It uses the same types the original implementation did, so I don't think 
it's any worse. I suspect that much of the simulator implementation 
would fall apart if the size of char, short, int and long long were not 
as expected.

ST does indeed have all the proper assignments. I do not know what is 
the proper thing to do with the write-after-approval list. Antony does 
not have write access, hence why I was posting it on his behalf. This 
stuff is usually handled by myself and Denis Pilat, both on the list.

If this is not a problem then I shall go ahead and check in the patch 
(minus the internal ST bug number).

Andrew


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

* Re: [patch][sh] mac.l insn endian issue
  2008-02-04 11:54   ` Andrew STUBBS
@ 2008-02-04 13:40     ` Daniel Jacobowitz
  2008-02-04 17:27       ` Andrew STUBBS
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2008-02-04 13:40 UTC (permalink / raw)
  To: gdb-patches

On Mon, Feb 04, 2008 at 11:53:17AM +0000, Andrew STUBBS wrote:
> If this is not a problem then I shall go ahead and check in the patch  
> (minus the internal ST bug number).

It's not a problem - go ahead.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [patch][sh] mac.l insn endian issue
  2008-02-04 13:40     ` Daniel Jacobowitz
@ 2008-02-04 17:27       ` Andrew STUBBS
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew STUBBS @ 2008-02-04 17:27 UTC (permalink / raw)
  To: gdb-patches

Daniel Jacobowitz wrote:
> On Mon, Feb 04, 2008 at 11:53:17AM +0000, Andrew STUBBS wrote:
>> If this is not a problem then I shall go ahead and check in the patch  
>> (minus the internal ST bug number).
> 
> It's not a problem - go ahead.
> 
Thanks, committed.


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

end of thread, other threads:[~2008-02-04 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-01 10:26 [patch][sh] mac.l insn endian issue Andrew STUBBS
2008-02-01 22:40 ` Jim Blandy
2008-02-04 11:54   ` Andrew STUBBS
2008-02-04 13:40     ` Daniel Jacobowitz
2008-02-04 17:27       ` Andrew STUBBS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox