diff --git a/reactos/base/setup/usetup/usetup.h b/reactos/base/setup/usetup/usetup.h index ce933d8a5a6..ace2c68ece8 100644 --- a/reactos/base/setup/usetup/usetup.h +++ b/reactos/base/setup/usetup/usetup.h @@ -45,9 +45,6 @@ /* DDK Disk Headers */ #include -/* Helper Header */ -#include - /* ReactOS Version */ #include @@ -125,6 +122,34 @@ typedef enum _PAGE_NUMBER #define POPUP_WAIT_ANY_KEY 1 #define POPUP_WAIT_ENTER 2 +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) + +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) + +#define LIST_FOR_EACH(elem, list, type, field) \ + for ((elem) = CONTAINING_RECORD((list)->Flink, type, field); \ + &(elem)->field != (list) || (elem == NULL); \ + (elem) = CONTAINING_RECORD((elem)->field.Flink, type, field)) + +#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)\ +{\ + PLIST_ENTRY current;\ +\ + current = (ListHead)->Flink;\ + while (current != (ListHead))\ + {\ + if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\ + (NewEntry)->SortField)\ + {\ + break;\ + }\ + current = current->Flink;\ + }\ +\ + InsertTailList(current, &((NewEntry)->ListEntryField));\ +} #endif /* __USETUP_H__*/ diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index ebbc93be171..decedca71ad 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -21,6 +21,13 @@ #define __FREELDR_H #define UINT64_C(val) val##ULL +#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m))) + +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) + +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) #define NTOSAPI #define printf TuiPrintf @@ -94,7 +101,6 @@ /* Externals */ #include #include -#include /* Needed if debuging is enabled */ #include /* Swap */ diff --git a/reactos/dll/directx/ksuser/ksuser.h b/reactos/dll/directx/ksuser/ksuser.h index 2e00b47eced..69a83aa73ca 100644 --- a/reactos/dll/directx/ksuser/ksuser.h +++ b/reactos/dll/directx/ksuser/ksuser.h @@ -9,7 +9,6 @@ #include -#include LPVOID __stdcall @@ -19,4 +18,10 @@ HeapAlloc( DWORD dwBytes ); +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) + +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) + #endif diff --git a/reactos/dll/ntdll/include/ntdll.h b/reactos/dll/ntdll/include/ntdll.h index cb8f21cd134..e85d5c5ffb6 100644 --- a/reactos/dll/ntdll/include/ntdll.h +++ b/reactos/dll/ntdll/include/ntdll.h @@ -32,7 +32,4 @@ /* CSRSS Header */ #include -/* Helper Macros */ -#include - /* EOF */ diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index 3219d723b3e..e23e9690452 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -22,6 +22,7 @@ #include #define LDRP_PROCESS_CREATION_TIME 0x8000000 +#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m))) /* GLOBALS *******************************************************************/ diff --git a/reactos/dll/win32/kernel32/file/iocompl.c b/reactos/dll/win32/kernel32/file/iocompl.c index 83a1fc04c0d..2f332460cc7 100644 --- a/reactos/dll/win32/kernel32/file/iocompl.c +++ b/reactos/dll/win32/kernel32/file/iocompl.c @@ -12,6 +12,10 @@ #include #include +#define NANOS_TO_100NS(nanos) (((LONGLONG)(nanos)) / 100) +#define MICROS_TO_100NS(micros) (((LONGLONG)(micros)) * NANOS_TO_100NS(1000)) +#define MILLIS_TO_100NS(milli) (((LONGLONG)(milli)) * MICROS_TO_100NS(1000)) + WINE_DEFAULT_DEBUG_CHANNEL(kernel32file); /* @@ -110,7 +114,7 @@ GetQueuedCompletionStatus( if (dwMilliseconds != INFINITE) { - Interval.QuadPart = RELATIVE_TIME(MILLIS_TO_100NS(dwMilliseconds)); + Interval.QuadPart = (-(MILLIS_TO_100NS(dwMilliseconds))); } errCode = NtRemoveIoCompletion(CompletionHandle, diff --git a/reactos/dll/win32/kernel32/include/kernel32.h b/reactos/dll/win32/kernel32/include/kernel32.h index a00880592f0..72ea0cfedaa 100755 --- a/reactos/dll/win32/kernel32/include/kernel32.h +++ b/reactos/dll/win32/kernel32/include/kernel32.h @@ -21,6 +21,12 @@ #define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b)) #define ROUNDDOWN(a,b) (((a)/(b))*(b)) +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) + +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) + #ifndef FIELD_OFFSET #define FIELD_OFFSET(type,fld) ((LONG)&(((type *)0)->fld)) #endif diff --git a/reactos/dll/win32/kernel32/k32.h b/reactos/dll/win32/kernel32/k32.h index bc55db7eda8..602642120ac 100755 --- a/reactos/dll/win32/kernel32/k32.h +++ b/reactos/dll/win32/kernel32/k32.h @@ -41,7 +41,4 @@ /* PSEH for SEH Support */ #include -/* Helper Header */ -#include - #endif diff --git a/reactos/dll/win32/kernel32/misc/version.c b/reactos/dll/win32/kernel32/misc/version.c index fa52e442d9a..67e96b3f196 100644 --- a/reactos/dll/win32/kernel32/misc/version.c +++ b/reactos/dll/win32/kernel32/misc/version.c @@ -15,6 +15,8 @@ #define NDEBUG #include +#define UNICODIZE1(x) L##x +#define UNICODIZE(x) UNICODIZE1(x) /* FUNCTIONS ******************************************************************/ diff --git a/reactos/drivers/filesystems/fastfat/vfat.h b/reactos/drivers/filesystems/fastfat/vfat.h index 43f222b680c..b9f96af9363 100644 --- a/reactos/drivers/filesystems/fastfat/vfat.h +++ b/reactos/drivers/filesystems/fastfat/vfat.h @@ -1,6 +1,5 @@ #include #include -#include #include #ifdef __GNUC__ @@ -14,6 +13,12 @@ #define ROUND_UP(N, S) ROUND_DOWN((N) + (S) - 1, (S)) #endif +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) + +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) + #include struct _BootSector { diff --git a/reactos/drivers/filesystems/fastfat_new/fastfat.h b/reactos/drivers/filesystems/fastfat_new/fastfat.h index dbb5dddc9a6..b900b2387cf 100644 --- a/reactos/drivers/filesystems/fastfat_new/fastfat.h +++ b/reactos/drivers/filesystems/fastfat_new/fastfat.h @@ -1,6 +1,5 @@ #include #include -#include #include #ifndef TAG diff --git a/reactos/drivers/storage/class/ramdisk/ramdisk.c b/reactos/drivers/storage/class/ramdisk/ramdisk.c index ae13361828c..9d28c4c39a2 100644 --- a/reactos/drivers/storage/class/ramdisk/ramdisk.c +++ b/reactos/drivers/storage/class/ramdisk/ramdisk.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/reactos/drivers/video/videoprt/videoprt.h b/reactos/drivers/video/videoprt/videoprt.h index e249f005cf7..9e66cd4f3a7 100644 --- a/reactos/drivers/video/videoprt/videoprt.h +++ b/reactos/drivers/video/videoprt/videoprt.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/reactos/hal/halarm/include/hal.h b/reactos/hal/halarm/include/hal.h index e16859b753f..585b4d0401f 100644 --- a/reactos/hal/halarm/include/hal.h +++ b/reactos/hal/halarm/include/hal.h @@ -37,7 +37,4 @@ /* Internal HAL Headers */ #include "halp.h" -/* Helper Header */ -#include - /* EOF */ diff --git a/reactos/hal/halppc/include/hal.h b/reactos/hal/halppc/include/hal.h index 5220140dfe4..87372c42b6a 100644 --- a/reactos/hal/halppc/include/hal.h +++ b/reactos/hal/halppc/include/hal.h @@ -47,7 +47,4 @@ #include "mps.h" #include "ioapic.h" -/* Helper Header */ -#include - /* EOF */ diff --git a/reactos/hal/halx86/include/hal.h b/reactos/hal/halx86/include/hal.h index caedc2efd78..7a7845d46c1 100644 --- a/reactos/hal/halx86/include/hal.h +++ b/reactos/hal/halx86/include/hal.h @@ -46,7 +46,4 @@ #include "mps.h" #include "ioapic.h" -/* Helper Header */ -#include - /* EOF */ diff --git a/reactos/include/reactos/helper.h b/reactos/include/reactos/helper.h deleted file mode 100644 index 1bb7a52cfe4..00000000000 --- a/reactos/include/reactos/helper.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef _HELPER_H -#define _HELPER_H - -#ifndef ROUND_UP -#define ROUND_UP(n, align) \ - ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) -#endif - -#ifndef ROUND_DOWN -#define ROUND_DOWN(n, align) \ - (((ULONG)n) & ~((align) - 1l)) -#endif - -#ifndef ROUNDUP -#define ROUNDUP ROUND_UP -#endif - -#ifndef ROUNDDOWN -#define ROUNDDOWN ROUND_DOWN -#endif - -#ifndef PAGE_ROUND_DOWN -#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-1) & (~(PAGE_SIZE-1)) ) -#endif - -/* iterate through the list using a list entry. - * elem is set to NULL if the list is run thru without breaking out or if list is empty. - */ -#define LIST_FOR_EACH(elem, list, type, field) \ - for ((elem) = CONTAINING_RECORD((list)->Flink, type, field); \ - &(elem)->field != (list) || (elem == NULL); \ - (elem) = CONTAINING_RECORD((elem)->field.Flink, type, field)) - -/* iterate through the list using a list entry, with safety against removal - * elem is set to NULL if the list is run thru without breaking out or if list is empty. - */ -#define LIST_FOR_EACH_SAFE(cursor, cursor2, list, type, field) \ - for ((cursor) = CONTAINING_RECORD((list)->Flink, type, field), \ - (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field); \ - &(cursor)->field != (list) || (cursor == NULL); \ - (cursor) = (cursor2), \ - (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field)) - -#define OPTHDROFFSET(a) ((LPVOID)((BYTE *)a + \ - ((PIMAGE_DOS_HEADER)a)->e_lfanew + \ - sizeof (IMAGE_NT_SIGNATURE) + \ - sizeof (IMAGE_FILE_HEADER))) -#ifndef TAG -#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24)) -#endif -#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m))) -#define NTSTAT_SEVERITY_SHIFT 30 -#define NTSTAT_SEVERITY_MASK 0x00000003 -#define NTSTAT_FACILITY_SHIFT 16 -#define NTSTAT_FACILITY_MASK 0x00000FFF -#define NTSTAT_CUSTOMER_MASK 0x20000000 -#define NT_SEVERITY(StatCode) (((StatCode) >> NTSTAT_SEVERITY_SHIFT) & NTSTAT_SEVERITY_MASK) -#define NT_FACILITY(StatCode) (((StatCode) >> NTSTAT_FACILITY_SHIFT) & NTSTAT_FACILITY_MASK) -#define NT_CUSTOMER(StatCode) ((StatCode) & NTSTAT_CUSTOMER_MASK) -#define RELATIVE_TIME(wait) (-(wait)) -#define NANOS_TO_100NS(nanos) (((LONGLONG)(nanos)) / 100) -#define MICROS_TO_100NS(micros) (((LONGLONG)(micros)) * NANOS_TO_100NS(1000)) -#define MILLIS_TO_100NS(milli) (((LONGLONG)(milli)) * MICROS_TO_100NS(1000)) -#define SECONDS_TO_100NS(seconds) (((LONGLONG)(seconds)) * MILLIS_TO_100NS(1000)) -#define MINUTES_TO_100NS(minutes) (((LONGLONG)(minutes)) * SECONDS_TO_100NS(60)) -#define HOURS_TO_100NS(hours) (((LONGLONG)(hours)) * MINUTES_TO_100NS(60)) -#define UNICODIZE1(x) L##x -#define UNICODIZE(x) UNICODIZE1(x) -#define InsertAscendingListFIFO(ListHead, NewEntry, Type, ListEntryField, SortField)\ -{\ - PLIST_ENTRY current;\ -\ - current = (ListHead)->Flink;\ - while (current != (ListHead))\ - {\ - if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >\ - (NewEntry)->SortField)\ - {\ - break;\ - }\ - current = current->Flink;\ - }\ -\ - InsertTailList(current, &((NewEntry)->ListEntryField));\ -} - -#define InsertDescendingListFIFO(ListHead, NewEntry, Type, ListEntryField, SortField)\ -{\ - PLIST_ENTRY current;\ -\ - current = (ListHead)->Flink;\ - while (current != (ListHead))\ - {\ - if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <\ - (NewEntry)->SortField)\ - {\ - break;\ - }\ - current = current->Flink;\ - }\ -\ - InsertTailList(current, &((NewEntry)->ListEntryField));\ -} - -#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)\ -{\ - PLIST_ENTRY current;\ -\ - current = (ListHead)->Flink;\ - while (current != (ListHead))\ - {\ - if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\ - (NewEntry)->SortField)\ - {\ - break;\ - }\ - current = current->Flink;\ - }\ -\ - InsertTailList(current, &((NewEntry)->ListEntryField));\ -} - -#define InsertDescendingList(ListHead, NewEntry, Type, ListEntryField, SortField)\ -{\ - PLIST_ENTRY current;\ -\ - current = (ListHead)->Flink;\ - while (current != (ListHead))\ - {\ - if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <=\ - (NewEntry)->SortField)\ - {\ - break;\ - }\ - current = current->Flink;\ - }\ -\ - InsertTailList(current, &((NewEntry)->ListEntryField));\ -} - -#endif diff --git a/reactos/lib/fslib/vfatlib/check/vfat.h b/reactos/lib/fslib/vfatlib/check/vfat.h index 121ca3258ea..25b79d68a42 100755 --- a/reactos/lib/fslib/vfatlib/check/vfat.h +++ b/reactos/lib/fslib/vfatlib/check/vfat.h @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include diff --git a/reactos/lib/ppcmmu/mmuobject.c b/reactos/lib/ppcmmu/mmuobject.c index d8a42eba214..45190bbdbdf 100644 --- a/reactos/lib/ppcmmu/mmuobject.c +++ b/reactos/lib/ppcmmu/mmuobject.c @@ -2,7 +2,6 @@ #include "ppcmmu/mmu.h" #include "ppcmmu/mmuutil.h" #include "mmuobject.h" -#include "helper.h" typedef unsigned long ULONG; diff --git a/reactos/lib/rtl/env.c b/reactos/lib/rtl/env.c index 6a719abefbd..f7fac92aeb8 100644 --- a/reactos/lib/rtl/env.c +++ b/reactos/lib/rtl/env.c @@ -368,7 +368,7 @@ found: /* enlarge environment size */ /* check the size of available memory */ new_size += (env_len - hole_len) * sizeof(WCHAR); - new_size = ROUNDUP(new_size, PAGE_SIZE); + new_size = ROUND_UP(new_size, PAGE_SIZE); mbi.RegionSize = 0; DPRINT("new_size %lu\n", new_size); diff --git a/reactos/lib/rtl/image.c b/reactos/lib/rtl/image.c index 5f79b7e3aa0..24fab06d0d0 100644 --- a/reactos/lib/rtl/image.c +++ b/reactos/lib/rtl/image.c @@ -16,6 +16,8 @@ #define NDEBUG #include +#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m))) + /* FUNCTIONS *****************************************************************/ BOOLEAN diff --git a/reactos/lib/rtl/ppb.c b/reactos/lib/rtl/ppb.c index d21d8eac86c..868f170b989 100644 --- a/reactos/lib/rtl/ppb.c +++ b/reactos/lib/rtl/ppb.c @@ -121,7 +121,7 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, Length += ALIGN(RuntimeData->MaximumLength, sizeof(ULONG)); /* Calculate the required block size */ - RegionSize = ROUNDUP(Length, PAGE_SIZE); + RegionSize = ROUND_UP(Length, PAGE_SIZE); Status = ZwAllocateVirtualMemory(NtCurrentProcess(), (PVOID*)&Param, diff --git a/reactos/lib/rtl/rtl.h b/reactos/lib/rtl/rtl.h index bcb254d5e31..3d10deb9338 100644 --- a/reactos/lib/rtl/rtl.h +++ b/reactos/lib/rtl/rtl.h @@ -28,7 +28,6 @@ #include "rtlp.h" /* PSEH Support */ -#include #include #include diff --git a/reactos/lib/rtl/rtlp.h b/reactos/lib/rtl/rtlp.h index 4f3d8c00bed..8458c65f21b 100644 --- a/reactos/lib/rtl/rtlp.h +++ b/reactos/lib/rtl/rtlp.h @@ -24,6 +24,12 @@ extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line); #define SWAPW(x) x #endif +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) + +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) + VOID NTAPI RtlpGetStackLimits(PULONG_PTR StackBase, diff --git a/reactos/lib/sdk/crt/precomp.h b/reactos/lib/sdk/crt/precomp.h index 847d76b2e05..19d08a56aa8 100644 --- a/reactos/lib/sdk/crt/precomp.h +++ b/reactos/lib/sdk/crt/precomp.h @@ -28,7 +28,6 @@ #define WIN32_NO_STATUS #include #include -#include #if !defined(_MSC_VER) #include diff --git a/reactos/lib/sdk/crt/stdlib/malloc.c b/reactos/lib/sdk/crt/stdlib/malloc.c index 3c5d98eebf5..2bd7d8a7bbf 100644 --- a/reactos/lib/sdk/crt/stdlib/malloc.c +++ b/reactos/lib/sdk/crt/stdlib/malloc.c @@ -25,6 +25,11 @@ #include #include +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) + +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) /* round to 16 bytes + alloc at minimum 16 bytes */ #define ROUND_SIZE(size) (max(16, ROUND_UP(size, 16))) diff --git a/reactos/ntoskrnl/include/internal/ntoskrnl.h b/reactos/ntoskrnl/include/internal/ntoskrnl.h index dd7bee0946d..8deb0616ec6 100644 --- a/reactos/ntoskrnl/include/internal/ntoskrnl.h +++ b/reactos/ntoskrnl/include/internal/ntoskrnl.h @@ -24,6 +24,8 @@ #undef PsGetCurrentProcess #define PsGetCurrentProcess _PsGetCurrentProcess +#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m))) + // // We are very lazy on ARM -- we just import intrinsics // Question: Why wasn't this done for x86 too? (see fastintrlck.asm) diff --git a/reactos/ntoskrnl/include/precomp.h b/reactos/ntoskrnl/include/precomp.h index 48170a25e3e..8efaa9e864f 100644 --- a/reactos/ntoskrnl/include/precomp.h +++ b/reactos/ntoskrnl/include/precomp.h @@ -63,9 +63,6 @@ /* PNP GUIDs */ #include -/* Helper Header */ -#include - /* Internal Headers */ #include "internal/ntoskrnl.h" #include "config.h" diff --git a/reactos/subsystems/win32/win32k/pch.h b/reactos/subsystems/win32/win32k/pch.h index af71227cc03..0d1257069d8 100644 --- a/reactos/subsystems/win32/win32k/pch.h +++ b/reactos/subsystems/win32/win32k/pch.h @@ -43,9 +43,6 @@ typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; /* CSRSS Header */ #include -/* Helper Header */ -#include - /* Public Win32K Headers */ #include #include @@ -139,4 +136,22 @@ UserHeapAddressToUser(PVOID lpMem) (ULONG_PTR)W32Process->HeapMappings.UserMapping); } +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) + +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) + +#define LIST_FOR_EACH(elem, list, type, field) \ + for ((elem) = CONTAINING_RECORD((list)->Flink, type, field); \ + &(elem)->field != (list) || (elem == NULL); \ + (elem) = CONTAINING_RECORD((elem)->field.Flink, type, field)) + +#define LIST_FOR_EACH_SAFE(cursor, cursor2, list, type, field) \ + for ((cursor) = CONTAINING_RECORD((list)->Flink, type, field), \ + (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field); \ + &(cursor)->field != (list) || (cursor == NULL); \ + (cursor) = (cursor2), \ + (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field)) + #endif /* __W32K_H */