- Fix a number of MSVC/64 bit warnings/problems
- Fix return type of RtlpInitializeHeapSegment (by Roel)

svn path=/trunk/; revision=53764
This commit is contained in:
Timo Kreuzer 2011-09-19 19:31:21 +00:00
parent 54f8ab351c
commit 78f25bbeea
9 changed files with 75 additions and 74 deletions

View file

@ -299,7 +299,7 @@ VOID
NTAPI
RtlpFreeDebugInfo(PRTL_CRITICAL_SECTION_DEBUG DebugInfo)
{
ULONG EntryId;
SIZE_T EntryId;
/* Is it part of our cached entries? */
if ((DebugInfo >= RtlpStaticDebugInfo) &&
@ -310,7 +310,7 @@ RtlpFreeDebugInfo(PRTL_CRITICAL_SECTION_DEBUG DebugInfo)
/* Mark as free */
EntryId = (DebugInfo - RtlpStaticDebugInfo);
DPRINT("Freeing from Buffer: %p. Entry: %lu inside Process: %p\n",
DPRINT("Freeing from Buffer: %p. Entry: %Iu inside Process: %p\n",
DebugInfo,
EntryId,
NtCurrentTeb()->ClientId.UniqueProcess);

View file

@ -126,7 +126,7 @@ RtlpInitializeHeap(OUT PHEAP Heap,
ASSERT(HeaderSize <= PAGE_SIZE);
/* Initialise the Heap Entry header containing the Heap header */
Heap->Entry.Size = HeaderSize >> HEAP_ENTRY_SHIFT;
Heap->Entry.Size = (USHORT)(HeaderSize >> HEAP_ENTRY_SHIFT);
Heap->Entry.Flags = HEAP_ENTRY_BUSY;
Heap->Entry.SmallTagIndex = LOBYTE(Heap->Entry.Size) ^ HIBYTE(Heap->Entry.Size) ^ Heap->Entry.Flags;
Heap->Entry.PreviousSize = 0;
@ -157,7 +157,7 @@ RtlpInitializeHeap(OUT PHEAP Heap,
/* Initialise the Heap validation info */
Heap->HeaderValidateCopy = NULL;
Heap->HeaderValidateLength = HeaderSize;
Heap->HeaderValidateLength = (USHORT)HeaderSize;
/* Initialise the Heap Lock */
if (!(Flags & HEAP_NO_SERIALIZE) && !(Flags & HEAP_LOCK_USER_ALLOCATED))
@ -656,7 +656,7 @@ RtlpFindAndCommitPages(PHEAP Heap,
}
/* Update tracking numbers */
Segment->NumberOfUnCommittedPages -= *Size / PAGE_SIZE;
Segment->NumberOfUnCommittedPages -= (ULONG)(*Size / PAGE_SIZE);
/* Calculate first and last entries */
FirstEntry = (PHEAP_ENTRY)Address;
@ -738,7 +738,7 @@ RtlpDeCommitFreeBlock(PHEAP Heap,
PHEAP_ENTRY PrecedingInUseEntry = NULL, NextInUseEntry = NULL;
PHEAP_FREE_ENTRY NextFreeEntry;
PHEAP_UCR_DESCRIPTOR UcrDescriptor;
ULONG PrecedingSize, NextSize, DecommitSize;
SIZE_T PrecedingSize, NextSize, DecommitSize;
ULONG_PTR DecommitBase;
NTSTATUS Status;
@ -828,7 +828,7 @@ RtlpDeCommitFreeBlock(PHEAP Heap,
/* Insert uncommitted pages */
RtlpInsertUnCommittedPages(Segment, DecommitBase, DecommitSize);
Segment->NumberOfUnCommittedPages += (DecommitSize / PAGE_SIZE);
Segment->NumberOfUnCommittedPages += (ULONG)(DecommitSize / PAGE_SIZE);
if (PrecedingSize)
{
@ -866,7 +866,8 @@ RtlpDeCommitFreeBlock(PHEAP Heap,
}
}
BOOLEAN NTAPI
NTSTATUS
NTAPI
RtlpInitializeHeapSegment(IN OUT PHEAP Heap,
OUT PHEAP_SEGMENT Segment,
IN UCHAR SegmentIndex,
@ -908,7 +909,7 @@ RtlpInitializeHeapSegment(IN OUT PHEAP Heap,
/* Initialise the Heap Segment location information */
Segment->BaseAddress = Segment;
Segment->NumberOfPages = SegmentReserve >> PAGE_SHIFT;
Segment->NumberOfPages = (ULONG)(SegmentReserve >> PAGE_SHIFT);
/* Initialise the Heap Entries contained within the Heap Segment */
Segment->FirstEntry = &Segment->Entry + Segment->Entry.Size;
@ -928,7 +929,7 @@ RtlpInitializeHeapSegment(IN OUT PHEAP Heap,
}
/* Initialise the Heap Segment UnCommitted Range information */
Segment->NumberOfUnCommittedPages = (SegmentReserve - SegmentCommit) >> PAGE_SHIFT;
Segment->NumberOfUnCommittedPages = (ULONG)((SegmentReserve - SegmentCommit) >> PAGE_SHIFT);
Segment->NumberOfUnCommittedRanges = 0;
InitializeListHead(&Segment->UCRSegmentList);
@ -1162,7 +1163,7 @@ RtlpExtendHeap(PHEAP Heap,
DPRINT("RtlpExtendHeap(%p %x)\n", Heap, Size);
/* Calculate amount in pages */
Pages = (Size + PAGE_SIZE - 1) / PAGE_SIZE;
Pages = (ULONG)((Size + PAGE_SIZE - 1) / PAGE_SIZE);
FreeSize = Pages * PAGE_SIZE;
DPRINT("Pages %x, FreeSize %x. Going through segments...\n", Pages, FreeSize);
@ -1998,11 +1999,10 @@ RtlAllocateHeap(IN PVOID HeapPtr,
PULONG FreeListsInUse;
ULONG FreeListsInUseUlong;
SIZE_T AllocationSize;
SIZE_T Index;
SIZE_T Index, InUseIndex, i;
PLIST_ENTRY FreeListHead;
PHEAP_ENTRY InUseEntry;
PHEAP_FREE_ENTRY FreeBlock;
ULONG InUseIndex, i;
UCHAR FreeFlags;
EXCEPTION_RECORD ExceptionRecord;
BOOLEAN HeapLocked = FALSE;
@ -3390,7 +3390,7 @@ RtlpValidateHeapSegment(
}
else
{
UnCommittedPages += (UcrDescriptor->Size / PAGE_SIZE);
UnCommittedPages += (ULONG)(UcrDescriptor->Size / PAGE_SIZE);
UnCommittedRanges++;
CurrentEntry = (PHEAP_ENTRY)((PCHAR)UcrDescriptor->Address + UcrDescriptor->Size);

View file

@ -151,15 +151,15 @@ typedef struct _HEAP_PSEUDO_TAG_ENTRY
{
ULONG Allocs;
ULONG Frees;
ULONG Size;
SIZE_T Size;
} HEAP_PSEUDO_TAG_ENTRY, *PHEAP_PSEUDO_TAG_ENTRY;
typedef struct _HEAP_COUNTERS
{
ULONG TotalMemoryReserved;
ULONG TotalMemoryCommitted;
ULONG TotalMemoryLargeUCR;
ULONG TotalSizeInVirtualBlocks;
SIZE_T TotalMemoryReserved;
SIZE_T TotalMemoryCommitted;
SIZE_T TotalMemoryLargeUCR;
SIZE_T TotalSizeInVirtualBlocks;
ULONG TotalSegments;
ULONG TotalUCRs;
ULONG CommittOps;
@ -173,13 +173,13 @@ typedef struct _HEAP_COUNTERS
ULONG CompactHeapCalls;
ULONG CompactedUCRs;
ULONG InBlockDeccommits;
ULONG InBlockDeccomitSize;
SIZE_T InBlockDeccomitSize;
} HEAP_COUNTERS, *PHEAP_COUNTERS;
typedef struct _HEAP_TUNING_PARAMETERS
{
ULONG CommittThresholdShift;
ULONG MaxPreCommittThreshold;
SIZE_T MaxPreCommittThreshold;
} HEAP_TUNING_PARAMETERS, *PHEAP_TUNING_PARAMETERS;
typedef struct _HEAP_LIST_LOOKUP
@ -217,16 +217,16 @@ typedef struct _HEAP
ULONG CompatibilityFlags;
ULONG EncodeFlagMask;
HEAP_ENTRY Encoding;
ULONG PointerKey;
ULONG_PTR PointerKey;
ULONG Interceptor;
ULONG VirtualMemoryThreshold;
ULONG Signature;
ULONG SegmentReserve;
ULONG SegmentCommit;
ULONG DeCommitFreeBlockThreshold;
ULONG DeCommitTotalFreeThreshold;
ULONG TotalFreeSize;
ULONG MaximumAllocationSize;
SIZE_T SegmentReserve;
SIZE_T SegmentCommit;
SIZE_T DeCommitFreeBlockThreshold;
SIZE_T DeCommitTotalFreeThreshold;
SIZE_T TotalFreeSize;
SIZE_T MaximumAllocationSize;
USHORT ProcessHeapsListIndex;
USHORT HeaderValidateLength;
PVOID HeaderValidateCopy;
@ -235,8 +235,8 @@ typedef struct _HEAP
PHEAP_TAG_ENTRY TagEntries;
LIST_ENTRY UCRList;
LIST_ENTRY UCRSegments; // FIXME: non-Vista
ULONG AlignRound;
ULONG AlignMask;
ULONG_PTR AlignRound;
ULONG_PTR AlignMask;
LIST_ENTRY VirtualAllocdBlocks;
LIST_ENTRY SegmentList;
struct _HEAP_SEGMENT *Segments[HEAP_SEGMENTS]; //FIXME: non-Vista
@ -284,7 +284,7 @@ typedef struct _HEAP_UCR_DESCRIPTOR
LIST_ENTRY ListEntry;
LIST_ENTRY SegmentEntry;
PVOID Address;
ULONG Size;
SIZE_T Size;
} HEAP_UCR_DESCRIPTOR, *PHEAP_UCR_DESCRIPTOR;
typedef struct _HEAP_UCR_SEGMENT
@ -314,8 +314,8 @@ typedef struct _HEAP_VIRTUAL_ALLOC_ENTRY
{
LIST_ENTRY Entry;
HEAP_ENTRY_EXTRA ExtraStuff;
ULONG CommitSize;
ULONG ReserveSize;
SIZE_T CommitSize;
SIZE_T ReserveSize;
HEAP_ENTRY BusyBlock;
} HEAP_VIRTUAL_ALLOC_ENTRY, *PHEAP_VIRTUAL_ALLOC_ENTRY;

View file

@ -24,8 +24,8 @@ typedef struct _DPH_BLOCK_INFORMATION
{
ULONG StartStamp;
PVOID Heap;
ULONG RequestedSize;
ULONG ActualSize;
SIZE_T RequestedSize;
SIZE_T ActualSize;
union
{
LIST_ENTRY FreeQueue;
@ -46,10 +46,10 @@ typedef struct _DPH_HEAP_BLOCK
};
PUCHAR pUserAllocation;
PUCHAR pVirtualBlock;
ULONG nVirtualBlockSize;
ULONG nVirtualAccessSize;
ULONG nUserRequestedSize;
ULONG nUserActualSize;
SIZE_T nVirtualBlockSize;
SIZE_T nVirtualAccessSize;
SIZE_T nUserRequestedSize;
SIZE_T nUserActualSize;
PVOID UserValue;
ULONG UserFlags;
PRTL_TRACE_BLOCK StackTrace;
@ -67,30 +67,30 @@ typedef struct _DPH_HEAP_ROOT
PDPH_HEAP_BLOCK pVirtualStorageListHead;
PDPH_HEAP_BLOCK pVirtualStorageListTail;
ULONG nVirtualStorageRanges;
ULONG nVirtualStorageBytes;
SIZE_T nVirtualStorageBytes;
RTL_AVL_TABLE BusyNodesTable;
PDPH_HEAP_BLOCK NodeToAllocate;
ULONG nBusyAllocations;
ULONG nBusyAllocationBytesCommitted;
SIZE_T nBusyAllocationBytesCommitted;
PDPH_HEAP_BLOCK pFreeAllocationListHead;
PDPH_HEAP_BLOCK pFreeAllocationListTail;
ULONG nFreeAllocations;
ULONG nFreeAllocationBytesCommitted;
SIZE_T nFreeAllocationBytesCommitted;
LIST_ENTRY AvailableAllocationHead;
ULONG nAvailableAllocations;
ULONG nAvailableAllocationBytesCommitted;
SIZE_T nAvailableAllocationBytesCommitted;
PDPH_HEAP_BLOCK pUnusedNodeListHead;
PDPH_HEAP_BLOCK pUnusedNodeListTail;
ULONG nUnusedNodes;
ULONG nBusyAllocationBytesAccessible;
SIZE_T nBusyAllocationBytesAccessible;
PDPH_HEAP_BLOCK pNodePoolListHead;
PDPH_HEAP_BLOCK pNodePoolListTail;
ULONG nNodePools;
ULONG nNodePoolBytes;
SIZE_T nNodePoolBytes;
LIST_ENTRY NextHeap;
ULONG ExtraFlags;
@ -117,7 +117,7 @@ UNICODE_STRING RtlpDphTargetDllsUnicode;
RTL_CRITICAL_SECTION RtlpDphDelayedFreeQueueLock;
LIST_ENTRY RtlpDphDelayedFreeQueue;
SLIST_HEADER RtlpDphDelayedTemporaryPushList;
ULONG RtlpDphMemoryUsedByDelayedFreeBlocks;
SIZE_T RtlpDphMemoryUsedByDelayedFreeBlocks;
ULONG RtlpDphNumberOfDelayedFreeBlocks;
/* Counters */
@ -429,7 +429,7 @@ RtlpDphWritePageHeapBlockInformation(PDPH_HEAP_ROOT DphRoot, PVOID UserAllocatio
RtlFillMemory(FillPtr, ROUND_UP(FillPtr, PAGE_SIZE) - (ULONG_PTR)FillPtr, DPH_FILL_SUFFIX);
/* FIXME: Check if logging stack traces is turned on */
//if (DphRoot->ExtraFlags &
//if (DphRoot->ExtraFlags &
return TRUE;
}
@ -758,7 +758,7 @@ RtlpDphAddNewPool(PDPH_HEAP_ROOT DphRoot, PDPH_HEAP_BLOCK NodeBlock, PVOID Virtu
ULONG NodeCount, i;
//NodeCount = (Size >> 6) - 1;
NodeCount = (Size / sizeof(DPH_HEAP_BLOCK));
NodeCount = (ULONG)(Size / sizeof(DPH_HEAP_BLOCK));
DphStartNode = Virtual;
/* Set pNextAlloc for all blocks */
@ -1903,7 +1903,8 @@ RtlpPageHeapReAllocate(HANDLE HeapPtr,
PDPH_HEAP_ROOT DphRoot;
PDPH_HEAP_BLOCK Node = NULL, AllocatedNode;
BOOLEAN Biased = FALSE, UseNormalHeap = FALSE, OldBlockPageHeap = TRUE;
ULONG DataSize, ValidationInfo;
ULONG ValidationInfo;
SIZE_T DataSize;
PVOID NewAlloc = NULL;
/* Check requested size */

View file

@ -116,8 +116,9 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
IN PVOID Context,
IN PVOID Environment)
{
ULONG InfoLength, Length, c;
LONG RequiredLength, SpareLength;
ULONG InfoLength;
SIZE_T Length, SpareLength, c;
LONG RequiredLength;
PCHAR SpareData, DataEnd;
ULONG Type;
PWCHAR Name, p, ValueEnd;
@ -207,7 +208,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
if (SpareLength < RequiredLength)
{
/* Fail and return the missing length */
*InfoSize = SpareData - (PCHAR)KeyValueInfo + RequiredLength;
*InfoSize = (ULONG)(SpareData - (PCHAR)KeyValueInfo) + RequiredLength;
return STATUS_BUFFER_TOO_SMALL;
}
@ -257,7 +258,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
/* Do the query */
Status = RtlpQueryRegistryDirect(REG_SZ,
Data,
Length,
(ULONG)Length,
QueryTable->EntryContext);
QueryTable->EntryContext = (PVOID)((ULONG_PTR)QueryTable->
EntryContext +
@ -269,7 +270,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
Status = QueryTable->QueryRoutine(Name,
REG_SZ,
Data,
Length,
(ULONG)Length,
Context,
QueryTable->EntryContext);
}
@ -311,7 +312,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
if (FoundExpander)
{
/* Setup the source string */
RtlInitEmptyUnicodeString(&Source, Data, Length);
RtlInitEmptyUnicodeString(&Source, Data, (USHORT)Length);
Source.Length = Source.MaximumLength - sizeof(UNICODE_NULL);
/* Setup the desination string */
@ -326,7 +327,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
else if (SpareLength <= MAXUSHORT)
{
/* This is the good case, where we fit into a string */
Destination.MaximumLength = SpareLength;
Destination.MaximumLength = (USHORT)SpareLength;
Destination.Buffer[SpareLength / 2 - 1] = UNICODE_NULL;
}
else
@ -356,9 +357,8 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
if (Status == STATUS_BUFFER_TOO_SMALL)
{
/* Set the required missing length */
*InfoSize = SpareData -
(PCHAR)KeyValueInfo +
RequiredLength;
*InfoSize = (ULONG)(SpareData - (PCHAR)KeyValueInfo) +
RequiredLength;
/* Notify debugger */
DPRINT1("RTL: Expand variables for %wZ failed - "
@ -391,7 +391,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
/* Return the data */
Status = RtlpQueryRegistryDirect(Type,
Data,
Length,
(ULONG)Length,
QueryTable->EntryContext);
}
else
@ -400,7 +400,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
Status = QueryTable->QueryRoutine(Name,
Type,
Data,
Length,
(ULONG)Length,
Context,
QueryTable->EntryContext);
}
@ -756,7 +756,7 @@ RtlFormatCurrentUserKeyPath(OUT PUNICODE_STRING KeyPath)
/* Initialize a string */
RtlInitEmptyUnicodeString(KeyPath,
RtlpAllocateStringMemory(Length, TAG_USTR),
Length);
(USHORT)Length);
if (!KeyPath->Buffer)
{
/* Free the string and fail */
@ -840,7 +840,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle,
if (KeyInfo->NameLength <= SubKeyName->MaximumLength)
{
/* Set the length */
SubKeyName->Length = KeyInfo->NameLength;
SubKeyName->Length = (USHORT)KeyInfo->NameLength;
/* Copy it */
RtlMoveMemory(SubKeyName->Buffer,
@ -1094,7 +1094,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
&KeyValueName,
KeyValueFullInformation,
KeyValueInfo,
InfoSize,
(ULONG)InfoSize,
&ResultLength);
if (Status == STATUS_BUFFER_OVERFLOW)
{
@ -1111,7 +1111,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
/* Setup a default */
KeyValueInfo->Type = REG_NONE;
KeyValueInfo->DataLength = 0;
ResultLength = InfoSize;
ResultLength = (ULONG)InfoSize;
/* Call the query routine */
Status = RtlpCallQueryRegistryRoutine(QueryTable,
@ -1151,7 +1151,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
}
/* Call the query routine */
ResultLength = InfoSize;
ResultLength = (ULONG)InfoSize;
Status = RtlpCallQueryRegistryRoutine(QueryTable,
KeyValueInfo,
&ResultLength,
@ -1212,7 +1212,7 @@ ProcessValues:
Value,
KeyValueFullInformation,
KeyValueInfo,
InfoSize,
(ULONG)InfoSize,
&ResultLength);
if (Status == STATUS_BUFFER_OVERFLOW)
{
@ -1242,7 +1242,7 @@ ProcessValues:
if (NT_SUCCESS(Status))
{
/* Call the query routine */
ResultLength = InfoSize;
ResultLength = (ULONG)InfoSize;
Status = RtlpCallQueryRegistryRoutine(QueryTable,
KeyValueInfo,
&ResultLength,

View file

@ -63,7 +63,7 @@ typedef struct _DISPATCHER_CONTEXT
PVOID
NTAPI
RtlpAllocateMemory(
ULONG Bytes,
SIZE_T Bytes,
ULONG Tag);
VOID

View file

@ -630,7 +630,7 @@ RtlAcquireSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock)
/* There are no wait blocks so far, we need to add ourselves as the first
wait block. We need to keep the shared count! */
StackWaitBlock.Exclusive = TRUE;
StackWaitBlock.SharedCount = CurrentValue >> RTL_SRWLOCK_BITS;
StackWaitBlock.SharedCount = (LONG)(CurrentValue >> RTL_SRWLOCK_BITS);
StackWaitBlock.Next = NULL;
StackWaitBlock.Last = &StackWaitBlock;
StackWaitBlock.Wake = 0;

View file

@ -193,7 +193,7 @@ static ULONG queue_get_timeout(struct timer_queue *q)
if (t->expire != EXPIRE_NEVER)
{
ULONGLONG time = queue_current_time();
timeout = t->expire < time ? 0 : t->expire - time;
timeout = t->expire < time ? 0 : (ULONG)(t->expire - time);
}
}
RtlLeaveCriticalSection(&q->cs);

View file

@ -85,7 +85,7 @@ RtlQueryTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
NTSTATUS NTAPI
RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
{
ULONG Length;
SIZE_T Length;
NTSTATUS Status;
DPRINT("RtlSetTimeZoneInformation()\n");
@ -109,7 +109,7 @@ RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
L"Standard Name",
REG_SZ,
TimeZoneInformation->StandardName,
Length);
(ULONG)Length);
if (!NT_SUCCESS(Status))
{
return Status;
@ -143,7 +143,7 @@ RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
L"Daylight Name",
REG_SZ,
TimeZoneInformation->DaylightName,
Length);
(ULONG)Length);
if (!NT_SUCCESS(Status))
{
return Status;