perf stat: Fix command option / manpage
[linux-2.6] / drivers / staging / vt6655 / tmacro.h
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * File: tmacro.h
20  *
21  * Purpose: define basic common types and macros
22  *
23  * Author: Tevin Chen
24  *
25  * Date: May 21, 1996
26  *
27  */
28
29
30 #ifndef __TMACRO_H__
31 #define __TMACRO_H__
32
33
34 #if !defined(__TTYPE_H__)
35 #include "ttype.h"
36 #endif
37
38
39
40
41 /****** Common helper macros ***********************************************/
42
43 #if !defined(LONIBBLE)
44 #define LONIBBLE(b)         ((BYTE)(b) & 0x0F)
45 #endif
46 #if !defined(HINIBBLE)
47 #define HINIBBLE(b)         ((BYTE)(((WORD)(b) >> 4) & 0x0F))
48 #endif
49
50 #if !defined(LOBYTE)
51 #define LOBYTE(w)           ((BYTE)(w))
52 #endif
53 #if !defined(HIBYTE)
54 #define HIBYTE(w)           ((BYTE)(((WORD)(w) >> 8) & 0xFF))
55 #endif
56
57 #if !defined(LOWORD)
58 #define LOWORD(d)           ((WORD)(d))
59 #endif
60 #if !defined(HIWORD)
61 #define HIWORD(d)           ((WORD)((((DWORD)(d)) >> 16) & 0xFFFF))
62 #endif
63
64 #define LODWORD(q)          ((q).u.dwLowDword)
65 #define HIDWORD(q)          ((q).u.dwHighDword)
66
67
68
69 #if !defined(MAKEBYTE)
70 #define MAKEBYTE(ln, hn)    ((BYTE)(((BYTE)(ln) & 0x0F) | ((BYTE)(hn) << 4)))
71 #endif
72 #if !defined(MAKEWORD)
73 #define MAKEWORD(lb, hb)    ((WORD)(((BYTE)(lb)) | (((WORD)((BYTE)(hb))) << 8)))
74 #endif
75 #if !defined(MAKEDWORD)
76 #define MAKEDWORD(lw, hw)   ((DWORD)(((WORD)(lw)) | (((DWORD)((WORD)(hw))) << 16)))
77 #endif
78 #if !defined(MAKEQWORD)
79 #define MAKEQWORD(ld, hd, pq) {pq->u.dwLowDword = ld; pq->u.dwHighDword = hd;}
80 #endif
81
82 #if !defined(MAKELONG)
83 #define MAKELONG(low, high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
84 #endif
85
86
87
88 // Bytes Reverse: big endian to little endian convert
89 #if !defined(REVWORD)
90 #define REVWORD(w) ((WORD)( ((WORD)(w) >> 8) | ((WORD)(w) << 8) ))
91 #endif
92 #if !defined(REVDWORD)
93 #define REVDWORD(d) (MAKEDWORD(MAKEWORD(HIBYTE(HIWORD(d)),LOBYTE(HIWORD(d))),MAKEWORD(HIBYTE(LOWORD(d)),LOBYTE(LOWORD(d)))))
94 #endif
95
96 /* map to known network names */
97 /*
98 #define ntohs(x)        REVWORD(x)
99 #define ntohl(x)        REVDWORD(x)
100 #define htons(x)        REVWORD(x)
101 #define htonl(x)        REVDWORD(x)
102 */
103
104
105 /*
106 #ifndef NOMINMAX
107 #ifndef max
108 #define max(a,b)            (((a) > (b)) ? (a) : (b))
109 #endif
110 #ifndef min
111 #define min(a,b)            (((a) < (b)) ? (a) : (b))
112 #endif
113 #endif // NOMINMAX
114 */
115
116
117
118 /****** Misc macros ********************************************************/
119
120 // get the field offset in the type(struct, class, ...)
121 #define OFFSET(type, field) ((int)(&((type NEAR*)1)->field)-1)
122
123
124 /* string equality shorthand */
125 #define STR_EQ(x, y)        (strcmp(x, y) == 0)
126 #define STR_NE(x, y)        (strcmp(x, y) != 0)
127
128
129 // calculate element # of array
130 #define ELEMENT_NUM(array)  (sizeof(array) / sizeof(array[0]))
131 //#define ARRAY_SIZE(a)       (sizeof(a) / sizeof(a[0]))
132
133
134 // null statement
135 #define NULL_FUNC()
136
137
138 /* Since not all compilers support structure assignment, the ASSIGN()
139  * macro is used. This controls how it's actually implemented.
140  */
141 #ifdef  NOSTRUCTASSIGN  /* Version for old compilers that don't support it */
142 #define ASSIGN(a,b)     memcpy((char *)&(a),(char *)&(b),sizeof(b);
143 #else                   /* Version for compilers that do */
144 #define ASSIGN(a,b)     ((a) = (b))
145 #endif
146
147
148
149
150 #endif // __TMACRO_H__
151
152