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

Joerg


Home | Main Index | Thread Index | Old Index