Reverted latest changes.
[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 <net/ndis.h>
23 #endif /* _MSC_VER */
24
25 #include <debug.h>
26
27
28 #ifndef _MSC_VER
29 /* FIXME: The following should be moved to ntddk.h */
30
31 /*
32 * ULONG MmGetMdlByteCount(
33 * IN PMDL Mdl)
34 */
35 #define MmGetMdlByteCount(Mdl) \
36 ((Mdl)->ByteCount)
37
38 #endif
39
40
41 /* Exported functions */
42 #ifdef _MSC_VER
43 #define EXPORT __declspec(dllexport)
44 #else
45 #define EXPORT STDCALL
46 #endif
47
48
49 #ifdef DBG
50
51 #define DEBUG_REFCHECK(Object) { \
52 if ((Object)->RefCount <= 0) { \
53 NDIS_DbgPrint(MIN_TRACE, ("Object at (0x%X) has invalid reference count (%d).\n", \
54 (Object), (Object)->RefCount)); \
55 } \
56 }
57
58 #else
59
60 #define DEBUG_REFCHECK(Object)
61
62 #endif
63
64
65 /*
66 * VOID ReferenceObject(
67 * PVOID Object)
68 */
69 #define ReferenceObject(Object) \
70 { \
71 DEBUG_REFCHECK(Object); \
72 NDIS_DbgPrint(DEBUG_REFCOUNT, ("Referencing object at (0x%X). RefCount (%d).\n", \
73 (Object), (Object)->RefCount)); \
74 \
75 InterlockedIncrement(&((Object)->RefCount)); \
76 }
77
78 /*
79 * VOID DereferenceObject(
80 * PVOID Object)
81 */
82 #define DereferenceObject(Object) \
83 { \
84 DEBUG_REFCHECK(Object); \
85 NDIS_DbgPrint(DEBUG_REFCOUNT, ("Dereferencing object at (0x%X). RefCount (%d).\n", \
86 (Object), (Object)->RefCount)); \
87 \
88 if (InterlockedDecrement(&((Object)->RefCount)) == 0) \
89 PoolFreeBuffer(Object); \
90 }
91
92
93 #define MIN(value1, value2) \
94 ((value1 < value2)? value1 : value2)
95
96 #define MAX(value1, value2) \
97 ((value1 > value2)? value1 : value2)
98
99 #endif /* __NDISSYS_H */
100
101 /* EOF */