Subject: Re: Converting to little endian
To: Lennart Augustsson <augustss@cs.chalmers.se>
From: Todd Vierling <tv@pobox.com>
List: tech-kern
Date: 12/28/1998 08:14:13
On Mon, 28 Dec 1998, Lennart Augustsson wrote:

: I need to convert u_int32_t to little endian format (in the USB drivers).
: I assumed that this is a pretty common operation so there should be
: functions (macros) for it, but a quick perusal of the code gave me
: nothing?
: 
: What is the standard way to do it?

#include <sys/param.h>
#include <machine/bswap.h>
...

	u_int32_t x;
	...
#if BYTE_ORDER == BIG_ENDIAN
	x = bswap32(x);
#endif

-- 
-- Todd Vierling (Personal tv@pobox.com; Bus. todd_vierling@xn.xerox.com)