Colin Cross | 07a5832 | 2022-02-08 19:45:27 -0800 | [diff] [blame] | 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/bitsperlong.h> |
| 24 | #include <asm/swab.h> |
| 25 | #define ___constant_swab16(x) ((__u16) ((((__u16) (x) & (__u16) 0x00ffU) << 8) | (((__u16) (x) & (__u16) 0xff00U) >> 8))) |
| 26 | #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))) |
| 27 | #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))) |
| 28 | #define ___constant_swahw32(x) ((__u32) ((((__u32) (x) & (__u32) 0x0000ffffUL) << 16) | (((__u32) (x) & (__u32) 0xffff0000UL) >> 16))) |
| 29 | #define ___constant_swahb32(x) ((__u32) ((((__u32) (x) & (__u32) 0x00ff00ffUL) << 8) | (((__u32) (x) & (__u32) 0xff00ff00UL) >> 8))) |
| 30 | #ifdef __arch_swab16 |
| 31 | #else |
| 32 | #endif |
| 33 | #ifdef __arch_swab32 |
| 34 | #else |
| 35 | #endif |
| 36 | #ifdef __arch_swab64 |
| 37 | #elif defined(__SWAB_64_THRU_32__) |
| 38 | #else |
| 39 | #endif |
| 40 | static inline __attribute__((__const__)) __u32 __fswahw32(__u32 val) { |
| 41 | #ifdef __arch_swahw32 |
| 42 | return __arch_swahw32(val); |
| 43 | #else |
| 44 | return ___constant_swahw32(val); |
| 45 | #endif |
| 46 | } |
| 47 | static inline __attribute__((__const__)) __u32 __fswahb32(__u32 val) { |
| 48 | #ifdef __arch_swahb32 |
| 49 | return __arch_swahb32(val); |
| 50 | #else |
| 51 | return ___constant_swahb32(val); |
| 52 | #endif |
| 53 | } |
| 54 | #define __swab16(x) (__u16) __builtin_bswap16((__u16) (x)) |
| 55 | #define __swab32(x) (__u32) __builtin_bswap32((__u32) (x)) |
| 56 | #define __swab64(x) (__u64) __builtin_bswap64((__u64) (x)) |
| 57 | #if __BITS_PER_LONG == 64 |
| 58 | #else |
| 59 | #endif |
| 60 | #define __swahw32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahw32(x) : __fswahw32(x)) |
| 61 | #define __swahb32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahb32(x) : __fswahb32(x)) |
| 62 | static __always_inline __u16 __swab16p(const __u16 * p) { |
| 63 | #ifdef __arch_swab16p |
| 64 | return __arch_swab16p(p); |
| 65 | #else |
| 66 | return __swab16(* p); |
| 67 | #endif |
| 68 | } |
| 69 | static __always_inline __u32 __swab32p(const __u32 * p) { |
| 70 | #ifdef __arch_swab32p |
| 71 | return __arch_swab32p(p); |
| 72 | #else |
| 73 | return __swab32(* p); |
| 74 | #endif |
| 75 | } |
| 76 | static __always_inline __u64 __swab64p(const __u64 * p) { |
| 77 | #ifdef __arch_swab64p |
| 78 | return __arch_swab64p(p); |
| 79 | #else |
| 80 | return __swab64(* p); |
| 81 | #endif |
| 82 | } |
| 83 | static inline __u32 __swahw32p(const __u32 * p) { |
| 84 | #ifdef __arch_swahw32p |
| 85 | return __arch_swahw32p(p); |
| 86 | #else |
| 87 | return __swahw32(* p); |
| 88 | #endif |
| 89 | } |
| 90 | static inline __u32 __swahb32p(const __u32 * p) { |
| 91 | #ifdef __arch_swahb32p |
| 92 | return __arch_swahb32p(p); |
| 93 | #else |
| 94 | return __swahb32(* p); |
| 95 | #endif |
| 96 | } |
| 97 | static inline void __swab16s(__u16 * p) { |
| 98 | #ifdef __arch_swab16s |
| 99 | __arch_swab16s(p); |
| 100 | #else |
| 101 | * p = __swab16p(p); |
| 102 | #endif |
| 103 | } |
| 104 | static __always_inline void __swab32s(__u32 * p) { |
| 105 | #ifdef __arch_swab32s |
| 106 | __arch_swab32s(p); |
| 107 | #else |
| 108 | * p = __swab32p(p); |
| 109 | #endif |
| 110 | } |
| 111 | static __always_inline void __swab64s(__u64 * p) { |
| 112 | #ifdef __arch_swab64s |
| 113 | __arch_swab64s(p); |
| 114 | #else |
| 115 | * p = __swab64p(p); |
| 116 | #endif |
| 117 | } |
| 118 | static inline void __swahw32s(__u32 * p) { |
| 119 | #ifdef __arch_swahw32s |
| 120 | __arch_swahw32s(p); |
| 121 | #else |
| 122 | * p = __swahw32p(p); |
| 123 | #endif |
| 124 | } |
| 125 | static inline void __swahb32s(__u32 * p) { |
| 126 | #ifdef __arch_swahb32s |
| 127 | __arch_swahb32s(p); |
| 128 | #else |
| 129 | * p = __swahb32p(p); |
| 130 | #endif |
| 131 | } |
| 132 | #endif |