sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\math\t_gcc64.cpp sl@0: // From UP_GCC.CPP, for emulating UP_GCC in T_R64.CPP tests sl@0: // sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "t_math.h" sl@0: sl@0: LOCAL_C void MathException(TInt aErrType) sl@0: // sl@0: // Decides on type of maths exception according to error and raises exception. sl@0: // DOES NOT CONVERT TO SPECIAL IF RETURNS sl@0: // Added by AnnW, December 1996 sl@0: // sl@0: { sl@0: sl@0: TExcType excType=EExcGeneral; sl@0: sl@0: switch (aErrType) sl@0: { sl@0: case KErrArgument: // error due to invalid operation sl@0: excType=EExcFloatInvalidOperation; sl@0: break; sl@0: case KErrDivideByZero: sl@0: excType=EExcFloatDivideByZero; sl@0: break; sl@0: case KErrOverflow: sl@0: excType=EExcFloatOverflow; sl@0: break; sl@0: case KErrUnderflow: sl@0: excType=EExcFloatUnderflow; sl@0: break; sl@0: /* sl@0: // also errors due to inexact result sl@0: case KErrInexact: // const not defined yet sl@0: excType=EExcFloatInexact; sl@0: break; sl@0: */ sl@0: sl@0: default: sl@0: // Unknown error sl@0: User::Panic(_L("USER-Math"),EMathUnknownError); sl@0: } sl@0: sl@0: RThread thread; sl@0: thread.RaiseException(excType); sl@0: } sl@0: sl@0: GLDEF_C TReal64 __adddf3(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Add two doubles sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: sl@0: TRealX res; sl@0: TReal64 trg; sl@0: x1.Add(res,x2); sl@0: TInt ret=res.GetTReal(trg); sl@0: if (ret!=KErrNone) sl@0: MathException(ret); sl@0: sl@0: return(trg); sl@0: } sl@0: sl@0: GLDEF_C TReal64 __subdf3(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Subtract two doubles sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: sl@0: TRealX res; sl@0: TReal64 trg; sl@0: x1.Sub(res,x2); sl@0: TInt ret=res.GetTReal(trg); sl@0: if (ret!=KErrNone) sl@0: MathException(ret); sl@0: sl@0: return(trg); sl@0: } sl@0: sl@0: GLDEF_C TReal64 __muldf3(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Multiply two doubles sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: sl@0: TRealX res; sl@0: TReal64 trg; sl@0: TInt ret=x1.Mult(res,x2); sl@0: if (ret==KErrNone) sl@0: ret=res.GetTReal(trg); sl@0: if (ret!=KErrNone) sl@0: MathException(ret); sl@0: sl@0: return((TReal64)res); sl@0: } sl@0: sl@0: GLDEF_C TReal64 __divdf3(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Divide two doubles sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: sl@0: TRealX res; sl@0: TReal64 trg; sl@0: TInt ret=x1.Div(res,x2); sl@0: if (ret==KErrNone) sl@0: ret=res.GetTReal(trg); sl@0: if (ret!=KErrNone) sl@0: MathException(ret); sl@0: sl@0: return((TReal64)res); sl@0: }