swab.h revision ee1e0a34ae01aa01a207f00f0fe6cfb09852e44e
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/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
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/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
29#define ___constant_swahw32(x) ((__u32) ((((__u32) (x) & (__u32) 0x0000ffffUL) << 16) | (((__u32) (x) & (__u32) 0xffff0000UL) >> 16)))
30#define ___constant_swahb32(x) ((__u32) ((((__u32) (x) & (__u32) 0x00ff00ffUL) << 8) | (((__u32) (x) & (__u32) 0xff00ff00UL) >> 8)))
31#ifdef __arch_swab16
32#else
33/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
34#endif
35#ifdef __arch_swab32
36#else
37#endif
38/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
39#ifdef __arch_swab64
40#elif defined(__SWAB_64_THRU_32__)
41#else
42#endif
43/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
44static inline __attribute__((__const__)) __u32 __fswahw32(__u32 val) {
45#ifdef __arch_swahw32
46  return __arch_swahw32(val);
47#else
48/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
49  return ___constant_swahw32(val);
50#endif
51}
52static inline __attribute__((__const__)) __u32 __fswahb32(__u32 val) {
53/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
54#ifdef __arch_swahb32
55  return __arch_swahb32(val);
56#else
57  return ___constant_swahb32(val);
58/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
59#endif
60}
61#define __swab16(x) (__u16) __builtin_bswap16((__u16) (x))
62#define __swab32(x) (__u32) __builtin_bswap32((__u32) (x))
63/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
64#define __swab64(x) (__u64) __builtin_bswap64((__u64) (x))
65#define __swahw32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahw32(x) : __fswahw32(x))
66#define __swahb32(x) (__builtin_constant_p((__u32) (x)) ? ___constant_swahb32(x) : __fswahb32(x))
67static __always_inline __u16 __swab16p(const __u16 * p) {
68/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
69#ifdef __arch_swab16p
70  return __arch_swab16p(p);
71#else
72  return __swab16(* p);
73/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
74#endif
75}
76static __always_inline __u32 __swab32p(const __u32 * p) {
77#ifdef __arch_swab32p
78/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
79  return __arch_swab32p(p);
80#else
81  return __swab32(* p);
82#endif
83/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
84}
85static __always_inline __u64 __swab64p(const __u64 * p) {
86#ifdef __arch_swab64p
87  return __arch_swab64p(p);
88/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
89#else
90  return __swab64(* p);
91#endif
92}
93/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
94static inline __u32 __swahw32p(const __u32 * p) {
95#ifdef __arch_swahw32p
96  return __arch_swahw32p(p);
97#else
98/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
99  return __swahw32(* p);
100#endif
101}
102static inline __u32 __swahb32p(const __u32 * p) {
103/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
104#ifdef __arch_swahb32p
105  return __arch_swahb32p(p);
106#else
107  return __swahb32(* p);
108/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
109#endif
110}
111static inline void __swab16s(__u16 * p) {
112#ifdef __arch_swab16s
113/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
114  __arch_swab16s(p);
115#else
116  * p = __swab16p(p);
117#endif
118/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
119}
120static __always_inline void __swab32s(__u32 * p) {
121#ifdef __arch_swab32s
122  __arch_swab32s(p);
123/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
124#else
125  * p = __swab32p(p);
126#endif
127}
128/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
129static __always_inline void __swab64s(__u64 * p) {
130#ifdef __arch_swab64s
131  __arch_swab64s(p);
132#else
133/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
134  * p = __swab64p(p);
135#endif
136}
137static inline void __swahw32s(__u32 * p) {
138/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
139#ifdef __arch_swahw32s
140  __arch_swahw32s(p);
141#else
142  * p = __swahw32p(p);
143/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
144#endif
145}
146static inline void __swahb32s(__u32 * p) {
147#ifdef __arch_swahb32s
148/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
149  __arch_swahb32s(p);
150#else
151  * p = __swahb32p(p);
152#endif
153/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
154}
155#endif
156