sl@0: // Copyright (c) 1995-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: // e32\euser\us_gcc.cpp sl@0: // sl@0: // sl@0: sl@0: #include "us_std.h" sl@0: #include sl@0: sl@0: extern "C" { sl@0: sl@0: EXPORT_C TInt64 __fixsfdi(TReal32 a1) sl@0: // sl@0: // Convert float to long long sl@0: // sl@0: { sl@0: const TRealX f(a1); sl@0: const TInt64 ret = f; sl@0: return ret; sl@0: } sl@0: sl@0: } // end of extern "C" declaration sl@0: sl@0: #ifndef __REALS_MACHINE_CODED__ 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: // 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: Panic(EMathUnknownError); sl@0: } sl@0: sl@0: User::RaiseException(excType); sl@0: } sl@0: sl@0: EXPORT_C TReal32 __addsf3(TReal32 a1,TReal32 a2) sl@0: // sl@0: // Add two floats sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: sl@0: TRealX res; sl@0: TReal32 trg; sl@0: x1.Add(res,x2); // need not check error because no underflow and others will not be lost in conversion 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: EXPORT_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); // need not check error because no underflow and others will not be lost in conversion 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: EXPORT_C TReal32 __subsf3(TReal32 a1,TReal32 a2) sl@0: // sl@0: // Subtract two floats sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: sl@0: TRealX res; sl@0: TReal32 trg; sl@0: x1.Sub(res,x2); // need not check error because no underflow and others will not be lost in conversion 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: EXPORT_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); // need not check error because no underflow and others will not be lost in conversion 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: EXPORT_C TInt __cmpsf3(TReal32 a1,TReal32 a2) sl@0: // sl@0: // Compare two floats sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: if (x1x2) sl@0: return(1); sl@0: return(0); sl@0: } sl@0: sl@0: EXPORT_C TInt __cmpdf3(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Compare two doubles sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: if (x1x2) sl@0: return(1); sl@0: return(0); sl@0: } sl@0: sl@0: EXPORT_C TInt __eqsf2(TReal32 a1,TReal32 a2) sl@0: // sl@0: // Compare if two floats are equal sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return (x1==x2 ? 0 : 1); sl@0: } sl@0: sl@0: EXPORT_C TInt __eqdf2(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Compare if two doubles are equal sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return (x1==x2 ? 0 : 1); sl@0: } sl@0: sl@0: EXPORT_C TInt __nesf2(TReal32 a1,TReal32 a2) sl@0: // sl@0: // Compare if two floats are not equal sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return(x1!=x2 ? 1 : 0); sl@0: } sl@0: sl@0: EXPORT_C TInt __nedf2(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Compare if two doubles are not equal sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return(x1!=x2 ? 1 : 0); sl@0: } sl@0: sl@0: EXPORT_C TInt __gtsf2(TReal32 a1,TReal32 a2) sl@0: // sl@0: // Compare if one float is greater than another sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return(x1>x2 ? +1 : -1); sl@0: } sl@0: sl@0: EXPORT_C TInt __gtdf2(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Compare if one double is greater than another sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return(x1>x2 ? +1 : -1); sl@0: } sl@0: sl@0: EXPORT_C TInt __gesf2(TReal32 a1,TReal32 a2) sl@0: // sl@0: // Compare if one float is greater than or equal to another sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return(x1>=x2 ? 1 : -1); sl@0: } sl@0: sl@0: EXPORT_C TInt __gedf2(TReal64 a1,TReal64 a2) sl@0: // sl@0: // Compare if one double is greater than or equal to another sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return(x1>=x2 ? 1 : -1); sl@0: } sl@0: sl@0: EXPORT_C TInt __ltsf2(TReal32 a1,TReal32 a2) sl@0: // sl@0: // Compare if one float is less than another sl@0: // sl@0: { sl@0: sl@0: TRealX x1=a1; sl@0: TRealX x2=a2; sl@0: return(x1