1 /**************************************************************************** 2 **************************************************************************** 3 *** 4 *** This header was automatically generated from a Linux kernel header 5 *** of the same name, to make information necessary for userspace to 6 *** call into the kernel available to libc. It contains only constants, 7 *** structures, and macros generated from the original header, and thus, 8 *** contains no copyrightable information. 9 *** 10 *** To edit the content of this header, modify the corresponding 11 *** source file (e.g. under external/kernel-headers/original/) then 12 *** run bionic/libc/kernel/tools/update_all.py 13 *** 14 *** Any manual change here will be lost the next time this script will 15 *** be run. You've been warned! 16 *** 17 **************************************************************************** 18 ****************************************************************************/ 19 #ifndef _UAPI_LINUX_SWAB_H 20 #define _UAPI_LINUX_SWAB_H 21 #include <linux/types.h> 22 #include <linux/compiler.h> 23 #include <asm/swab.h> 24 #define ___constant_swab16(x) ((__u16) ((((__u16) (x) & (__u16) 0x00ffU) << 8) | (((__u16) (x) & (__u16) 0xff00U) >> 8))) 25 #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))) 26 #define ___constant_swab64(x) ((__u64) ((((__u64) (x) & (__u64) 0x00000000000000ffULL) << 56) | (((__u64) (x) & (__u64) 0x000000000000ff00ULL) << 40) | (((__u64) (x) & (__u64) 0x0000000000ff0000ULL) << 24) | (((__u64) (x) & (__u64) 0x00000000ff000000ULL) << 8) | (((__u64) (x) & (__u64) 0x000000ff00000000ULL) >> 8) | (((__u64) (x) & (__u64) 0x0000ff0000000000ULL) >> 24) | (((__u64) (x) & (__u64) 0x00ff000000000000ULL) >> 40) | (((__u64) (x) & (__u64) 0xff00000000000000ULL) >> 56))) 27 #define ___constant_swahw32(x) ((__u32) ((((__u32) (x) & (__u32) 0x0000ffffUL) << 16) | (((__u32) (x) & (__u32) 0xffff0000UL) >> 16))) 28 #define ___constant_swahb32(x) ((__u32) ((((__u32) (x) & (__u32) 0x00ff00ffUL) << 8) | (((__u32) (x) & (__u32) 0xff00ff00UL) >> 8))) 29 #ifdef __arch_swab16 30 #else 31 #endif 32 #ifdef __arch_swab32 33 #else 34 #endif 35 #ifdef __arch_swab64 36 #elif defined(__SWAB_64_THRU_32__) 37 #else 38 #endif __fswahw32(__u32 val)39static inline __attribute__((__const__)) __u32 __fswahw32(__u32 val) { 40 #ifdef __arch_swahw32 41 return __arch_swahw32(val); 42 #else 43 return ___constant_swahw32(val); 44 #endif 45 } __fswahb32(__u32 val)46static inline __attribute__((__const__)) __u32 __fswahb32(__u32 val) { 47 #ifdef __arch_swahb32 48 return __arch_swahb32(val); 49 #else 50 return ___constant_swahb32(val); 51 #endif 52 } 53 #define __swab16(x) (__u16) __builtin_bswap16((__u16) (x)) 54 #define __swab32(x) (__u32) __builtin_bswap32((__u32) (x)) 55 #define __swab64(x) (__u64) __builtin_bswap64((__u64) (x)) 56 #define __swahw32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahw32(x) : __fswahw32(x)) 57 #define __swahb32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahb32(x) : __fswahb32(x)) __swab16p(const __u16 * p)58static __always_inline __u16 __swab16p(const __u16 * p) { 59 #ifdef __arch_swab16p 60 return __arch_swab16p(p); 61 #else 62 return __swab16(* p); 63 #endif 64 } __swab32p(const __u32 * p)65static __always_inline __u32 __swab32p(const __u32 * p) { 66 #ifdef __arch_swab32p 67 return __arch_swab32p(p); 68 #else 69 return __swab32(* p); 70 #endif 71 } __swab64p(const __u64 * p)72static __always_inline __u64 __swab64p(const __u64 * p) { 73 #ifdef __arch_swab64p 74 return __arch_swab64p(p); 75 #else 76 return __swab64(* p); 77 #endif 78 } __swahw32p(const __u32 * p)79static inline __u32 __swahw32p(const __u32 * p) { 80 #ifdef __arch_swahw32p 81 return __arch_swahw32p(p); 82 #else 83 return __swahw32(* p); 84 #endif 85 } __swahb32p(const __u32 * p)86static inline __u32 __swahb32p(const __u32 * p) { 87 #ifdef __arch_swahb32p 88 return __arch_swahb32p(p); 89 #else 90 return __swahb32(* p); 91 #endif 92 } __swab16s(__u16 * p)93static inline void __swab16s(__u16 * p) { 94 #ifdef __arch_swab16s 95 __arch_swab16s(p); 96 #else 97 * p = __swab16p(p); 98 #endif 99 } __swab32s(__u32 * p)100static __always_inline void __swab32s(__u32 * p) { 101 #ifdef __arch_swab32s 102 __arch_swab32s(p); 103 #else 104 * p = __swab32p(p); 105 #endif 106 } __swab64s(__u64 * p)107static __always_inline void __swab64s(__u64 * p) { 108 #ifdef __arch_swab64s 109 __arch_swab64s(p); 110 #else 111 * p = __swab64p(p); 112 #endif 113 } __swahw32s(__u32 * p)114static inline void __swahw32s(__u32 * p) { 115 #ifdef __arch_swahw32s 116 __arch_swahw32s(p); 117 #else 118 * p = __swahw32p(p); 119 #endif 120 } __swahb32s(__u32 * p)121static inline void __swahb32s(__u32 * p) { 122 #ifdef __arch_swahb32s 123 __arch_swahb32s(p); 124 #else 125 * p = __swahb32p(p); 126 #endif 127 } 128 #endif 129