qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [Patch] Swapping functions for Mac OS X
@ 2004-07-17 13:50 Pierre d'Herbemont
  2004-07-24 14:33 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 5+ messages in thread
From: Pierre d'Herbemont @ 2004-07-17 13:50 UTC (permalink / raw)
  To: Fabrice Bellard; +Cc: qemu-devel

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

Hi Fabrice,

I think it should be quite useful to use the swapping functions on Mac 
OS X. However I don't see a huge performance gain with this patch.

Thanks,

Pierre.

[-- Attachment #2: qemudbswap.diff.txt --]
[-- Type: text/plain, Size: 516 bytes --]

Index: bswap.h
===================================================================
RCS file: /cvsroot/qemu/qemu/bswap.h,v
retrieving revision 1.3
diff -u -r1.3 bswap.h
--- bswap.h	21 Mar 2004 17:06:25 -0000	1.3
+++ bswap.h	17 Jul 2004 13:47:35 -0000
@@ -7,6 +7,11 @@
 
 #ifdef HAVE_BYTESWAP_H
 #include <byteswap.h>
+#elif defined(__APPLE__)
+#include <machine/byte_order.h>
+#define bswap_16(x) NXSwapShort(x)
+#define bswap_32(x) NXSwapInt(x)
+#define bswap_64(x) NXSwapLongLong(x)
 #else
 
 #define bswap_16(x) \

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

* Re: [Qemu-devel] [Patch] Swapping functions for Mac OS X
  2004-07-17 13:50 [Qemu-devel] [Patch] Swapping functions for Mac OS X Pierre d'Herbemont
@ 2004-07-24 14:33 ` Benjamin Herrenschmidt
  2004-07-26 17:48   ` stegefin
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2004-07-24 14:33 UTC (permalink / raw)
  To: qemu-devel


On Sat, 2004-07-17 at 09:50, Pierre d'Herbemont wrote:
> Hi Fabrice,
> 
> I think it should be quite useful to use the swapping functions on Mac 
> OS X. However I don't see a huge performance gain with this patch.

Ugh ? How cna it be useful to call into library functions why you can
use inline assembly ? Actually, if the swap is done on data loaded/stored
from/to memory, then you can use the ppc endian swapped load/store
instructions

Ben.

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

* Re: [Qemu-devel] [Patch] Swapping functions for Mac OS X
  2004-07-24 14:33 ` Benjamin Herrenschmidt
@ 2004-07-26 17:48   ` stegefin
  2004-07-26 21:00     ` Laurent Amon
  2004-07-28  1:13     ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 5+ messages in thread
From: stegefin @ 2004-07-26 17:48 UTC (permalink / raw)
  To: qemu-devel, Benjamin Herrenschmidt

Benjamin,

I think that the NXSwap functions are defined as inlined asm in the header.

Pierre

Quoting Benjamin Herrenschmidt <benh@kernel.crashing.org>:

>
> On Sat, 2004-07-17 at 09:50, Pierre d'Herbemont wrote:
> > Hi Fabrice,
> >
> > I think it should be quite useful to use the swapping functions on Mac
> > OS X. However I don't see a huge performance gain with this patch.
>
> Ugh ? How cna it be useful to call into library functions why you can
> use inline assembly ? Actually, if the swap is done on data loaded/stored
> from/to memory, then you can use the ppc endian swapped load/store
> instructions
>
> Ben.
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>

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

* Re: [Qemu-devel] [Patch] Swapping functions for Mac OS X
  2004-07-26 17:48   ` stegefin
@ 2004-07-26 21:00     ` Laurent Amon
  2004-07-28  1:13     ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 5+ messages in thread
From: Laurent Amon @ 2004-07-26 21:00 UTC (permalink / raw)
  To: qemu-devel

Since I just looked, I can confirm it.

cpp includes this when including bswap.h :

static __inline
uint16_t
OSReadSwapInt16(
     __volatile void               * base,
     uintptr_t                          offset
)
{
     uint16_t result;
     __asm__ __volatile("lhbrx %0, %1, %2"
                      : "=r" (result)
                      : "b%"  (base), "r" (offset)
                      : "memory");
     return result;
}

And all wrappers are static inline so everything *should* get ASM 
inline.

However, I ran a few benchmarks and it makes no difference. So either 
gcc 3.3 is intelligent enough to do it anyway, or the code does not 
rely much on them, or they do not perform on my PPC7410. This bears 
more investigation.

Lga.

On 26 juil. 04, at 19:48, stegefin@free.fr wrote:

> Benjamin,
>
> I think that the NXSwap functions are defined as inlined asm in the 
> header.
>
> Pierre
>
> Quoting Benjamin Herrenschmidt <benh@kernel.crashing.org>:
>
>>
>> On Sat, 2004-07-17 at 09:50, Pierre d'Herbemont wrote:
>>> Hi Fabrice,
>>>
>>> I think it should be quite useful to use the swapping functions on 
>>> Mac
>>> OS X. However I don't see a huge performance gain with this patch.
>>
>> Ugh ? How cna it be useful to call into library functions why you can
>> use inline assembly ? Actually, if the swap is done on data 
>> loaded/stored
>> from/to memory, then you can use the ppc endian swapped load/store
>> instructions
>>
>> Ben.
>>
>>
>>
>> _______________________________________________
>> Qemu-devel mailing list
>> Qemu-devel@nongnu.org
>> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>>
>
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>
>

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

* Re: [Qemu-devel] [Patch] Swapping functions for Mac OS X
  2004-07-26 17:48   ` stegefin
  2004-07-26 21:00     ` Laurent Amon
@ 2004-07-28  1:13     ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2004-07-28  1:13 UTC (permalink / raw)
  To: stegefin; +Cc: qemu-devel

On Mon, 2004-07-26 at 13:48, stegefin@free.fr wrote:
> Benjamin,
> 
> I think that the NXSwap functions are defined as inlined asm in the header.

Ah ok. Sorry for the noise then.

Ben.

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

end of thread, other threads:[~2004-07-28  1:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-17 13:50 [Qemu-devel] [Patch] Swapping functions for Mac OS X Pierre d'Herbemont
2004-07-24 14:33 ` Benjamin Herrenschmidt
2004-07-26 17:48   ` stegefin
2004-07-26 21:00     ` Laurent Amon
2004-07-28  1:13     ` Benjamin Herrenschmidt

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 NNTP newsgroup(s).