Author: mnordell
Date: Wed Oct 17 12:31:02 2007
New Revision: 29633
URL:
http://svn.reactos.org/svn/reactos?rev=29633&view=rev
Log:
Fix PAGE_ROUND_DOWN, PAGE_ROUND_UP, and a user of them (correctness and speedup)
Modified:
trunk/reactos/include/ndk/mmtypes.h
trunk/reactos/include/reactos/helper.h
trunk/reactos/ntoskrnl/mm/virtual.c
Modified: trunk/reactos/include/ndk/mmtypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/mmtypes.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/mmtypes.h (original)
+++ trunk/reactos/include/ndk/mmtypes.h Wed Oct 17 12:31:02 2007
@@ -30,11 +30,9 @@
// Page-Rounding Macros
//
#define PAGE_ROUND_DOWN(x) \
- (((ULONG_PTR)x)&(~(PAGE_SIZE-1)))
+ (((ULONG_PTR)(x))&(~(PAGE_SIZE-1)))
#define PAGE_ROUND_UP(x) \
- ( (((ULONG_PTR)x)%PAGE_SIZE) ? \
- ((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : \
- ((ULONG_PTR)x) )
+ ( (((ULONG_PTR)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)) )
#ifdef NTOS_MODE_USER
#define ROUND_TO_PAGES(Size) \
(((ULONG_PTR)(Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
Modified: trunk/reactos/include/reactos/helper.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/helper.h?r…
==============================================================================
--- trunk/reactos/include/reactos/helper.h (original)
+++ trunk/reactos/include/reactos/helper.h Wed Oct 17 12:31:02 2007
@@ -20,11 +20,11 @@
#endif
#ifndef PAGE_ROUND_DOWN
-#define PAGE_ROUND_DOWN(x) (((ULONG_PTR)x)&(~(PAGE_SIZE-1)))
+#define PAGE_ROUND_DOWN(x) (((ULONG_PTR)(x))&(~(PAGE_SIZE-1)))
#endif
#ifndef PAGE_ROUND_UP
-#define PAGE_ROUND_UP(x) ( (((ULONG_PTR)x)%PAGE_SIZE) ?
((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG_PTR)x) )
+#define PAGE_ROUND_UP(x) ( (((ULONG_PTR)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)) )
#endif
#define ABS_VALUE(V) (((V) < 0) ? -(V) : (V))
Modified: trunk/reactos/ntoskrnl/mm/virtual.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/virtual.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/virtual.c (original)
+++ trunk/reactos/ntoskrnl/mm/virtual.c Wed Oct 17 12:31:02 2007
@@ -390,7 +390,7 @@
NTSTATUS Status;
*NumberOfBytesToProtect =
- PAGE_ROUND_UP((*BaseAddress) + (*NumberOfBytesToProtect)) -
+ PAGE_ROUND_UP((ULONG_PTR)(*BaseAddress) + (*NumberOfBytesToProtect)) -
PAGE_ROUND_DOWN(*BaseAddress);
*BaseAddress = (PVOID)PAGE_ROUND_DOWN(*BaseAddress);