Debian Codegraph @

test/dapltest/mdep/windows/dapl_mdep_user.h

raw
1
2 /*
3 * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
4 *
5 * This Software is licensed under one of the following licenses:
6 *
7 * 1) under the terms of the "Common Public License 1.0" a copy of which is
8 * in the file LICENSE.txt in the root directory. The license is also
9 * available from the Open Source Initiative, see
10 * http://www.opensource.org/licenses/cpl.php.
11 *
12 * 2) under the terms of the "The BSD License" a copy of which is in the file
13 * LICENSE2.txt in the root directory. The license is also available from
14 * the Open Source Initiative, see
15 * http://www.opensource.org/licenses/bsd-license.php.
16 *
17 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
18 * copy of which is in the file LICENSE3.txt in the root directory. The
19 * license is also available from the Open Source Initiative, see
20 * http://www.opensource.org/licenses/gpl-license.php.
21 *
22 * Licensee has the right to choose one of the above licenses.
23 *
24 * Redistributions of source code must retain the above copyright
25 * notice and one of the license notices.
26 *
27 * Redistributions in binary form must reproduce both the above copyright
28 * notice, one of the license notices in the documentation
29 * and/or other materials provided with the distribution.
30 */
31
32 #ifndef __DAPL_MDEP_USER_H__
33 #define __DAPL_MDEP_USER_H__
34
35 /* include files */
36
37 #include <ctype.h>
38
39 #ifndef WIN32_LEAN_AND_MEAN
40 # define WIN32_LEAN_AND_MEAN
41 #endif
42
43 # include <windows.h>
44 # include <process.h>
45 # include <stdio.h>
46 # include <string.h>
47 # include <winsock2.h>
48 # include <ws2tcpip.h>
49
50 /* Default Device Name */
51 #define DT_MdepDeviceName "ibnic0v2"
52
53 /* Boolean */
54 typedef int bool;
55
56 #define true (1)
57 #define false (0)
58
59 #ifndef __BASE_FILE__
60 #define __BASE_FILE__ __FILE__
61 #endif
62
63 #ifndef _INLINE_
64 #define _INLINE_ __inline
65 #endif
66
67 /* Mdep function defines */
68
69 #define DT_Mdep_spew(N, _X_) \
70 do { \
71 if (DT_dapltest_debug >= (N)) \
72 { \
73 DT_Mdep_printf _X_; \
74 } \
75 } while (0)
76
77 #define DT_Mdep_debug(_X_) DT_Mdep_spew(1, _X_)
78
79 #define DT_Mdep_printf printf
80 #define DT_Mdep_flush() fflush(NULL)
81
82 /*
83 * Release processor to reschedule
84 */
85 #define DT_Mdep_yield() Sleep(0)
86
87 /*
88 * Locks
89 */
90
91 typedef HANDLE DT_Mdep_LockType;
92 /* Wait object used for inter thread communication */
93
94 typedef HANDLE DT_WAIT_OBJECT;
95
96 /*
97 * Thread types
98 */
99 typedef HANDLE DT_Mdep_ThreadHandleType;
100 typedef void (*DT_Mdep_ThreadFunction) (void *param);
101 typedef void DT_Mdep_Thread_Start_Routine_Return_Type;
102
103 #define DT_MDEP_DEFAULT_STACK_SIZE 65536
104
105 typedef struct
106 {
107 void (*function) (void *);
108 void *param;
109 DT_Mdep_ThreadHandleType thread_handle;
110 unsigned int stacksize;
111 } Thread;
112
113 /*
114 * System information
115 *
116 */
117
118 typedef struct
119 {
120 unsigned long int system;
121 unsigned long int user;
122 unsigned long int idle;
123 } DT_CpuStat;
124
125 /*
126 * Timing
127 */
128 #if defined(_WIN64) && !defined(ReadTimeStampCounter)
129
130 static _INLINE_ _ReadTimeStampCounter(void)
131 {
132 LARGE_INTEGER val;
133 QueryPerformanceCounter( &val );
134 return val.QuadPart;
135 }
136 #define ReadTimeStampCounter _ReadTimeStampCounter
137 #endif
138
139 typedef unsigned __int64 DT_Mdep_TimeStamp;
140
141 static _INLINE_ DT_Mdep_TimeStamp
142 DT_Mdep_GetTimeStamp ( void )
143 {
144 #if !defined (_WIN64) && !defined (IA64)
145 _asm rdtsc
146 #else
147
148 #ifndef ReadTimeStampCounter
149
150 #define ReadTimeStampCounter() __rdtsc()
151
152 DWORD64
153 __rdtsc (VOID);
154
155 #endif
156
157 return (DT_Mdep_TimeStamp) ReadTimeStampCounter();
158
159 #endif //endif !_WIN64, and !IA64
160 }
161
162 /*
163 * Define types for Window compatibility
164 */
165
166 typedef __int64 int64_t;
167 typedef unsigned __int64 uint64_t;
168 typedef __int32 int32_t;
169 typedef unsigned __int32 uint32_t;
170
171
172 #define bzero(x, y) memset(x, 0, y)
173
174 /*
175 * Define long format types to be used in *printf format strings. We
176 * use the C string constant concatenation ability to define 64 bit
177 * formats, which unfortunatly are non standard in the C compiler
178 * world. E.g. %llx for gcc, %I64x for Windows
179 */
180 #define F64d "%I64d"
181 #define F64u "%I64u"
182 #define F64x "%I64x"
183 #define F64X "%I64X"
184
185 /*
186 * Define notion of a LONG LONG 0
187 */
188 #define LZERO 0UL
189
190 #endif /* __DAPL_MDEP_USER_H__ */