[PATCH] pcmciautils: handle big endian host in dump_cis
Kars de Jong
jongk at linux-m68k.org
Mon May 15 16:32:42 EDT 2006
Hi Dominik,
I have the following patch for pcmciautils. It's OK for glibc, but may
not work for other C libraries, I haven't checked.
From: Kars de Jong <jongk at linux-m68k.org>
[PATCH] pcmciautils: handle big endian host in dump_cis
- dump_cis: Use glibc functionality for detecting host endian and bytes wapping.
Signed-off-by: Kars de Jong <jongk at linux-m68k.org>
diff -ur pcmciautils-013/debug/parse_cis.c pcmciautils-013-kdj/debug/parse_cis.c
--- pcmciautils-013/debug/parse_cis.c Sun Mar 26 12:56:41 2006
+++ pcmciautils-013-kdj/debug/parse_cis.c Mon May 15 22:20:29 2006
@@ -18,6 +18,8 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <endian.h>
+#include <byteswap.h>
#include "../src/cistpl.h"
@@ -40,9 +42,13 @@
(mantissa[((v)>>3)&15] * exponent[(v)&7] / 10)
#define POWER_SCALE(v) (exponent[(v)&7])
-/* FIXME: how to handle this in userspace? */
-#define le32_to_cpu(value) (value)
-#define le16_to_cpu(value) (value)
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define le32_to_cpu(value) bswap_32(value)
+# define le16_to_cpu(value) bswap_16(value)
+#else
+# define le32_to_cpu(value) (value)
+# define le16_to_cpu(value) (value)
+#endif
static int parse_device(tuple_t *tuple, cistpl_device_t *device)
{
More information about the linux-pcmcia
mailing list