- Deprecate global helper.h -- define the various 'helpful macros' per module

svn path=/trunk/; revision=39092
This commit is contained in:
Stefan Ginsberg 2009-01-25 16:13:16 +00:00
parent 72916420fc
commit dbd86db31e
29 changed files with 96 additions and 182 deletions

View file

@ -45,9 +45,6 @@
/* DDK Disk Headers */
#include <ntddscsi.h>
/* Helper Header */
#include <reactos/helper.h>
/* ReactOS Version */
#include <reactos/buildno.h>
@ -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__*/

View file

@ -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 <reactos/rossym.h>
#include <reactos/buildno.h>
#include <reactos/helper.h>
/* Needed if debuging is enabled */
#include <comm.h>
/* Swap */

View file

@ -9,7 +9,6 @@
#include <ks.h>
#include <reactos/helper.h>
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

View file

@ -32,7 +32,4 @@
/* CSRSS Header */
#include <csrss/csrss.h>
/* Helper Macros */
#include <reactos/helper.h>
/* EOF */

View file

@ -22,6 +22,7 @@
#include <debug.h>
#define LDRP_PROCESS_CREATION_TIME 0x8000000
#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
/* GLOBALS *******************************************************************/

View file

@ -12,6 +12,10 @@
#include <k32.h>
#include <wine/debug.h>
#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,

View file

@ -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

View file

@ -41,7 +41,4 @@
/* PSEH for SEH Support */
#include <pseh/pseh2.h>
/* Helper Header */
#include <reactos/helper.h>
#endif

View file

@ -15,6 +15,8 @@
#define NDEBUG
#include <debug.h>
#define UNICODIZE1(x) L##x
#define UNICODIZE(x) UNICODIZE1(x)
/* FUNCTIONS ******************************************************************/

View file

@ -1,6 +1,5 @@
#include <ntifs.h>
#include <ntdddisk.h>
#include <reactos/helper.h>
#include <debug.h>
#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 <pshpack1.h>
struct _BootSector
{

View file

@ -1,6 +1,5 @@
#include <ntifs.h>
#include <ntdddisk.h>
#include <reactos/helper.h>
#include <debug.h>
#ifndef TAG

View file

@ -17,7 +17,6 @@
#include <ntddvol.h>
#include <mountdev.h>
#include <mountmgr.h>
#include <helper.h>
#include <ketypes.h>
#include <iotypes.h>
#include <rtlfuncs.h>

View file

@ -31,7 +31,6 @@
#include <ntagp.h>
#include <ntifs.h>
#include <ndk/ntndk.h>
#include <reactos/helper.h>
#include <dderror.h>
#include <windef.h>

View file

@ -37,7 +37,4 @@
/* Internal HAL Headers */
#include "halp.h"
/* Helper Header */
#include <reactos/helper.h>
/* EOF */

View file

@ -47,7 +47,4 @@
#include "mps.h"
#include "ioapic.h"
/* Helper Header */
#include <reactos/helper.h>
/* EOF */

View file

@ -46,7 +46,4 @@
#include "mps.h"
#include "ioapic.h"
/* Helper Header */
#include <reactos/helper.h>
/* EOF */

View file

@ -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

View file

@ -3,7 +3,6 @@
#include <ddk/ntifs.h>
#include <ddk/ntdddisk.h>
#include <ndk/ntndk.h>
#include <reactos/helper.h>
#include <ccros.h>
#include <limits.h>
#include <debug.h>

View file

@ -2,7 +2,6 @@
#include "ppcmmu/mmu.h"
#include "ppcmmu/mmuutil.h"
#include "mmuobject.h"
#include "helper.h"
typedef unsigned long ULONG;

View file

@ -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);

View file

@ -16,6 +16,8 @@
#define NDEBUG
#include <debug.h>
#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
/* FUNCTIONS *****************************************************************/
BOOLEAN

View file

@ -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,

View file

@ -28,7 +28,6 @@
#include "rtlp.h"
/* PSEH Support */
#include <reactos/helper.h>
#include <pseh/pseh2.h>
#include <intrin.h>

View file

@ -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,

View file

@ -28,7 +28,6 @@
#define WIN32_NO_STATUS
#include <windows.h>
#include <ndk/ntndk.h>
#include <reactos/helper.h>
#if !defined(_MSC_VER)
#include <stdint.h>

View file

@ -25,6 +25,11 @@
#include <stdlib.h>
#include <malloc.h>
#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)))

View file

@ -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)

View file

@ -63,9 +63,6 @@
/* PNP GUIDs */
#include <umpnpmgr/sysguid.h>
/* Helper Header */
#include <reactos/helper.h>
/* Internal Headers */
#include "internal/ntoskrnl.h"
#include "config.h"

View file

@ -43,9 +43,6 @@ typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
/* CSRSS Header */
#include <csrss/csrss.h>
/* Helper Header */
#include <reactos/helper.h>
/* Public Win32K Headers */
#include <win32k/callback.h>
#include <win32k/ntusrtyp.h>
@ -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 */