tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Please do not yell at people for trying to help you.



On Fri, 12 Nov 2010, Joerg Sonnenberger wrote:

> On Fri, Nov 12, 2010 at 06:35:32PM +0000, Eduardo Horvath wrote:
> > Take, for example, the simple act of byte swapping network data.  x86 has 
> > a bswap instruction.  SPARC and PowerPC architectures have a multiplexer 
> > on the load/store.  (Don't know about MIPS, don't remember about ARM.)  In 
> > order to swap a 64-bit value in registers you need to issue a series of 
> > shift, mask, and or instrutions, usually about 8 of them, most of which 
> > are depenent (cannot be issued in parallel on a superscalar machine).
> > The macro NetBSD uses here is bswap64().  This maps very well to the x86 
> > instruction, but is really not usable for any machine that does the 
> > swapping in the load/store path.  Instead we could use something like 
> > load_be64()/load_le64()/store_be64()/store_le64() which could be mapped to 
> > a reverse-endian load/store instruction on architetures that support it 
> > and bswap on x86.  
> 
> If you look at sys/endian.h, that is exactly the kind of abstraction the
> API makes easy to use. Just provide the proper inline functions for your
> platform.

No it doesen't because all those macros assume the value is being 
transferred from one register to another rather than regiser to memory.  
The assignment:

foo.size = htole64(size);

Cannot be replaced with:

__inline __asm("stxa %1, [%0] ASI_LITLE" : &foo.size : size);

Eduardo


Home | Main Index | Thread Index | Old Index