os/kernelhwsrv/kerneltest/e32test/math/t_gcc64.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\math\t_gcc64.cpp
sl@0
    15
// From UP_GCC.CPP, for emulating UP_GCC in T_R64.CPP tests
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
sl@0
    20
#include <e32def.h>
sl@0
    21
#include <e32def_private.h>
sl@0
    22
sl@0
    23
#include "t_math.h"
sl@0
    24
sl@0
    25
LOCAL_C void MathException(TInt aErrType) 
sl@0
    26
//
sl@0
    27
// Decides on type of maths exception according to error and raises exception.
sl@0
    28
// DOES NOT CONVERT TO SPECIAL IF RETURNS
sl@0
    29
// Added by AnnW, December 1996
sl@0
    30
//
sl@0
    31
	{
sl@0
    32
sl@0
    33
	TExcType excType=EExcGeneral;
sl@0
    34
sl@0
    35
	switch (aErrType)
sl@0
    36
		{
sl@0
    37
	case KErrArgument:				// error due to invalid operation
sl@0
    38
		excType=EExcFloatInvalidOperation;
sl@0
    39
		break;
sl@0
    40
	case KErrDivideByZero:
sl@0
    41
		excType=EExcFloatDivideByZero;
sl@0
    42
		break;
sl@0
    43
	case KErrOverflow:
sl@0
    44
		excType=EExcFloatOverflow;
sl@0
    45
		break;
sl@0
    46
	case KErrUnderflow:
sl@0
    47
		excType=EExcFloatUnderflow;
sl@0
    48
		break;
sl@0
    49
/*
sl@0
    50
	// also errors due to inexact result
sl@0
    51
	case KErrInexact:		// const not defined yet
sl@0
    52
		excType=EExcFloatInexact;
sl@0
    53
		break;
sl@0
    54
*/
sl@0
    55
	
sl@0
    56
	default:
sl@0
    57
		// Unknown error
sl@0
    58
		User::Panic(_L("USER-Math"),EMathUnknownError);
sl@0
    59
		}
sl@0
    60
sl@0
    61
	RThread thread;
sl@0
    62
	thread.RaiseException(excType);
sl@0
    63
	}
sl@0
    64
sl@0
    65
GLDEF_C TReal64 __adddf3(TReal64 a1,TReal64 a2)
sl@0
    66
//
sl@0
    67
// Add two doubles
sl@0
    68
//
sl@0
    69
    {
sl@0
    70
sl@0
    71
    TRealX x1=a1;
sl@0
    72
    TRealX x2=a2;
sl@0
    73
sl@0
    74
	TRealX res;
sl@0
    75
	TReal64 trg;
sl@0
    76
	x1.Add(res,x2);
sl@0
    77
	TInt ret=res.GetTReal(trg);
sl@0
    78
	if (ret!=KErrNone)
sl@0
    79
		MathException(ret);
sl@0
    80
sl@0
    81
	return(trg);
sl@0
    82
    }
sl@0
    83
sl@0
    84
GLDEF_C TReal64 __subdf3(TReal64 a1,TReal64 a2)
sl@0
    85
//
sl@0
    86
// Subtract two doubles
sl@0
    87
//
sl@0
    88
    {
sl@0
    89
sl@0
    90
    TRealX x1=a1;
sl@0
    91
    TRealX x2=a2;
sl@0
    92
sl@0
    93
	TRealX res;
sl@0
    94
	TReal64 trg;
sl@0
    95
	x1.Sub(res,x2);
sl@0
    96
	TInt ret=res.GetTReal(trg);
sl@0
    97
	if (ret!=KErrNone)
sl@0
    98
		MathException(ret);
sl@0
    99
sl@0
   100
	return(trg);    
sl@0
   101
    }
sl@0
   102
sl@0
   103
GLDEF_C TReal64 __muldf3(TReal64 a1,TReal64 a2)
sl@0
   104
//
sl@0
   105
// Multiply two doubles
sl@0
   106
//
sl@0
   107
    {
sl@0
   108
sl@0
   109
    TRealX x1=a1;
sl@0
   110
    TRealX x2=a2;
sl@0
   111
sl@0
   112
	TRealX res;
sl@0
   113
	TReal64 trg;
sl@0
   114
	TInt ret=x1.Mult(res,x2);
sl@0
   115
	if (ret==KErrNone)
sl@0
   116
		ret=res.GetTReal(trg);
sl@0
   117
	if (ret!=KErrNone)
sl@0
   118
		MathException(ret);
sl@0
   119
sl@0
   120
	return((TReal64)res);
sl@0
   121
    }
sl@0
   122
sl@0
   123
GLDEF_C TReal64 __divdf3(TReal64 a1,TReal64 a2)
sl@0
   124
	//
sl@0
   125
	// Divide two doubles
sl@0
   126
	//
sl@0
   127
	{
sl@0
   128
	
sl@0
   129
	TRealX x1=a1;
sl@0
   130
	TRealX x2=a2;
sl@0
   131
sl@0
   132
	TRealX res;
sl@0
   133
	TReal64 trg;
sl@0
   134
	TInt ret=x1.Div(res,x2);
sl@0
   135
	if (ret==KErrNone)
sl@0
   136
		ret=res.GetTReal(trg);
sl@0
   137
	if (ret!=KErrNone)
sl@0
   138
		MathException(ret);
sl@0
   139
sl@0
   140
	return((TReal64)res);
sl@0
   141
	}