jbd: Fix a race between checkpointing code and journal_get_write_access()
[linux/fpc-iii.git] / drivers / staging / vt6655 / tmacro.h
blob3d932a258dd196986fe3bd7e4e688cb4d861d9f5
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
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.
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.
19 * File: tmacro.h
21 * Purpose: define basic common types and macros
23 * Author: Tevin Chen
25 * Date: May 21, 1996
30 #ifndef __TMACRO_H__
31 #define __TMACRO_H__
34 #if !defined(__TTYPE_H__)
35 #include "ttype.h"
36 #endif
41 /****** Common helper macros ***********************************************/
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
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
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
64 #define LODWORD(q) ((q).u.dwLowDword)
65 #define HIDWORD(q) ((q).u.dwHighDword)
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
82 #if !defined(MAKELONG)
83 #define MAKELONG(low, high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
84 #endif
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
96 /* map to known network names */
98 #define ntohs(x) REVWORD(x)
99 #define ntohl(x) REVDWORD(x)
100 #define htons(x) REVWORD(x)
101 #define htonl(x) REVDWORD(x)
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
118 /****** Misc macros ********************************************************/
120 // get the field offset in the type(struct, class, ...)
121 #define OFFSET(type, field) ((int)(&((type NEAR*)1)->field)-1)
124 /* string equality shorthand */
125 #define STR_EQ(x, y) (strcmp(x, y) == 0)
126 #define STR_NE(x, y) (strcmp(x, y) != 0)
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]))
134 // null statement
135 #define NULL_FUNC()
138 /* Since not all compilers support structure assignment, the ASSIGN()
139 * macro is used. This controls how it's actually implemented.
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
150 #endif // __TMACRO_H__