linux/drivers/staging/rtl8712/swab.h
<<
>>
Prefs
   1/******************************************************************************
   2 *
   3 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
   4 *
   5 * This program is free software; you can redistribute it and/or modify it
   6 * under the terms of version 2 of the GNU General Public License as
   7 * published by the Free Software Foundation.
   8 *
   9 * This program is distributed in the hope that it will be useful, but WITHOUT
  10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12 * more details.
  13 *
  14 * You should have received a copy of the GNU General Public License along with
  15 * this program; if not, write to the Free Software Foundation, Inc.,
  16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17 *
  18 * Modifications for inclusion into the Linux staging tree are
  19 * Copyright(c) 2010 Larry Finger. All rights reserved.
  20 *
  21 * Contact information:
  22 * WLAN FAE <wlanfae@realtek.com>
  23 * Larry Finger <Larry.Finger@lwfinger.net>
  24 *
  25 ******************************************************************************/
  26#ifndef _LINUX_BYTEORDER_SWAB_H
  27#define _LINUX_BYTEORDER_SWAB_H
  28
  29#ifndef __u16
  30 #define __u16 unsigned short
  31#endif
  32
  33#ifndef __u32
  34 #define __u32 unsigned int
  35#endif
  36
  37#ifndef __u8
  38 #define __u8 unsigned char
  39#endif
  40
  41#ifndef __u64
  42 #define __u64 unsigned long long
  43#endif
  44
  45
  46static inline __u16  ___swab16(__u16 x)
  47{
  48        __u16 __x = x;
  49        return (__u16)(
  50                (((__u16)(__x) & (__u16)0x00ffU) << 8) |
  51                (((__u16)(__x) & (__u16)0xff00U) >> 8));
  52
  53}
  54
  55static inline __u32  ___swab32(__u32 x)
  56{
  57        __u32 __x = (x);
  58        return (__u32)(
  59                (((__u32)(__x) & (__u32)0x000000ffUL) << 24) |
  60                (((__u32)(__x) & (__u32)0x0000ff00UL) <<  8) |
  61                (((__u32)(__x) & (__u32)0x00ff0000UL) >>  8) |
  62                (((__u32)(__x) & (__u32)0xff000000UL) >> 24));
  63}
  64
  65static inline __u64  ___swab64(__u64 x)
  66{
  67        __u64 __x = (x);
  68
  69        return (__u64)( \
  70                (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \
  71                (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \
  72                (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \
  73                (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) <<  8) | \
  74                (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >>  8) | \
  75                (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
  76                (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \
  77                (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56));
  78}
  79
  80#ifndef __arch__swab16
  81static inline __u16 __arch__swab16(__u16 x)
  82{
  83        return ___swab16(x);
  84}
  85
  86#endif
  87
  88#ifndef __arch__swab32
  89static inline __u32 __arch__swab32(__u32 x)
  90{
  91        __u32 __tmp = (x) ;
  92        return ___swab32(__tmp);
  93}
  94#endif
  95
  96#ifndef __arch__swab64
  97
  98static inline __u64 __arch__swab64(__u64 x)
  99{
 100        __u64 __tmp = (x) ;
 101        return ___swab64(__tmp);
 102}
 103
 104
 105#endif
 106
 107#define __swab16(x) __fswab16(x)
 108#define __swab32(x) __fswab32(x)
 109#define __swab64(x) __fswab64(x)
 110
 111static inline const __u16 __fswab16(__u16 x)
 112{
 113        return __arch__swab16(x);
 114}
 115static inline const __u32 __fswab32(__u32 x)
 116{
 117        return __arch__swab32(x);
 118}
 119
 120#define swab16 __swab16
 121#define swab32 __swab32
 122#define swab64 __swab64
 123#define swab16p __swab16p
 124#define swab32p __swab32p
 125#define swab64p __swab64p
 126#define swab16s __swab16s
 127#define swab32s __swab32s
 128#define swab64s __swab64s
 129
 130#endif /* _LINUX_BYTEORDER_SWAB_H */
 131
 132
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.