1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/math/t_gcc64.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,141 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\math\t_gcc64.cpp
1.18 +// From UP_GCC.CPP, for emulating UP_GCC in T_R64.CPP tests
1.19 +//
1.20 +//
1.21 +
1.22 +
1.23 +#include <e32def.h>
1.24 +#include <e32def_private.h>
1.25 +
1.26 +#include "t_math.h"
1.27 +
1.28 +LOCAL_C void MathException(TInt aErrType)
1.29 +//
1.30 +// Decides on type of maths exception according to error and raises exception.
1.31 +// DOES NOT CONVERT TO SPECIAL IF RETURNS
1.32 +// Added by AnnW, December 1996
1.33 +//
1.34 + {
1.35 +
1.36 + TExcType excType=EExcGeneral;
1.37 +
1.38 + switch (aErrType)
1.39 + {
1.40 + case KErrArgument: // error due to invalid operation
1.41 + excType=EExcFloatInvalidOperation;
1.42 + break;
1.43 + case KErrDivideByZero:
1.44 + excType=EExcFloatDivideByZero;
1.45 + break;
1.46 + case KErrOverflow:
1.47 + excType=EExcFloatOverflow;
1.48 + break;
1.49 + case KErrUnderflow:
1.50 + excType=EExcFloatUnderflow;
1.51 + break;
1.52 +/*
1.53 + // also errors due to inexact result
1.54 + case KErrInexact: // const not defined yet
1.55 + excType=EExcFloatInexact;
1.56 + break;
1.57 +*/
1.58 +
1.59 + default:
1.60 + // Unknown error
1.61 + User::Panic(_L("USER-Math"),EMathUnknownError);
1.62 + }
1.63 +
1.64 + RThread thread;
1.65 + thread.RaiseException(excType);
1.66 + }
1.67 +
1.68 +GLDEF_C TReal64 __adddf3(TReal64 a1,TReal64 a2)
1.69 +//
1.70 +// Add two doubles
1.71 +//
1.72 + {
1.73 +
1.74 + TRealX x1=a1;
1.75 + TRealX x2=a2;
1.76 +
1.77 + TRealX res;
1.78 + TReal64 trg;
1.79 + x1.Add(res,x2);
1.80 + TInt ret=res.GetTReal(trg);
1.81 + if (ret!=KErrNone)
1.82 + MathException(ret);
1.83 +
1.84 + return(trg);
1.85 + }
1.86 +
1.87 +GLDEF_C TReal64 __subdf3(TReal64 a1,TReal64 a2)
1.88 +//
1.89 +// Subtract two doubles
1.90 +//
1.91 + {
1.92 +
1.93 + TRealX x1=a1;
1.94 + TRealX x2=a2;
1.95 +
1.96 + TRealX res;
1.97 + TReal64 trg;
1.98 + x1.Sub(res,x2);
1.99 + TInt ret=res.GetTReal(trg);
1.100 + if (ret!=KErrNone)
1.101 + MathException(ret);
1.102 +
1.103 + return(trg);
1.104 + }
1.105 +
1.106 +GLDEF_C TReal64 __muldf3(TReal64 a1,TReal64 a2)
1.107 +//
1.108 +// Multiply two doubles
1.109 +//
1.110 + {
1.111 +
1.112 + TRealX x1=a1;
1.113 + TRealX x2=a2;
1.114 +
1.115 + TRealX res;
1.116 + TReal64 trg;
1.117 + TInt ret=x1.Mult(res,x2);
1.118 + if (ret==KErrNone)
1.119 + ret=res.GetTReal(trg);
1.120 + if (ret!=KErrNone)
1.121 + MathException(ret);
1.122 +
1.123 + return((TReal64)res);
1.124 + }
1.125 +
1.126 +GLDEF_C TReal64 __divdf3(TReal64 a1,TReal64 a2)
1.127 + //
1.128 + // Divide two doubles
1.129 + //
1.130 + {
1.131 +
1.132 + TRealX x1=a1;
1.133 + TRealX x2=a2;
1.134 +
1.135 + TRealX res;
1.136 + TReal64 trg;
1.137 + TInt ret=x1.Div(res,x2);
1.138 + if (ret==KErrNone)
1.139 + ret=res.GetTReal(trg);
1.140 + if (ret!=KErrNone)
1.141 + MathException(ret);
1.142 +
1.143 + return((TReal64)res);
1.144 + }