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:
parent
20769e6ee0
commit
d36833b139
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-Wall -pedantic -g -DUNIX_HOST
|
CFLAGS=-Wall -pedantic -g -DUNIX_HOST -DDEBUG_HEAP
|
||||||
LIBS=#-lm
|
LIBS=#-lm
|
||||||
|
|
||||||
TARGET = picoc
|
TARGET = picoc
|
||||||
|
|
|
@ -138,7 +138,7 @@ int ExpressionCoerceInteger(struct Value *Val)
|
||||||
case TypeShort: return (int)Val->Val->ShortInteger;
|
case TypeShort: return (int)Val->Val->ShortInteger;
|
||||||
case TypeUnsignedInt: return (int)Val->Val->UnsignedInteger;
|
case TypeUnsignedInt: return (int)Val->Val->UnsignedInteger;
|
||||||
case TypeUnsignedShort: return (int)Val->Val->UnsignedShortInteger;
|
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
|
#ifndef NO_FP
|
||||||
case TypeFP: return (int)Val->Val->FP;
|
case TypeFP: return (int)Val->Val->FP;
|
||||||
#endif
|
#endif
|
||||||
|
@ -155,7 +155,7 @@ unsigned int ExpressionCoerceUnsignedInteger(struct Value *Val)
|
||||||
case TypeShort: return (unsigned int)Val->Val->ShortInteger;
|
case TypeShort: return (unsigned int)Val->Val->ShortInteger;
|
||||||
case TypeUnsignedInt: return (unsigned int)Val->Val->UnsignedInteger;
|
case TypeUnsignedInt: return (unsigned int)Val->Val->UnsignedInteger;
|
||||||
case TypeUnsignedShort: return (unsigned int)Val->Val->UnsignedShortInteger;
|
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
|
#ifndef NO_FP
|
||||||
case TypeFP: return (unsigned int)Val->Val->FP;
|
case TypeFP: return (unsigned int)Val->Val->FP;
|
||||||
#endif
|
#endif
|
||||||
|
@ -309,7 +309,7 @@ void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
|
||||||
else if (AllowPointerCoercion && IS_NUMERIC_COERCIBLE(FromValue))
|
else if (AllowPointerCoercion && IS_NUMERIC_COERCIBLE(FromValue))
|
||||||
{
|
{
|
||||||
/* assign integer to native pointer */
|
/* assign integer to native pointer */
|
||||||
ToValue->Val->NativePointer = (void *)ExpressionCoerceUnsignedInteger(FromValue);
|
ToValue->Val->NativePointer = (void *)(unsigned long)ExpressionCoerceUnsignedInteger(FromValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AssignFail(Parser, "%t from %t", ToValue->Typ, FromValue->Typ, 0, 0, FuncName, ParamNo);
|
AssignFail(Parser, "%t from %t", ToValue->Typ, FromValue->Typ, 0, 0, FuncName, ParamNo);
|
||||||
|
|
11
heap.c
11
heap.c
|
@ -56,7 +56,7 @@ void *HeapAllocStack(int Size)
|
||||||
char *NewMem = HeapStackTop;
|
char *NewMem = HeapStackTop;
|
||||||
char *NewTop = (char *)HeapStackTop + MEM_ALIGN(Size);
|
char *NewTop = (char *)HeapStackTop + MEM_ALIGN(Size);
|
||||||
#ifdef DEBUG_HEAP
|
#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
|
#endif
|
||||||
if (NewTop > (char *)HeapBottom)
|
if (NewTop > (char *)HeapBottom)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -70,7 +70,7 @@ void *HeapAllocStack(int Size)
|
||||||
void HeapUnpopStack(int Size)
|
void HeapUnpopStack(int Size)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_HEAP
|
#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
|
#endif
|
||||||
HeapStackTop = (void *)((char *)HeapStackTop + MEM_ALIGN(Size));
|
HeapStackTop = (void *)((char *)HeapStackTop + MEM_ALIGN(Size));
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ int HeapPopStack(void *Addr, int Size)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#ifdef DEBUG_HEAP
|
#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
|
#endif
|
||||||
HeapStackTop = (void *)((char *)HeapStackTop - ToLose);
|
HeapStackTop = (void *)((char *)HeapStackTop - ToLose);
|
||||||
assert(HeapStackTop == Addr);
|
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 */
|
/* couldn't allocate from a freelist - try to increase the size of the heap area */
|
||||||
#ifdef DEBUG_HEAP
|
#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
|
#endif
|
||||||
if ((char *)HeapBottom - AllocSize < (char *)HeapStackTop)
|
if ((char *)HeapBottom - AllocSize < (char *)HeapStackTop)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -218,6 +218,9 @@ void HeapFreeMem(void *Mem)
|
||||||
struct AllocNode *MemNode = (struct AllocNode *)((char *)Mem - MEM_ALIGN(sizeof(MemNode->Size)));
|
struct AllocNode *MemNode = (struct AllocNode *)((char *)Mem - MEM_ALIGN(sizeof(MemNode->Size)));
|
||||||
int Bucket = MemNode->Size >> 2;
|
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((unsigned long)Mem >= (unsigned long)&HeapMemory[0] && (unsigned char *)Mem - &HeapMemory[0] < HEAP_SIZE);
|
||||||
assert(MemNode->Size < HEAP_SIZE && MemNode->Size > 0);
|
assert(MemNode->Size < HEAP_SIZE && MemNode->Size > 0);
|
||||||
if (Mem == NULL)
|
if (Mem == NULL)
|
||||||
|
|
|
@ -201,7 +201,7 @@ void VariableStackPop(struct ParseState *Parser, struct Value *Var)
|
||||||
|
|
||||||
#ifdef DEBUG_HEAP
|
#ifdef DEBUG_HEAP
|
||||||
if (Var->ValOnStack)
|
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
|
#endif
|
||||||
|
|
||||||
if (Var->ValOnHeap)
|
if (Var->ValOnHeap)
|
||||||
|
|
Loading…
Reference in a new issue