Idioms for byteswapping and unaligned memory access

2006-04-20 Thread Olivier Galibert
I need to be able to do unaligned memory accesses to memory in big-endian or little-endian mode. For portability, I'd like to do it in pure C, but I'd like the compiler to generate optimal sequences for the operations. Most CPUs that I know of even have special instructions designed to speed up

Re: Idioms for byteswapping and unaligned memory access

2006-04-20 Thread H. J. Lu
On Thu, Apr 20, 2006 at 05:18:08PM +0200, Olivier Galibert wrote: I need to be able to do unaligned memory accesses to memory in big-endian or little-endian mode. For portability, I'd like to do it in pure C, but I'd like the compiler to generate optimal sequences for the operations. Most

Re: Idioms for byteswapping and unaligned memory access

2006-04-20 Thread Olivier Galibert
On Thu, Apr 20, 2006 at 08:38:00AM -0700, H. J. Lu wrote: On Thu, Apr 20, 2006 at 05:18:08PM +0200, Olivier Galibert wrote: I need to be able to do unaligned memory accesses to memory in big-endian or little-endian mode. For portability, I'd like to do it in pure C, but I'd like the

Re: Idioms for byteswapping and unaligned memory access

2006-04-20 Thread Daniel Jacobowitz
On Thu, Apr 20, 2006 at 08:38:00AM -0700, H. J. Lu wrote: On Thu, Apr 20, 2006 at 05:18:08PM +0200, Olivier Galibert wrote: I need to be able to do unaligned memory accesses to memory in big-endian or little-endian mode. For portability, I'd like to do it in pure C, but I'd like the