Fixed some warnings for 64 bit architectures

git-svn-id: http://picoc.googlecode.com/svn/trunk@380 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-11-06 18:17:36 +00:00
parent 20769e6ee0
commit d36833b139
4 changed files with 12 additions and 9 deletions

View file

@ -1,5 +1,5 @@
CC=gcc
CFLAGS=-Wall -pedantic -g -DUNIX_HOST
CFLAGS=-Wall -pedantic -g -DUNIX_HOST -DDEBUG_HEAP
LIBS=#-lm
TARGET = picoc

View file

@ -138,7 +138,7 @@ int ExpressionCoerceInteger(struct Value *Val)
case TypeShort: return (int)Val->Val->ShortInteger;
case TypeUnsignedInt: return (int)Val->Val->UnsignedInteger;
case TypeUnsignedShort: return (int)Val->Val->UnsignedShortInteger;
case TypePointer: return (int)Val->Val->NativePointer;
case TypePointer: return (int)(unsigned long)Val->Val->NativePointer;
#ifndef NO_FP
case TypeFP: return (int)Val->Val->FP;
#endif
@ -155,7 +155,7 @@ unsigned int ExpressionCoerceUnsignedInteger(struct Value *Val)
case TypeShort: return (unsigned int)Val->Val->ShortInteger;
case TypeUnsignedInt: return (unsigned int)Val->Val->UnsignedInteger;
case TypeUnsignedShort: return (unsigned int)Val->Val->UnsignedShortInteger;
case TypePointer: return (unsigned int)Val->Val->NativePointer;
case TypePointer: return (unsigned int)(unsigned long)Val->Val->NativePointer;
#ifndef NO_FP
case TypeFP: return (unsigned int)Val->Val->FP;
#endif
@ -309,7 +309,7 @@ void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
else if (AllowPointerCoercion && IS_NUMERIC_COERCIBLE(FromValue))
{
/* assign integer to native pointer */
ToValue->Val->NativePointer = (void *)ExpressionCoerceUnsignedInteger(FromValue);
ToValue->Val->NativePointer = (void *)(unsigned long)ExpressionCoerceUnsignedInteger(FromValue);
}
else
AssignFail(Parser, "%t from %t", ToValue->Typ, FromValue->Typ, 0, 0, FuncName, ParamNo);

11
heap.c
View file

@ -56,7 +56,7 @@ void *HeapAllocStack(int Size)
char *NewMem = HeapStackTop;
char *NewTop = (char *)HeapStackTop + MEM_ALIGN(Size);
#ifdef DEBUG_HEAP
printf("HeapAllocStack(%d) at 0x%lx\n", MEM_ALIGN(Size), (unsigned long)HeapStackTop);
printf("HeapAllocStack(%ld) at 0x%lx\n", (unsigned long)MEM_ALIGN(Size), (unsigned long)HeapStackTop);
#endif
if (NewTop > (char *)HeapBottom)
return NULL;
@ -70,7 +70,7 @@ void *HeapAllocStack(int Size)
void HeapUnpopStack(int Size)
{
#ifdef DEBUG_HEAP
printf("HeapUnpopStack(%d) at 0x%lx\n", MEM_ALIGN(Size), (unsigned long)HeapStackTop);
printf("HeapUnpopStack(%ld) at 0x%lx\n", (unsigned long)MEM_ALIGN(Size), (unsigned long)HeapStackTop);
#endif
HeapStackTop = (void *)((char *)HeapStackTop + MEM_ALIGN(Size));
}
@ -83,7 +83,7 @@ int HeapPopStack(void *Addr, int Size)
return FALSE;
#ifdef DEBUG_HEAP
printf("HeapPopStack(0x%lx, %d) back to 0x%lx\n", (unsigned long)Addr, MEM_ALIGN(Size), (unsigned long)HeapStackTop - ToLose);
printf("HeapPopStack(0x%lx, %ld) back to 0x%lx\n", (unsigned long)Addr, (unsigned long)MEM_ALIGN(Size), (unsigned long)HeapStackTop - ToLose);
#endif
HeapStackTop = (void *)((char *)HeapStackTop - ToLose);
assert(HeapStackTop == Addr);
@ -190,7 +190,7 @@ void *HeapAllocMem(int Size)
{
/* couldn't allocate from a freelist - try to increase the size of the heap area */
#ifdef DEBUG_HEAP
printf("allocating %d(%d) at bottom of heap (0x%lx-0x%lx)", Size, AllocSize, (long)(HeapBottom - AllocSize), (long)HeapBottom);
printf("allocating %d(%d) at bottom of heap (0x%lx-0x%lx)", Size, AllocSize, (long)((char *)HeapBottom - AllocSize), (long)HeapBottom);
#endif
if ((char *)HeapBottom - AllocSize < (char *)HeapStackTop)
return NULL;
@ -218,6 +218,9 @@ void HeapFreeMem(void *Mem)
struct AllocNode *MemNode = (struct AllocNode *)((char *)Mem - MEM_ALIGN(sizeof(MemNode->Size)));
int Bucket = MemNode->Size >> 2;
#ifdef DEBUG_HEAP
printf("HeapFreeMem(%lx)\n", (unsigned long)Mem);
#endif
assert((unsigned long)Mem >= (unsigned long)&HeapMemory[0] && (unsigned char *)Mem - &HeapMemory[0] < HEAP_SIZE);
assert(MemNode->Size < HEAP_SIZE && MemNode->Size > 0);
if (Mem == NULL)

View file

@ -201,7 +201,7 @@ void VariableStackPop(struct ParseState *Parser, struct Value *Var)
#ifdef DEBUG_HEAP
if (Var->ValOnStack)
printf("popping %d at 0x%lx\n", sizeof(struct Value) + VariableSizeValue(Var), (unsigned long)Var);
printf("popping %ld at 0x%lx\n", (unsigned long)(sizeof(struct Value) + TypeSizeValue(Var)), (unsigned long)Var);
#endif
if (Var->ValOnHeap)