Merge from amd64 branch:
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 6 Dec 2009 03:24:18 +0000 (03:24 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 6 Dec 2009 03:24:18 +0000 (03:24 +0000)
- 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
reactos/ntoskrnl/mm/pool.c
reactos/ntoskrnl/mm/region.c
reactos/ntoskrnl/mm/rpoolmgr.h
reactos/ntoskrnl/mm/section.c
reactos/ntoskrnl/mm/sysldr.c

index bab8e96..84c1e66 100644 (file)
@@ -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)
index 73fdbe2..07132e8 100644 (file)
@@ -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;
 
index 66a8965..9c79738 100644 (file)
@@ -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;
index 8ca1099..f72cdb3 100644 (file)
@@ -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;
                }
index d49cb09..30c71b2 100644 (file)
@@ -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;
index 3f64426..3c6946d 100644 (file)
@@ -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,