First public contribution.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\math\t_gcc32.cpp
15 // From UP_GCC.CPP, for emulating UP_GCC in T_R32.CPP tests
21 #include <e32def_private.h>
25 LOCAL_C void MathException(TInt aErrType)
27 // Decides on type of maths exception according to error and raises exception.
28 // Added by AnnW, December 1996
32 TExcType excType=EExcGeneral;
36 case KErrArgument: // error due to invalid operation
37 excType=EExcFloatInvalidOperation;
39 case KErrDivideByZero:
40 excType=EExcFloatDivideByZero;
43 excType=EExcFloatOverflow;
46 excType=EExcFloatUnderflow;
49 // also errors due to inexact result
50 case KErrInexact: // const not defined yet
51 excType=EExcFloatInexact;
57 User::Panic(_L("USER-Math"),EMathUnknownError);
61 User::RaiseException(excType);
62 // thread.RaiseException(excType);
65 GLDEF_C TReal32 __addsf3(TReal32 a1,TReal32 a2)
77 TInt ret=res.GetTReal(trg);
84 GLDEF_C TReal32 __subsf3(TReal32 a1,TReal32 a2)
86 // Subtract two floats
96 TInt ret=res.GetTReal(trg);
103 GLDEF_C TReal32 __mulsf3(TReal32 a1,TReal32 a2)
105 // Multiply two floats
114 TInt ret=x1.Mult(res,x2);
116 ret=res.GetTReal(trg);
120 return((TReal32)res);
123 GLDEF_C TReal32 __divsf3(TReal32 a1,TReal32 a2)
134 TInt ret=x1.Div(res,x2);
136 ret=res.GetTReal(trg);
140 return((TReal32)res);
143 GLDEF_C TReal32 __truncdfsf2(TReal64 a1)
145 // Convert a double to a float
146 // Raises an exception if conversion results in an error
154 if ((ret=x1.GetTReal(trg))!=KErrNone)