From e077cc9d49018072b0c34b7b87210ed589738777 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Sat, 7 Nov 2009 15:17:53 +0000 Subject: [PATCH] Fixed UltraSPARC II bus error. Probably a compiler bug? Issue #65 git-svn-id: http://picoc.googlecode.com/svn/trunk@385 21eae674-98b7-11dd-bd71-f92a316d2d60 --- expression.c | 3 ++- variable.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/expression.c b/expression.c index 13a1451..870c68f 100644 --- a/expression.c +++ b/expression.c @@ -1192,9 +1192,10 @@ void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionSta if (FuncValue->Val->FuncDef.Intrinsic == NULL) { /* run a user-defined function */ - struct ParseState FuncParser = FuncValue->Val->FuncDef.Body; + struct ParseState FuncParser; int Count; + memcpy((void *)&FuncParser, (void *)&FuncValue->Val->FuncDef.Body, sizeof(struct ParseState)); VariableStackFrameAdd(Parser, FuncValue->Val->FuncDef.Intrinsic ? FuncValue->Val->FuncDef.NumParams : 0); TopStackFrame->NumParams = ArgCount; TopStackFrame->ReturnValue = ReturnValue; diff --git a/variable.c b/variable.c index 005a100..d6ae74e 100644 --- a/variable.c +++ b/variable.c @@ -88,8 +88,8 @@ void *VariableAlloc(struct ParseState *Parser, int Size, int OnHeap) /* allocate a value either on the heap or the stack using space dependent on what type we want */ struct Value *VariableAllocValueAndData(struct ParseState *Parser, int DataSize, int IsLValue, struct Value *LValueFrom, int OnHeap) { - struct Value *NewValue = VariableAlloc(Parser, sizeof(struct Value) + DataSize, OnHeap); - NewValue->Val = (union AnyValue *)((char *)NewValue + sizeof(struct Value)); + struct Value *NewValue = VariableAlloc(Parser, MEM_ALIGN(sizeof(struct Value)) + DataSize, OnHeap); + NewValue->Val = (union AnyValue *)((char *)NewValue + MEM_ALIGN(sizeof(struct Value))); NewValue->ValOnHeap = OnHeap; NewValue->ValOnStack = !OnHeap; NewValue->IsLValue = IsLValue;