#ifndef BYTEORDER_H_INCLUDED
#define BYTEORDER_H_INCLUDED
-#if defined (__s390__) || defined (__s390x__)
-#define le32_to_cpu(x) ( \
- (*(((unsigned char *) &(x)))) + \
- (*(((unsigned char *) &(x))+1) << 8) + \
- (*(((unsigned char *) &(x))+2) << 16) + \
- (*(((unsigned char *) &(x))+3) << 24) \
- )
+#ifdef __linux__
+# include <endian.h>
+# include <byteswap.h>
#else
-#define le32_to_cpu(x) (x)
+# error unsupported
+#endif
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+# define le32_to_cpu(x) (x)
+#elif BYTE_ORDER == BIG_ENDIAN
+# define le32_to_cpu(x) bswap_32(x)
+#else
+# error unsupported
#endif
#endif /* BYTEORDER_H_INCLUDED */