OSDN Git Service

libext2fs: use ext2fs byte swap functions for portability
authorTheodore Ts'o <tytso@mit.edu>
Thu, 29 Sep 2011 00:27:03 +0000 (20:27 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 29 Sep 2011 00:27:03 +0000 (20:27 -0400)
The functions htole32(), le32toh(), be32toh(), htobe32() aren't
defined in all environments.  Use the ext2fs byte swap functions for
portability.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/crc32c_defs.h

index 1752970..ced4f67 100644 (file)
                (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
 
 
+#include "ext2fs.h"
 #ifdef WORDS_BIGENDIAN
 #define __constant_cpu_to_le32(x) ___constant_swab32((x))
 #define __constant_cpu_to_be32(x) (x)
 #define __be32_to_cpu(x) (x)
 #define __cpu_to_be32(x) (x)
-#define __cpu_to_le32(x) (htole32((x)))
-#define __le32_to_cpu(x) (le32toh((x)))
+#define __cpu_to_le32(x) (ext2fs_cpu_to_le32((x)))
+#define __le32_to_cpu(x) (ext2fs_le32_to_cpu((x)))
 #else
 #define __constant_cpu_to_le32(x) (x)
 #define __constant_cpu_to_be32(x) ___constant_swab32((x))
-#define __be32_to_cpu(x) (be32toh((x)))
-#define __cpu_to_be32(x) (htobe32((x)))
+#define __be32_to_cpu(x) (ext2fs_be32_to_cpu((x)))
+#define __cpu_to_be32(x) (ext2fs_cpu_to_be32((x)))
 #define __cpu_to_le32(x) (x)
 #define __le32_to_cpu(x) (x)
 #endif