]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/linux-26-headers/include/linux/swab.h
update
[l4.git] / l4 / pkg / linux-26-headers / include / linux / swab.h
index 270d5c208a899aaeee19148a8a39109d59e384a8..75f54d4175d3b492ef387a4a9301408884b2cca1 100644 (file)
@@ -2,24 +2,24 @@
 #define _LINUX_SWAB_H
 
 #include <linux/types.h>
-#include <linux/compiler.h>
-#include <asm/byteorder.h>
+
+#include <asm/swab.h>
 
 /*
  * casts are necessary for constants, because we never know how for sure
  * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way.
  */
-#define __const_swab16(x) ((__u16)(                            \
+#define ___constant_swab16(x) ((__u16)(                                \
        (((__u16)(x) & (__u16)0x00ffU) << 8) |                  \
        (((__u16)(x) & (__u16)0xff00U) >> 8)))
 
-#define __const_swab32(x) ((__u32)(                            \
+#define ___constant_swab32(x) ((__u32)(                                \
        (((__u32)(x) & (__u32)0x000000ffUL) << 24) |            \
        (((__u32)(x) & (__u32)0x0000ff00UL) <<  8) |            \
        (((__u32)(x) & (__u32)0x00ff0000UL) >>  8) |            \
        (((__u32)(x) & (__u32)0xff000000UL) >> 24)))
 
-#define __const_swab64(x) ((__u64)(                            \
+#define ___constant_swab64(x) ((__u64)(                                \
        (((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) |   \
        (((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) |   \
        (((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) |   \
        (((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) |   \
        (((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56)))
 
-#define __const_swahw32(x) ((__u32)(                           \
+#define ___constant_swahw32(x) ((__u32)(                       \
        (((__u32)(x) & (__u32)0x0000ffffUL) << 16) |            \
        (((__u32)(x) & (__u32)0xffff0000UL) >> 16)))
 
-#define __const_swahb32(x) ((__u32)(                           \
+#define ___constant_swahb32(x) ((__u32)(                       \
        (((__u32)(x) & (__u32)0x00ff00ffUL) << 8) |             \
        (((__u32)(x) & (__u32)0xff00ff00UL) >> 8)))
 
  * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
  */
 
-static inline __attribute_const__ __u16 ___swab16(__u16 val)
+static __inline__ __u16 __fswab16(__u16 val)
 {
-#ifdef __arch_swab16
+#ifdef __HAVE_BUILTIN_BSWAP16__
+       return __builtin_bswap16(val);
+#elif defined (__arch_swab16)
        return __arch_swab16(val);
-#elif defined(__arch_swab16p)
-       return __arch_swab16p(&val);
 #else
-       return __const_swab16(val);
+       return ___constant_swab16(val);
 #endif
 }
 
-static inline __attribute_const__ __u32 ___swab32(__u32 val)
+static __inline__ __u32 __fswab32(__u32 val)
 {
-#ifdef __arch_swab32
+#ifdef __HAVE_BUILTIN_BSWAP32__
+       return __builtin_bswap32(val);
+#elif defined(__arch_swab32)
        return __arch_swab32(val);
-#elif defined(__arch_swab32p)
-       return __arch_swab32p(&val);
 #else
-       return __const_swab32(val);
+       return ___constant_swab32(val);
 #endif
 }
 
-static inline __attribute_const__ __u64 ___swab64(__u64 val)
+static __inline__ __u64 __fswab64(__u64 val)
 {
-#ifdef __arch_swab64
+#ifdef __HAVE_BUILTIN_BSWAP64__
+       return __builtin_bswap64(val);
+#elif defined (__arch_swab64)
        return __arch_swab64(val);
-#elif defined(__arch_swab64p)
-       return __arch_swab64p(&val);
 #elif defined(__SWAB_64_THRU_32__)
        __u32 h = val >> 32;
        __u32 l = val & ((1ULL << 32) - 1);
-       return (((__u64)___swab32(l)) << 32) | ((__u64)(___swab32(h)));
+       return (((__u64)__fswab32(l)) << 32) | ((__u64)(__fswab32(h)));
 #else
-       return __const_swab64(val);
+       return ___constant_swab64(val);
 #endif
 }
 
-static inline __attribute_const__ __u32 ___swahw32(__u32 val)
+static __inline__ __u32 __fswahw32(__u32 val)
 {
 #ifdef __arch_swahw32
        return __arch_swahw32(val);
-#elif defined(__arch_swahw32p)
-       return __arch_swahw32p(&val);
 #else
-       return __const_swahw32(val);
+       return ___constant_swahw32(val);
 #endif
 }
 
-static inline __attribute_const__ __u32 ___swahb32(__u32 val)
+static __inline__ __u32 __fswahb32(__u32 val)
 {
 #ifdef __arch_swahb32
        return __arch_swahb32(val);
-#elif defined(__arch_swahb32p)
-       return __arch_swahb32p(&val);
 #else
-       return __const_swahb32(val);
+       return ___constant_swahb32(val);
 #endif
 }
 
@@ -108,8 +104,8 @@ static inline __attribute_const__ __u32 ___swahb32(__u32 val)
  */
 #define __swab16(x)                            \
        (__builtin_constant_p((__u16)(x)) ?     \
-       __const_swab16((x)) :                   \
-       ___swab16((x)))
+       ___constant_swab16(x) :                 \
+       __fswab16(x))
 
 /**
  * __swab32 - return a byteswapped 32-bit value
@@ -117,8 +113,8 @@ static inline __attribute_const__ __u32 ___swahb32(__u32 val)
  */
 #define __swab32(x)                            \
        (__builtin_constant_p((__u32)(x)) ?     \
-       __const_swab32((x)) :                   \
-       ___swab32((x)))
+       ___constant_swab32(x) :                 \
+       __fswab32(x))
 
 /**
  * __swab64 - return a byteswapped 64-bit value
@@ -126,8 +122,8 @@ static inline __attribute_const__ __u32 ___swahb32(__u32 val)
  */
 #define __swab64(x)                            \
        (__builtin_constant_p((__u64)(x)) ?     \
-       __const_swab64((x)) :                   \
-       ___swab64((x)))
+       ___constant_swab64(x) :                 \
+       __fswab64(x))
 
 /**
  * __swahw32 - return a word-swapped 32-bit value
@@ -137,8 +133,8 @@ static inline __attribute_const__ __u32 ___swahb32(__u32 val)
  */
 #define __swahw32(x)                           \
        (__builtin_constant_p((__u32)(x)) ?     \
-       __const_swahw32((x)) :                  \
-       ___swahw32((x)))
+       ___constant_swahw32(x) :                \
+       __fswahw32(x))
 
 /**
  * __swahb32 - return a high and low byte-swapped 32-bit value
@@ -148,14 +144,14 @@ static inline __attribute_const__ __u32 ___swahb32(__u32 val)
  */
 #define __swahb32(x)                           \
        (__builtin_constant_p((__u32)(x)) ?     \
-       __const_swahb32((x)) :                  \
-       ___swahb32((x)))
+       ___constant_swahb32(x) :                \
+       __fswahb32(x))
 
 /**
  * __swab16p - return a byteswapped 16-bit value from a pointer
  * @p: pointer to a naturally-aligned 16-bit value
  */
-static inline __u16 __swab16p(const __u16 *p)
+static __inline__ __u16 __swab16p(const __u16 *p)
 {
 #ifdef __arch_swab16p
        return __arch_swab16p(p);
@@ -168,7 +164,7 @@ static inline __u16 __swab16p(const __u16 *p)
  * __swab32p - return a byteswapped 32-bit value from a pointer
  * @p: pointer to a naturally-aligned 32-bit value
  */
-static inline __u32 __swab32p(const __u32 *p)
+static __inline__ __u32 __swab32p(const __u32 *p)
 {
 #ifdef __arch_swab32p
        return __arch_swab32p(p);
@@ -181,7 +177,7 @@ static inline __u32 __swab32p(const __u32 *p)
  * __swab64p - return a byteswapped 64-bit value from a pointer
  * @p: pointer to a naturally-aligned 64-bit value
  */
-static inline __u64 __swab64p(const __u64 *p)
+static __inline__ __u64 __swab64p(const __u64 *p)
 {
 #ifdef __arch_swab64p
        return __arch_swab64p(p);
@@ -196,7 +192,7 @@ static inline __u64 __swab64p(const __u64 *p)
  *
  * See __swahw32() for details of wordswapping.
  */
-static inline __u32 __swahw32p(const __u32 *p)
+static __inline__ __u32 __swahw32p(const __u32 *p)
 {
 #ifdef __arch_swahw32p
        return __arch_swahw32p(p);
@@ -211,7 +207,7 @@ static inline __u32 __swahw32p(const __u32 *p)
  *
  * See __swahb32() for details of high/low byteswapping.
  */
-static inline __u32 __swahb32p(const __u32 *p)
+static __inline__ __u32 __swahb32p(const __u32 *p)
 {
 #ifdef __arch_swahb32p
        return __arch_swahb32p(p);
@@ -224,7 +220,7 @@ static inline __u32 __swahb32p(const __u32 *p)
  * __swab16s - byteswap a 16-bit value in-place
  * @p: pointer to a naturally-aligned 16-bit value
  */
-static inline void __swab16s(__u16 *p)
+static __inline__ void __swab16s(__u16 *p)
 {
 #ifdef __arch_swab16s
        __arch_swab16s(p);
@@ -236,7 +232,7 @@ static inline void __swab16s(__u16 *p)
  * __swab32s - byteswap a 32-bit value in-place
  * @p: pointer to a naturally-aligned 32-bit value
  */
-static inline void __swab32s(__u32 *p)
+static __inline__ void __swab32s(__u32 *p)
 {
 #ifdef __arch_swab32s
        __arch_swab32s(p);
@@ -249,7 +245,7 @@ static inline void __swab32s(__u32 *p)
  * __swab64s - byteswap a 64-bit value in-place
  * @p: pointer to a naturally-aligned 64-bit value
  */
-static inline void __swab64s(__u64 *p)
+static __inline__ void __swab64s(__u64 *p)
 {
 #ifdef __arch_swab64s
        __arch_swab64s(p);
@@ -264,7 +260,7 @@ static inline void __swab64s(__u64 *p)
  *
  * See __swahw32() for details of wordswapping
  */
-static inline void __swahw32s(__u32 *p)
+static __inline__ void __swahw32s(__u32 *p)
 {
 #ifdef __arch_swahw32s
        __arch_swahw32s(p);
@@ -279,7 +275,7 @@ static inline void __swahw32s(__u32 *p)
  *
  * See __swahb32() for details of high and low byte swapping
  */
-static inline void __swahb32s(__u32 *p)
+static __inline__ void __swahb32s(__u32 *p)
 {
 #ifdef __arch_swahb32s
        __arch_swahb32s(p);
@@ -288,22 +284,5 @@ static inline void __swahb32s(__u32 *p)
 #endif
 }
 
-#ifdef __KERNEL__
-# define swab16 __swab16
-# define swab32 __swab32
-# define swab64 __swab64
-# define swahw32 __swahw32
-# define swahb32 __swahb32
-# define swab16p __swab16p
-# define swab32p __swab32p
-# define swab64p __swab64p
-# define swahw32p __swahw32p
-# define swahb32p __swahb32p
-# define swab16s __swab16s
-# define swab32s __swab32s
-# define swab64s __swab64s
-# define swahw32s __swahw32s
-# define swahb32s __swahb32s
-#endif /* __KERNEL__ */
 
 #endif /* _LINUX_SWAB_H */