From 79690d04fac22ae10a11320d2c3b43cf557b6aaa Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 6 Dec 2009 03:24:18 +0000 Subject: [PATCH] Merge from amd64 branch: - 34939 fix several ULONG / ULONG_PTR / SIZE_T issues (Timo Kreuzer) - 40088 implement __mulh and __umulh (Timo Kreuzer) svn path=/trunk/; revision=44431 --- reactos/include/crt/mingw32/intrin_x86.h | 17 +++++++++++++++++ reactos/ntoskrnl/mm/pool.c | 4 ++-- reactos/ntoskrnl/mm/region.c | 2 +- reactos/ntoskrnl/mm/rpoolmgr.h | 4 ++-- reactos/ntoskrnl/mm/section.c | 10 ++++++---- reactos/ntoskrnl/mm/sysldr.c | 2 +- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/reactos/include/crt/mingw32/intrin_x86.h b/reactos/include/crt/mingw32/intrin_x86.h index bab8e969d1f..84c1e663996 100644 --- a/reactos/include/crt/mingw32/intrin_x86.h +++ b/reactos/include/crt/mingw32/intrin_x86.h @@ -968,6 +968,23 @@ __INTRIN_INLINE unsigned long long __emulu(const unsigned int a, const unsigned return retval; } +#ifdef _M_AMD64 + +__INTRIN_INLINE __int64 __mulh(__int64 a, __int64 b) +{ + __int64 retval; + __asm__("imulq %[b]" : "=d" (retval) : [a] "a" (a), [b] "rm" (b)); + return retval; +} + +__INTRIN_INLINE unsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b) +{ + unsigned __int64 retval; + __asm__("mulq %[b]" : "=d" (retval) : [a] "a" (a), [b] "rm" (b)); + return retval; +} + +#endif /*** Port I/O ***/ __INTRIN_INLINE unsigned char __inbyte(const unsigned short Port) diff --git a/reactos/ntoskrnl/mm/pool.c b/reactos/ntoskrnl/mm/pool.c index 73fdbe20530..07132e80e85 100644 --- a/reactos/ntoskrnl/mm/pool.c +++ b/reactos/ntoskrnl/mm/pool.c @@ -92,7 +92,7 @@ EiAllocatePool(POOL_TYPE PoolType, * @implemented */ PVOID NTAPI -ExAllocatePool (POOL_TYPE PoolType, ULONG NumberOfBytes) +ExAllocatePool (POOL_TYPE PoolType, SIZE_T NumberOfBytes) /* * FUNCTION: Allocates pool memory of a specified type and returns a pointer * to the allocated block. This routine is used for general purpose allocation @@ -141,7 +141,7 @@ ExAllocatePool (POOL_TYPE PoolType, ULONG NumberOfBytes) * @implemented */ PVOID NTAPI -ExAllocatePoolWithTag (POOL_TYPE PoolType, ULONG NumberOfBytes, ULONG Tag) +ExAllocatePoolWithTag (POOL_TYPE PoolType, SIZE_T NumberOfBytes, ULONG Tag) { PVOID Block; diff --git a/reactos/ntoskrnl/mm/region.c b/reactos/ntoskrnl/mm/region.c index 66a896597e4..9c79738b036 100644 --- a/reactos/ntoskrnl/mm/region.c +++ b/reactos/ntoskrnl/mm/region.c @@ -238,7 +238,7 @@ MmAlterRegion(PMMSUPPORT AddressSpace, PVOID BaseAddress, VOID NTAPI -MmInitializeRegion(PLIST_ENTRY RegionListHead, ULONG Length, ULONG Type, +MmInitializeRegion(PLIST_ENTRY RegionListHead, SIZE_T Length, ULONG Type, ULONG Protect) { PMM_REGION Region; diff --git a/reactos/ntoskrnl/mm/rpoolmgr.h b/reactos/ntoskrnl/mm/rpoolmgr.h index 8ca10998c5c..f72cdb366bf 100644 --- a/reactos/ntoskrnl/mm/rpoolmgr.h +++ b/reactos/ntoskrnl/mm/rpoolmgr.h @@ -12,7 +12,7 @@ typedef unsigned long rulong; -#define R_IS_POOL_PTR(pool,ptr) (void*)(ptr) >= pool->UserBase && (ULONG_PTR)(ptr) < ((ULONG_PTR)pool->UserBase + pool->UserSize) +#define R_IS_POOL_PTR(pool,ptr) (((void*)(ULONG_PTR)(ptr) >= pool->UserBase) && ((ULONG_PTR)(ptr) < ((ULONG_PTR)pool->UserBase + pool->UserSize))) #define R_ASSERT_PTR(pool,ptr) ASSERT( R_IS_POOL_PTR(pool,ptr) ) #define R_ASSERT_SIZE(pool,sz) ASSERT( sz > (sizeof(R_USED)+2*R_RZ) && sz >= sizeof(R_FREE) && sz < pool->UserSize ) @@ -712,7 +712,7 @@ RPoolAlloc ( PR_POOL pool, rulong NumberOfBytes, rulong Tag, rulong align ) if ( R_IS_POOL_PTR(pool,NumberOfBytes) ) { R_DEBUG("red zone verification requested for block 0x%X\n", NumberOfBytes ); - RUsedRedZoneCheck(pool,RBodyToHdr((void*)NumberOfBytes), (char*)NumberOfBytes, __FILE__, __LINE__ ); + RUsedRedZoneCheck(pool,RBodyToHdr((void*)(ULONG_PTR)NumberOfBytes), (char*)(ULONG_PTR)NumberOfBytes, __FILE__, __LINE__ ); R_RELEASE_MUTEX(pool); return NULL; } diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index d49cb0966d6..30c71b2ecf9 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -2472,6 +2472,7 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, LARGE_INTEGER Offset; CHAR Buffer; FILE_STANDARD_INFORMATION FileInfo; + ULONG Length; /* * Create the section @@ -2534,7 +2535,8 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject, FileStandardInformation, sizeof(FILE_STANDARD_INFORMATION), &FileInfo, - &Iosb.Information); + &Length); + Iosb.Information = Length; if (!NT_SUCCESS(Status)) { ObDereferenceObject(Section); @@ -4294,8 +4296,8 @@ NTSTATUS NTAPI NtQuerySection(IN HANDLE SectionHandle, IN SECTION_INFORMATION_CLASS SectionInformationClass, OUT PVOID SectionInformation, - IN ULONG SectionInformationLength, - OUT PULONG ResultLength OPTIONAL) + IN SIZE_T SectionInformationLength, + OUT PSIZE_T ResultLength OPTIONAL) { PROS_SECTION_OBJECT Section; KPROCESSOR_MODE PreviousMode; @@ -4874,7 +4876,7 @@ MmForceSectionClosed ( NTSTATUS NTAPI MmMapViewInSystemSpace (IN PVOID SectionObject, OUT PVOID * MappedBase, - IN OUT PULONG ViewSize) + IN OUT PSIZE_T ViewSize) { PROS_SECTION_OBJECT Section; PMMSUPPORT AddressSpace; diff --git a/reactos/ntoskrnl/mm/sysldr.c b/reactos/ntoskrnl/mm/sysldr.c index 3f644261f81..3c6946d6b1b 100644 --- a/reactos/ntoskrnl/mm/sysldr.c +++ b/reactos/ntoskrnl/mm/sysldr.c @@ -704,7 +704,7 @@ MiSnapThunk(IN PVOID DllBase, ForwardName->Hint = 0; /* Set the new address */ - *(PULONG)&ForwardThunk.u1.AddressOfData = (ULONG)ForwardName; + ForwardThunk.u1.AddressOfData = (ULONG_PTR)ForwardName; /* Snap the forwarder */ Status = MiSnapThunk(LdrEntry->DllBase,