2004-08-16 Casper S. Hornstrup <chorns@users.sourceforge.net>
[reactos.git] / reactos / drivers / net / ndis / include / ndissys.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS NDIS library
4 * FILE: ndissys.h
5 * PURPOSE: NDIS library definitions
6 * NOTES: Spin lock acquire order:
7 * - Miniport list lock
8 * - Adapter list lock
9 */
10 #ifndef __NDISSYS_H
11 #define __NDISSYS_H
12
13 #define NDIS50 1 /* Use NDIS 5.0 structures by default */
14
15 #ifdef _MSC_VER
16 #include <basetsd.h>
17 #include <ntddk.h>
18 #include <windef.h>
19 #include <ndis.h>
20 #else /* _MSC_VER */
21 #include <ddk/ntddk.h>
22 #include <ddk/xfilter.h>
23 #include <net/ndis.h>
24 #endif /* _MSC_VER */
25
26 #include "miniport.h"
27 #include "protocol.h"
28
29 #include <debug.h>
30
31 /* Exported functions */
32 #ifdef _MSC_VER
33 #define EXPORT __declspec(dllexport)
34 #else
35 #define EXPORT STDCALL
36 #endif
37
38
39 #ifdef DBG
40
41 #define DEBUG_REFCHECK(Object) { \
42 if ((Object)->RefCount <= 0) { \
43 NDIS_DbgPrint(MIN_TRACE, ("Object at (0x%X) has invalid reference count (%d).\n", \
44 (Object), (Object)->RefCount)); \
45 } \
46 }
47
48 #else
49
50 #define DEBUG_REFCHECK(Object)
51
52 #endif
53
54
55 /*
56 * VOID ReferenceObject(
57 * PVOID Object)
58 */
59 #define ReferenceObject(Object) \
60 { \
61 DEBUG_REFCHECK(Object); \
62 NDIS_DbgPrint(DEBUG_REFCOUNT, ("Referencing object at (0x%X). RefCount (%d).\n", \
63 (Object), (Object)->RefCount)); \
64 \
65 InterlockedIncrement(&((Object)->RefCount)); \
66 }
67
68 /*
69 * VOID DereferenceObject(
70 * PVOID Object)
71 */
72 #define DereferenceObject(Object) \
73 { \
74 DEBUG_REFCHECK(Object); \
75 NDIS_DbgPrint(DEBUG_REFCOUNT, ("Dereferencing object at (0x%X). RefCount (%d).\n", \
76 (Object), (Object)->RefCount)); \
77 \
78 if (InterlockedDecrement(&((Object)->RefCount)) == 0) \
79 PoolFreeBuffer(Object); \
80 }
81
82
83 #define MIN(value1, value2) \
84 ((value1 < value2)? value1 : value2)
85
86 #define MAX(value1, value2) \
87 ((value1 > value2)? value1 : value2)
88
89 #endif /* __NDISSYS_H */
90
91 /* EOF */