Path: blob/master/ALFA-W1F1/RTL8814AU/include/byteorder/swab.h
1307 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/14#ifndef _LINUX_BYTEORDER_SWAB_H15#define _LINUX_BYTEORDER_SWAB_H1617#if !defined(CONFIG_PLATFORM_MSTAR)18#ifndef __u1619typedef unsigned short __u16;20#endif2122#ifndef __u3223typedef unsigned int __u32;24#endif2526#ifndef __u827typedef unsigned char __u8;28#endif2930#ifndef __u6431typedef unsigned long long __u64;32#endif333435__inline static __u16 ___swab16(__u16 x)36{37__u16 __x = x;38return39(__u16)(40(((__u16)(__x)&(__u16)0x00ffU) << 8) |41(((__u16)(__x)&(__u16)0xff00U) >> 8));4243}4445__inline static __u32 ___swab32(__u32 x)46{47__u32 __x = (x);48return (__u32)(49(((__u32)(__x)&(__u32)0x000000ffUL) << 24) |50(((__u32)(__x)&(__u32)0x0000ff00UL) << 8) |51(((__u32)(__x)&(__u32)0x00ff0000UL) >> 8) |52(((__u32)(__x)&(__u32)0xff000000UL) >> 24));53}5455__inline static __u64 ___swab64(__u64 x)56{57__u64 __x = (x);5859return60(__u64)(\61(__u64)(((__u64)(__x)&(__u64)0x00000000000000ffULL) << 56) | \62(__u64)(((__u64)(__x)&(__u64)0x000000000000ff00ULL) << 40) | \63(__u64)(((__u64)(__x)&(__u64)0x0000000000ff0000ULL) << 24) | \64(__u64)(((__u64)(__x)&(__u64)0x00000000ff000000ULL) << 8) | \65(__u64)(((__u64)(__x)&(__u64)0x000000ff00000000ULL) >> 8) | \66(__u64)(((__u64)(__x)&(__u64)0x0000ff0000000000ULL) >> 24) | \67(__u64)(((__u64)(__x)&(__u64)0x00ff000000000000ULL) >> 40) | \68(__u64)(((__u64)(__x)&(__u64)0xff00000000000000ULL) >> 56));69\70}71#endif /* CONFIG_PLATFORM_MSTAR */7273#ifndef __arch__swab1674__inline static __u16 __arch__swab16(__u16 x)75{76return ___swab16(x);77}7879#endif8081#ifndef __arch__swab3282__inline static __u32 __arch__swab32(__u32 x)83{84__u32 __tmp = (x) ;85return ___swab32(__tmp);86}87#endif8889#ifndef __arch__swab649091__inline static __u64 __arch__swab64(__u64 x)92{93__u64 __tmp = (x) ;94return ___swab64(__tmp);95}969798#endif99100#ifndef __swab16101#define __swab16(x) __fswab16(x)102#define __swab32(x) __fswab32(x)103#define __swab64(x) __fswab64(x)104#endif /* __swab16 */105106#ifdef PLATFORM_FREEBSD107__inline static __u16 __fswab16(__u16 x)108#else109__inline static const __u16 __fswab16(__u16 x)110#endif /* PLATFORM_FREEBSD */111{112return __arch__swab16(x);113}114#ifdef PLATFORM_FREEBSD115__inline static __u32 __fswab32(__u32 x)116#else117__inline static const __u32 __fswab32(__u32 x)118#endif /* PLATFORM_FREEBSD */119{120return __arch__swab32(x);121}122123#if defined(PLATFORM_LINUX) || defined(PLATFORM_WINDOWS)124#define swab16 __swab16125#define swab32 __swab32126#define swab64 __swab64127#define swab16p __swab16p128#define swab32p __swab32p129#define swab64p __swab64p130#define swab16s __swab16s131#define swab32s __swab32s132#define swab64s __swab64s133#endif134135#endif /* _LINUX_BYTEORDER_SWAB_H */136137138