Commit 5d7b32de authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] beginning of endianness annotations

This adds the types and annotates conversion functions.  I've converted
the ...p() versions to inlines; AFAICS, everything's still happy...
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ee1afb3f
...@@ -8,48 +8,86 @@ ...@@ -8,48 +8,86 @@
#define __BIG_ENDIAN_BITFIELD #define __BIG_ENDIAN_BITFIELD
#endif #endif
#include <linux/types.h>
#include <linux/byteorder/swab.h> #include <linux/byteorder/swab.h>
#define __constant_htonl(x) ((__u32)(x)) #define __constant_htonl(x) ((__u32)(x))
#define __constant_ntohl(x) ((__u32)(x)) #define __constant_ntohl(x) ((__u32)(x))
#define __constant_htons(x) ((__u16)(x)) #define __constant_htons(x) ((__u16)(x))
#define __constant_ntohs(x) ((__u16)(x)) #define __constant_ntohs(x) ((__u16)(x))
#define __constant_cpu_to_le64(x) ___constant_swab64((x)) #define __constant_cpu_to_le64(x) ((__force __le64)___constant_swab64((x)))
#define __constant_le64_to_cpu(x) ___constant_swab64((x)) #define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le64)(x))
#define __constant_cpu_to_le32(x) ___constant_swab32((x)) #define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x)))
#define __constant_le32_to_cpu(x) ___constant_swab32((x)) #define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le32)(x))
#define __constant_cpu_to_le16(x) ___constant_swab16((x)) #define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x)))
#define __constant_le16_to_cpu(x) ___constant_swab16((x)) #define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le16)(x))
#define __constant_cpu_to_be64(x) ((__u64)(x)) #define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x))
#define __constant_be64_to_cpu(x) ((__u64)(x)) #define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x))
#define __constant_cpu_to_be32(x) ((__u32)(x)) #define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x))
#define __constant_be32_to_cpu(x) ((__u32)(x)) #define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x))
#define __constant_cpu_to_be16(x) ((__u16)(x)) #define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x))
#define __constant_be16_to_cpu(x) ((__u16)(x)) #define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x))
#define __cpu_to_le64(x) __swab64((x)) #define __cpu_to_le64(x) ((__force __le64)___swab64((x)))
#define __le64_to_cpu(x) __swab64((x)) #define __le64_to_cpu(x) ___swab64((__force __u64)(__le64)(x))
#define __cpu_to_le32(x) __swab32((x)) #define __cpu_to_le32(x) ((__force __le32)___swab32((x)))
#define __le32_to_cpu(x) __swab32((x)) #define __le32_to_cpu(x) ___swab32((__force __u32)(__le32)(x))
#define __cpu_to_le16(x) __swab16((x)) #define __cpu_to_le16(x) ((__force __le16)___swab16((x)))
#define __le16_to_cpu(x) __swab16((x)) #define __le16_to_cpu(x) ___swab16((__force __u16)(__le16)(x))
#define __cpu_to_be64(x) ((__u64)(x)) #define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
#define __be64_to_cpu(x) ((__u64)(x)) #define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
#define __cpu_to_be32(x) ((__u32)(x)) #define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
#define __be32_to_cpu(x) ((__u32)(x)) #define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
#define __cpu_to_be16(x) ((__u16)(x)) #define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
#define __be16_to_cpu(x) ((__u16)(x)) #define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
#define __cpu_to_le64p(x) __swab64p((x))
#define __le64_to_cpup(x) __swab64p((x)) static inline __le64 __cpu_to_le64p(const __u64 *p)
#define __cpu_to_le32p(x) __swab32p((x)) {
#define __le32_to_cpup(x) __swab32p((x)) return (__force __le64)__swab64p(p);
#define __cpu_to_le16p(x) __swab16p((x)) }
#define __le16_to_cpup(x) __swab16p((x)) static inline __u64 __le64_to_cpup(const __le64 *p)
#define __cpu_to_be64p(x) (*(__u64*)(x)) {
#define __be64_to_cpup(x) (*(__u64*)(x)) return __swab64p((__u64 *)p);
#define __cpu_to_be32p(x) (*(__u32*)(x)) }
#define __be32_to_cpup(x) (*(__u32*)(x)) static inline __le32 __cpu_to_le32p(const __u32 *p)
#define __cpu_to_be16p(x) (*(__u16*)(x)) {
#define __be16_to_cpup(x) (*(__u16*)(x)) return (__force __le32)__swab32p(p);
}
static inline __u32 __le32_to_cpup(const __le32 *p)
{
return __swab32p((__u32 *)p);
}
static inline __le16 __cpu_to_le16p(const __u16 *p)
{
return (__force __le16)__swab16p(p);
}
static inline __u16 __le16_to_cpup(const __le16 *p)
{
return __swab16p((__u16 *)p);
}
static inline __be64 __cpu_to_be64p(const __u64 *p)
{
return (__force __be64)*p;
}
static inline __u64 __be64_to_cpup(const __be64 *p)
{
return (__force __u64)*p;
}
static inline __be32 __cpu_to_be32p(const __u32 *p)
{
return (__force __be32)*p;
}
static inline __u32 __be32_to_cpup(const __be32 *p)
{
return (__force __u32)*p;
}
static inline __be16 __cpu_to_be16p(const __u16 *p)
{
return (__force __be16)*p;
}
static inline __u16 __be16_to_cpup(const __be16 *p)
{
return (__force __u16)*p;
}
#define __cpu_to_le64s(x) __swab64s((x)) #define __cpu_to_le64s(x) __swab64s((x))
#define __le64_to_cpus(x) __swab64s((x)) #define __le64_to_cpus(x) __swab64s((x))
#define __cpu_to_le32s(x) __swab32s((x)) #define __cpu_to_le32s(x) __swab32s((x))
......
...@@ -8,48 +8,86 @@ ...@@ -8,48 +8,86 @@
#define __LITTLE_ENDIAN_BITFIELD #define __LITTLE_ENDIAN_BITFIELD
#endif #endif
#include <linux/types.h>
#include <linux/byteorder/swab.h> #include <linux/byteorder/swab.h>
#define __constant_htonl(x) ___constant_swab32((x)) #define __constant_htonl(x) ___constant_swab32((x))
#define __constant_ntohl(x) ___constant_swab32((x)) #define __constant_ntohl(x) ___constant_swab32((x))
#define __constant_htons(x) ___constant_swab16((x)) #define __constant_htons(x) ___constant_swab16((x))
#define __constant_ntohs(x) ___constant_swab16((x)) #define __constant_ntohs(x) ___constant_swab16((x))
#define __constant_cpu_to_le64(x) ((__u64)(x)) #define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x))
#define __constant_le64_to_cpu(x) ((__u64)(x)) #define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x))
#define __constant_cpu_to_le32(x) ((__u32)(x)) #define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x))
#define __constant_le32_to_cpu(x) ((__u32)(x)) #define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x))
#define __constant_cpu_to_le16(x) ((__u16)(x)) #define __constant_cpu_to_le16(x) ((__force __le16)(__u16)(x))
#define __constant_le16_to_cpu(x) ((__u16)(x)) #define __constant_le16_to_cpu(x) ((__force __u16)(__le16)(x))
#define __constant_cpu_to_be64(x) ___constant_swab64((x)) #define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x)))
#define __constant_be64_to_cpu(x) ___constant_swab64((x)) #define __constant_be64_to_cpu(x) ___constant_swab64((__force __u64)(__be64)(x))
#define __constant_cpu_to_be32(x) ___constant_swab32((x)) #define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x)))
#define __constant_be32_to_cpu(x) ___constant_swab32((x)) #define __constant_be32_to_cpu(x) ___constant_swab32((__force __u32)(__be32)(x))
#define __constant_cpu_to_be16(x) ___constant_swab16((x)) #define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x)))
#define __constant_be16_to_cpu(x) ___constant_swab16((x)) #define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be16)(x))
#define __cpu_to_le64(x) ((__u64)(x)) #define __cpu_to_le64(x) ((__force __le64)(__u64)(x))
#define __le64_to_cpu(x) ((__u64)(x)) #define __le64_to_cpu(x) ((__force __u64)(__le64)(x))
#define __cpu_to_le32(x) ((__u32)(x)) #define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
#define __le32_to_cpu(x) ((__u32)(x)) #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
#define __cpu_to_le16(x) ((__u16)(x)) #define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
#define __le16_to_cpu(x) ((__u16)(x)) #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
#define __cpu_to_be64(x) __swab64((x)) #define __cpu_to_be64(x) ((__force __be64)___swab64((x)))
#define __be64_to_cpu(x) __swab64((x)) #define __be64_to_cpu(x) ___swab64((__force __u64)(__be64)(x))
#define __cpu_to_be32(x) __swab32((x)) #define __cpu_to_be32(x) ((__force __be32)___swab32((x)))
#define __be32_to_cpu(x) __swab32((x)) #define __be32_to_cpu(x) ___swab32((__force __u32)(__be32)(x))
#define __cpu_to_be16(x) __swab16((x)) #define __cpu_to_be16(x) ((__force __be16)___swab16((x)))
#define __be16_to_cpu(x) __swab16((x)) #define __be16_to_cpu(x) ___swab16((__force __u16)(__be16)(x))
#define __cpu_to_le64p(x) (*(__u64*)(x))
#define __le64_to_cpup(x) (*(__u64*)(x)) static inline __le64 __cpu_to_le64p(const __u64 *p)
#define __cpu_to_le32p(x) (*(__u32*)(x)) {
#define __le32_to_cpup(x) (*(__u32*)(x)) return (__force __le64)*p;
#define __cpu_to_le16p(x) (*(__u16*)(x)) }
#define __le16_to_cpup(x) (*(__u16*)(x)) static inline __u64 __le64_to_cpup(const __le64 *p)
#define __cpu_to_be64p(x) __swab64p((x)) {
#define __be64_to_cpup(x) __swab64p((x)) return (__force __u64)*p;
#define __cpu_to_be32p(x) __swab32p((x)) }
#define __be32_to_cpup(x) __swab32p((x)) static inline __le32 __cpu_to_le32p(const __u32 *p)
#define __cpu_to_be16p(x) __swab16p((x)) {
#define __be16_to_cpup(x) __swab16p((x)) return (__force __le32)*p;
}
static inline __u32 __le32_to_cpup(const __le32 *p)
{
return (__force __u32)*p;
}
static inline __le16 __cpu_to_le16p(const __u16 *p)
{
return (__force __le16)*p;
}
static inline __u16 __le16_to_cpup(const __le16 *p)
{
return (__force __u16)*p;
}
static inline __be64 __cpu_to_be64p(const __u64 *p)
{
return (__force __be64)__swab64p(p);
}
static inline __u64 __be64_to_cpup(const __be64 *p)
{
return __swab64p((__u64 *)p);
}
static inline __be32 __cpu_to_be32p(const __u32 *p)
{
return (__force __be32)__swab32p(p);
}
static inline __u32 __be32_to_cpup(const __be32 *p)
{
return __swab32p((__u32 *)p);
}
static inline __be16 __cpu_to_be16p(const __u16 *p)
{
return (__force __be16)__swab16p(p);
}
static inline __u16 __be16_to_cpup(const __be16 *p)
{
return __swab16p((__u16 *)p);
}
#define __cpu_to_le64s(x) do {} while (0) #define __cpu_to_le64s(x) do {} while (0)
#define __le64_to_cpus(x) do {} while (0) #define __le64_to_cpus(x) do {} while (0)
#define __cpu_to_le32s(x) do {} while (0) #define __cpu_to_le32s(x) do {} while (0)
......
...@@ -140,6 +140,19 @@ typedef unsigned long sector_t; ...@@ -140,6 +140,19 @@ typedef unsigned long sector_t;
#define pgoff_t unsigned long #define pgoff_t unsigned long
#endif #endif
#ifdef __CHECKER__
#define __bitwise __attribute__((bitwise))
#else
#define __bitwise
#endif
typedef __u16 __bitwise __le16;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __le32;
typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __le64;
typedef __u64 __bitwise __be64;
#endif /* __KERNEL_STRICT_NAMES */ #endif /* __KERNEL_STRICT_NAMES */
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment