/* * 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 ___constant_swab16(x) ((__u16)( \
(((__u16)(x) & (__u16)0x00ffU) << 8) | \
(((__u16)(x) & (__u16)0xff00U) >> 8)))
/* * Implement the following as inlines, but define the interface using * macros to allow constant folding when possible: * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
*/
/** * __swahw32 - return a word-swapped 32-bit value * @x: value to wordswap * * __swahw32(0x12340000) is 0x00001234
*/ #define __swahw32(x) \
(__builtin_constant_p((__u32)(x)) ? \
___constant_swahw32(x) : \
__fswahw32(x))
/** * __swahb32 - return a high and low byte-swapped 32-bit value * @x: value to byteswap * * __swahb32(0x12345678) is 0x34127856
*/ #define __swahb32(x) \
(__builtin_constant_p((__u32)(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 __always_inline __u16 __swab16p(const __u16 *p)
{ #ifdef __arch_swab16p return __arch_swab16p(p); #else return __swab16(*p); #endif
}
/** * __swab32p - return a byteswapped 32-bit value from a pointer * @p: pointer to a naturally-aligned 32-bit value
*/ static __always_inline __u32 __swab32p(const __u32 *p)
{ #ifdef __arch_swab32p return __arch_swab32p(p); #else return __swab32(*p); #endif
}
/** * __swab64p - return a byteswapped 64-bit value from a pointer * @p: pointer to a naturally-aligned 64-bit value
*/ static __always_inline __u64 __swab64p(const __u64 *p)
{ #ifdef __arch_swab64p return __arch_swab64p(p); #else return __swab64(*p); #endif
}
/** * __swahw32p - return a wordswapped 32-bit value from a pointer * @p: pointer to a naturally-aligned 32-bit value * * See __swahw32() for details of wordswapping.
*/ staticinline __u32 __swahw32p(const __u32 *p)
{ #ifdef __arch_swahw32p return __arch_swahw32p(p); #else return __swahw32(*p); #endif
}
/** * __swahb32p - return a high and low byteswapped 32-bit value from a pointer * @p: pointer to a naturally-aligned 32-bit value * * See __swahb32() for details of high/low byteswapping.
*/ staticinline __u32 __swahb32p(const __u32 *p)
{ #ifdef __arch_swahb32p return __arch_swahb32p(p); #else return __swahb32(*p); #endif
}
/** * __swab16s - byteswap a 16-bit value in-place * @p: pointer to a naturally-aligned 16-bit value
*/ staticinlinevoid __swab16s(__u16 *p)
{ #ifdef __arch_swab16s
__arch_swab16s(p); #else
*p = __swab16p(p); #endif
} /** * __swab32s - byteswap a 32-bit value in-place * @p: pointer to a naturally-aligned 32-bit value
*/ static __always_inline void __swab32s(__u32 *p)
{ #ifdef __arch_swab32s
__arch_swab32s(p); #else
*p = __swab32p(p); #endif
}
/** * __swab64s - byteswap a 64-bit value in-place * @p: pointer to a naturally-aligned 64-bit value
*/ static __always_inline void __swab64s(__u64 *p)
{ #ifdef __arch_swab64s
__arch_swab64s(p); #else
*p = __swab64p(p); #endif
}
/** * __swahw32s - wordswap a 32-bit value in-place * @p: pointer to a naturally-aligned 32-bit value * * See __swahw32() for details of wordswapping
*/ staticinlinevoid __swahw32s(__u32 *p)
{ #ifdef __arch_swahw32s
__arch_swahw32s(p); #else
*p = __swahw32p(p); #endif
}
/** * __swahb32s - high and low byteswap a 32-bit value in-place * @p: pointer to a naturally-aligned 32-bit value * * See __swahb32() for details of high and low byte swapping
*/ staticinlinevoid __swahb32s(__u32 *p)
{ #ifdef __arch_swahb32s
__arch_swahb32s(p); #else
*p = __swahb32p(p); #endif
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.