From ddf9f28b7fcb36da063e26102f7f97190e4158c8 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Mon, 7 Jun 2010 10:29:12 +0200 Subject: [PATCH] add byteorder macros --- usbtmc.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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; -- 2.39.2