MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink / Module / rtmp_type.h
blob126ad04a134aab7730b348c64007770416bc445e
1 /*************************************************************************
2 * Ralink Tech Inc. *
3 * 4F, No. 2 Technology 5th Rd. *
4 * Science-based Industrial Park *
5 * Hsin-chu, Taiwan, R.O.C. *
6 * *
7 * (c) Copyright 2002, Ralink Technology, Inc. *
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, write to the *
21 * Free Software Foundation, Inc., *
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23 * *
24 *************************************************************************
26 Module Name:
27 rtmp_type.h
29 Abstract:
31 Revision History:
32 Who When What
33 -------- ---------- ----------------------------------------------
34 Name Date Modification logs
35 Paul Lin 1-2-2004
37 #ifndef __RTMP_TYPE_H__
38 #define __RTMP_TYPE_H__
40 // Put platform dependent declaration here
41 // For example, linux type definition
42 #ifdef Linux
44 typedef unsigned short UINT16;
45 typedef unsigned long UINT32;
46 typedef unsigned long long UINT64;
48 #endif
50 #ifdef Win32
52 #undef BIG_ENDIAN // Only little endian foe WIN32 system
54 typedef unsigned short UINT16;
55 typedef unsigned long UINT32;
56 typedef unsigned __int64 UINT64;
58 #endif
60 // Endian byte swapping codes
61 #ifdef BIG_ENDIAN
63 #define SWAP16(x) \
64 ((UINT16)( \
65 (((UINT16)(x) & (UINT16) 0x00ffU) << 8) | \
66 (((UINT16)(x) & (UINT16) 0xff00U) >> 8) ))
68 #define SWAP32(x) \
69 ((UINT32)( \
70 (((UINT32)(x) & (UINT32) 0x000000ffUL) << 24) | \
71 (((UINT32)(x) & (UINT32) 0x0000ff00UL) << 8) | \
72 (((UINT32)(x) & (UINT32) 0x00ff0000UL) >> 8) | \
73 (((UINT32)(x) & (UINT32) 0xff000000UL) >> 24) ))
75 #define SWAP64(x) \
76 ((UINT64)( \
77 (UINT64)(((UINT64)(x) & (UINT64) 0x00000000000000ffULL) << 56) | \
78 (UINT64)(((UINT64)(x) & (UINT64) 0x000000000000ff00ULL) << 40) | \
79 (UINT64)(((UINT64)(x) & (UINT64) 0x0000000000ff0000ULL) << 24) | \
80 (UINT64)(((UINT64)(x) & (UINT64) 0x00000000ff000000ULL) << 8) | \
81 (UINT64)(((UINT64)(x) & (UINT64) 0x000000ff00000000ULL) >> 8) | \
82 (UINT64)(((UINT64)(x) & (UINT64) 0x0000ff0000000000ULL) >> 24) | \
83 (UINT64)(((UINT64)(x) & (UINT64) 0x00ff000000000000ULL) >> 40) | \
84 (UINT64)(((UINT64)(x) & (UINT64) 0xff00000000000000ULL) >> 56) ))
85 #else
87 #define SWAP16(x)
88 #define SWAP32(x)
89 #define SWAP64(x)
91 #endif
93 #define PACKED __attribute__ ((packed))
95 #ifdef BIG_ENDIAN
97 #define cpu2le64(x) SWAP64((x))
98 #define le2cpu64(x) SWAP64((x))
99 #define cpu2le32(x) SWAP32((x))
100 #define le2cpu32(x) SWAP32((x))
101 #define cpu2le16(x) SWAP16((x))
102 #define le2cpu16(x) SWAP16((x))
103 #define cpu2be64(x) ((UINT64)(x))
104 #define be2cpu64(x) ((UINT64)(x))
105 #define cpu2be32(x) ((UINT32)(x))
106 #define be2cpu32(x) ((UINT32)(x))
107 #define cpu2be16(x) ((UINT16)(x))
108 #define be2cpu16(x) ((UINT16)(x))
110 #else // Little_Endian
112 #define cpu2le64(x) ((UINT64)(x))
113 #define le2cpu64(x) ((UINT64)(x))
114 #define cpu2le32(x) ((UINT32)(x))
115 #define le2cpu32(x) ((UINT32)(x))
116 #define cpu2le16(x) ((UINT16)(x))
117 #define le2cpu16(x) ((UINT16)(x))
118 #define cpu2be64(x) SWAP64((x))
119 #define be2cpu64(x) SWAP64((x))
120 #define cpu2be32(x) SWAP32((x))
121 #define be2cpu32(x) SWAP32((x))
122 #define cpu2be16(x) SWAP16((x))
123 #define be2cpu16(x) SWAP16((x))
125 #endif // BIG_ENDIAN
127 #endif // __RTMP_TYPE_H__