diff --git a/reactos/include/ddk/mmfuncs.h b/reactos/include/ddk/mmfuncs.h index 7cffe6baa4f..bbf635a0414 100644 --- a/reactos/include/ddk/mmfuncs.h +++ b/reactos/include/ddk/mmfuncs.h @@ -26,21 +26,9 @@ extern POBJECT_TYPE IMPORTED MmSectionObjectType; * Size = Size of range * RETURNS: The number of pages */ -#if 0 -extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va, - ULONG Size) -{ - ULONG HighestAddr; - ULONG LowestAddr; - - HighestAddr = PAGE_ROUND_UP(Size + ((ULONG)Va)); - LowestAddr = PAGE_ROUND_DOWN((ULONG)Va); - return((HighestAddr - LowestAddr) / PAGE_SIZE); -} -#endif #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va, Size) \ - (ULONG)((PAGE_ROUND_UP((Size) + ((ULONG)(Va))) - \ - PAGE_ROUND_DOWN((ULONG)(Va))) / PAGE_SIZE) + (ULONG)((PAGE_ROUND_UP((Size) + ((ULONG_PTR)(Va))) - \ + PAGE_ROUND_DOWN((ULONG_PTR)(Va))) / PAGE_SIZE) /* * FUNCTION: Returns FALSE is the pointer is NULL, TRUE otherwise @@ -50,7 +38,7 @@ extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va, /* * FUNCTION: Returns the byte offset of the address within its page */ -#define BYTE_OFFSET(va) (((ULONG)va)%PAGE_SIZE) +#define BYTE_OFFSET(va) (((ULONG_PTR)va)%PAGE_SIZE) #define PAGE_OFFSET(va) BYTE_OFFSET(va) @@ -59,10 +47,9 @@ extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va, * required to hold it */ #define BYTES_TO_PAGES(Size) \ - ((ULONG) ((ULONG_PTR) (Size) >> PAGE_SHIFT) + (((ULONG) (Size) & (PAGE_SIZE - 1)) != 0)) + (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0)) - -#define PAGE_ALIGN(va) ( (PVOID) (((ULONG)(va)) & (~(PAGE_SIZE-1))) ) +#define PAGE_ALIGN(va) ( (PVOID) (((ULONG_PTR)(va)) & (~(PAGE_SIZE-1))) ) #define PAGE_BASE(va) PAGE_ALIGN(va) NTSTATUS @@ -331,10 +318,10 @@ MmGrowKernelStack ( { \ (MemoryDescriptorList)->Next = (PMDL)NULL; \ (MemoryDescriptorList)->Size = (CSHORT)(sizeof(MDL) + \ - (ADDRESS_AND_SIZE_TO_SPAN_PAGES((BaseVa),(Length)) * sizeof(ULONG))); \ + (ADDRESS_AND_SIZE_TO_SPAN_PAGES((BaseVa),(Length)) * sizeof(PFN_NUMBER))); \ (MemoryDescriptorList)->MdlFlags = 0; \ - (MemoryDescriptorList)->StartVa = (PVOID)PAGE_BASE(BaseVa); \ - (MemoryDescriptorList)->ByteOffset = (ULONG)PAGE_OFFSET(BaseVa); \ + (MemoryDescriptorList)->StartVa = PAGE_ALIGN(BaseVa); \ + (MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(BaseVa); \ (MemoryDescriptorList)->ByteCount = (Length); \ } diff --git a/reactos/include/ddk/mmtypes.h b/reactos/include/ddk/mmtypes.h index a4c87616e72..5eee4277254 100644 --- a/reactos/include/ddk/mmtypes.h +++ b/reactos/include/ddk/mmtypes.h @@ -15,7 +15,7 @@ * PURPOSE: Returns the byte offset of a field within a structure */ #ifndef FIELD_OFFSET -#define FIELD_OFFSET(Type,Field) ((LONG)(&(((Type *)(0))->Field))) +#define FIELD_OFFSET(Type,Field) ((ULONG_PTR)(&(((Type *)(0))->Field))) #endif /* @@ -27,9 +27,16 @@ * Field = Name of the field whose address is none */ #ifndef CONTAINING_RECORD -#define CONTAINING_RECORD(Address,Type,Field) ((Type *)(((LONG)Address) - FIELD_OFFSET(Type,Field))) +#define CONTAINING_RECORD(Address,Type,Field) ((Type *)(((ULONG_PTR)Address) - FIELD_OFFSET(Type,Field))) #endif +#ifdef _M_IX86 +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +#elif _M_IA64 +typedef ULONG64 PFN_NUMBER, *PPFN_NUMBER; +#else +#error Unknown architecture +#endif #define MDL_MAPPED_TO_SYSTEM_VA (0x1) #define MDL_PAGES_LOCKED (0x2) diff --git a/reactos/include/msvcrt/crttypes.h b/reactos/include/msvcrt/crttypes.h index 0900ce1a341..e8e066318a2 100644 --- a/reactos/include/msvcrt/crttypes.h +++ b/reactos/include/msvcrt/crttypes.h @@ -49,20 +49,6 @@ struct _ETHREAD { int foobar; }; struct _EPROCESS { int foobar; }; #endif -#ifndef _DEBUG -#pragma function(_disable,_enable) -#pragma function(_inp,_inpw,_outp,_outpw) -#pragma function(_lrotl,_lrotr,_rotl,_rotr) -#pragma function(abs,fabs,labs) -#pragma function(memcpy,memcmp,memset) -#pragma function(strcat,strcmp,strcpy,strlen,_strset) -#pragma function(fmod,sqrt) -#pragma function(log,log10,pow,exp) -#pragma function(tan,atan,atan2,tanh) -#pragma function(cos,acos,cosh) -#pragma function(sin,asin,sinh) -#endif - #endif /*__GNUC__*/ diff --git a/reactos/include/msvcrt/stddef.h b/reactos/include/msvcrt/stddef.h index 9dd4ee6edba..6a3e3df7c73 100644 --- a/reactos/include/msvcrt/stddef.h +++ b/reactos/include/msvcrt/stddef.h @@ -154,7 +154,11 @@ typedef __WINT_TYPE__ wint_t; #if defined (__MSVCRT_STDDEF_H_) || defined (__need_NULL) #undef NULL +#ifdef __cplusplus #define NULL (0) +#else +#define NULL ((void *)0) +#endif #endif /* __MSVCRT_STDDEF_H_ or __need_NULL */ #undef __need_NULL diff --git a/reactos/include/napi/teb.h b/reactos/include/napi/teb.h index c6f1ea00346..ed58fff818b 100644 --- a/reactos/include/napi/teb.h +++ b/reactos/include/napi/teb.h @@ -286,7 +286,7 @@ unsigned __gregister_get(unsigned const regnum); #define NtCurrentTeb() ((struct _TEB *)__gregister_get(13)) #else -#error Unsupported architecture or no architecture specified. +struct _TEB * NtCurrentTeb(void); #endif #endif diff --git a/reactos/include/ntos/mm.h b/reactos/include/ntos/mm.h index d6f763ca02e..ca752bca38e 100644 --- a/reactos/include/ntos/mm.h +++ b/reactos/include/ntos/mm.h @@ -62,7 +62,7 @@ #endif /* __USE_W32API */ -#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGE_SIZE) ? ((((ULONG)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG)x) ) -#define PAGE_ROUND_DOWN(x) (((ULONG)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) ) +#define PAGE_ROUND_DOWN(x) (((ULONG_PTR)x)&(~(PAGE_SIZE-1))) #endif /* __INCLUDE_MM_H */ diff --git a/reactos/include/pseh/framebased.h b/reactos/include/pseh/framebased.h index 8a913c6435e..51823e0091d 100644 --- a/reactos/include/pseh/framebased.h +++ b/reactos/include/pseh/framebased.h @@ -176,11 +176,11 @@ static __declspec(noreturn) __inline void __stdcall _SEHCompilerSpecificHandler #define _SEH_TRY_FILTER_FINALLY(FILTER_, FINALLY_) \ { \ - _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_); \ - \ _SEHFrame_t * _SEHFrame; \ volatile _SEHPortableFrame_t * _SEHPortableFrame; \ \ + _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_); \ + \ _SEHFrame = _alloca(sizeof(_SEHFrame_t)); \ _SEHFrame->SEH_Header.SPF_Handlers = &_SEHHandlers; \ _SEHFrame->SEH_Locals = &_SEHLocals; \