[ovs-dev] [PATCH 26/40] datapath-windows: Use annotations instead for macros
Alin Serdean
aserdean at cloudbasesolutions.com
Fri Jul 14 04:40:56 UTC 2017
We can safely use function annotations to instead of defining out own macros.
Nuke implementation of `OVS_VERIFY_IRQL_LE` and OVS_VERIFY_IRQL (unused).
Add function annotations to the functions which were using OVS_VERIFY_IRQL_LE`.
Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
---
datapath-windows/ovsext/Debug.h | 18 ------------------
datapath-windows/ovsext/Util.c | 7 +++----
datapath-windows/ovsext/Util.h | 6 ++++++
3 files changed, 9 insertions(+), 22 deletions(-)
diff --git a/datapath-windows/ovsext/Debug.h b/datapath-windows/ovsext/Debug.h
index 6de1812..c17f0e9 100644
--- a/datapath-windows/ovsext/Debug.h
+++ b/datapath-windows/ovsext/Debug.h
@@ -74,22 +74,4 @@ VOID OvsLog(UINT32 level, UINT32 flag, CHAR *funcName,
#define OVS_LOG_WARN(_format, ...) \
OvsLog(OVS_DBG_WARN, OVS_DBG_MOD, __FUNCTION__, __LINE__, _format, __VA_ARGS__)
-#if DBG
-#define OVS_VERIFY_IRQL(_x) \
- if (KeGetCurrentIrql() != (KIRQL)_x) { \
- OVS_LOG_WARN("expected IRQL %u, actual IRQL: %u", \
- _x, KeGetCurrentIrql()); \
- }
-
-#define OVS_VERIFY_IRQL_LE(_x) \
- if (KeGetCurrentIrql() > (KIRQL)_x) { \
- OVS_LOG_WARN("expected IRQL <= %u, actual IRQL: %u", \
- _x, KeGetCurrentIrql()); \
- }
-
-#else
-#define OVS_VERIFY_IRQL(_x)
-#define OVS_VERIFY_IRQL_LE(_x)
-#endif
-
#endif /* __DEBUG_H_ */
diff --git a/datapath-windows/ovsext/Util.c b/datapath-windows/ovsext/Util.c
index 3c9b052..abd38c2 100644
--- a/datapath-windows/ovsext/Util.c
+++ b/datapath-windows/ovsext/Util.c
@@ -25,10 +25,10 @@
extern NDIS_HANDLE gOvsExtDriverHandle;
+_Use_decl_annotations_
VOID*
OvsAllocateMemoryWithTag(size_t size, ULONG tag)
{
- OVS_VERIFY_IRQL_LE(DISPATCH_LEVEL);
return NdisAllocateMemoryWithTagPriority(gOvsExtDriverHandle,
(UINT32)size, tag, NormalPoolPriority);
}
@@ -40,19 +40,18 @@ OvsFreeMemoryWithTag(VOID *ptr, ULONG tag)
NdisFreeMemoryWithTagPriority(gOvsExtDriverHandle, ptr, tag);
}
+_Use_decl_annotations_
VOID *
OvsAllocateMemory(size_t size)
{
- OVS_VERIFY_IRQL_LE(DISPATCH_LEVEL);
return NdisAllocateMemoryWithTagPriority(gOvsExtDriverHandle,
(UINT32)size, OVS_MEMORY_TAG, NormalPoolPriority);
}
+_Use_decl_annotations_
VOID *
OvsAllocateAlignedMemory(size_t size, UINT16 align)
{
- OVS_VERIFY_IRQL_LE(DISPATCH_LEVEL);
-
ASSERT((align == 8) || (align == 16));
if ((align == 8) || (align == 16)) {
diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index cccf9ff..bcb80b6 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -41,9 +41,15 @@
#define OVS_GENEVE_POOL_TAG 'GNVO'
#define OVS_IPFRAG_POOL_TAG 'FGVO'
+_IRQL_requires_max_(DISPATCH_LEVEL)
VOID *OvsAllocateMemory(size_t size);
+
+_IRQL_requires_max_(DISPATCH_LEVEL)
VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
+
+_IRQL_requires_max_(DISPATCH_LEVEL)
VOID *OvsAllocateAlignedMemory(size_t size, UINT16 align);
+
VOID *OvsAllocateMemoryPerCpu(size_t size, size_t count, ULONG tag);
VOID OvsFreeMemory(VOID *ptr);
VOID OvsFreeMemoryWithTag(VOID *ptr, ULONG tag);
--
2.10.2.windows.1
More information about the dev
mailing list