]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
add cpu_to_be* / be*_to_cpu helpers for userspace
authorChristoph Hellwig <hch@sgi.com>
Wed, 9 Nov 2005 05:52:56 +0000 (05:52 +0000)
committerChristoph Hellwig <hch@sgi.com>
Wed, 9 Nov 2005 05:52:56 +0000 (05:52 +0000)
add cpu_to_be* / be*_to_cpu helpers for userspace

include/xfs_arch.h

index f3c8b4cfe734da68d1252af751fe50d7734cc2b2..17d5e50cac363d0d2f076181e7cd3a56fdd096f8 100644 (file)
 #undef XFS_NATIVE_HOST
 #endif
 
+#ifdef XFS_NATIVE_HOST
+#define cpu_to_be16(val)       ((__be16)(val))
+#define cpu_to_be32(val)       ((__be32)(val))
+#define cpu_to_be64(val)       ((__be64)(val))
+#define be16_to_cpu(val)       ((__uint16_t)(val)
+#define be32_to_cpu(val)       ((__uint32_t)(val))
+#define be64_to_cpu(val)       ((__uint64_t)(val))
+#else
+#define cpu_to_be16(val)       (__swab16((__uint16_t)(val)))
+#define cpu_to_be32(val)       (__swab32((__uint32_t)(val)))
+#define cpu_to_be64(val)       (__swab64((__uint64_t)(val)))
+#define be16_to_cpu(val)       (__swab16((__be16)(val)))
+#define be32_to_cpu(val)       (__swab32((__be32)(val)))
+#define be64_to_cpu(val)       (__swab64((__be64)(val)))
+#endif
+
 #endif /* __KERNEL__ */
 
 /* do we need conversion? */