From: Michael Gernoth Date: Mon, 7 Jun 2010 08:29:12 +0000 (+0200) Subject: add byteorder macros X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rigol/commitdiff_plain/ddf9f28b7fcb36da063e26102f7f97190e4158c8 add byteorder macros --- diff --git a/usbtmc.c b/usbtmc.c index 32f83a8..835b6c8 100644 --- a/usbtmc.c +++ b/usbtmc.c @@ -8,6 +8,14 @@ #define USB_TIMEOUT 50000 +#if BYTE_ORDER == LITTLE_ENDIAN +#define LE32(x) x +#elif BYTE_ORDER == BIG_ENDIAN +#define LE32(x) ((uint32_t)((((uint32_t)x)>>24) | ((((uint32_t)x)>>8) & 0xff00) | ((((uint32_t)x)<<8) & 0xff0000) | (((uint32_t)x)<<24))) +#else +#error BYTE_ORDER not defined/known! +#endif + //Helper-routine: Convert a little-endian 4-byte word to an int static void int2chars(unsigned char *buff,unsigned int a) { buff[3]=(a>>24)&0xff;