williamr@2: /* williamr@2: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: #ifndef _IEEE_FP_H_ williamr@2: #define _IEEE_FP_H_ williamr@2: williamr@2: #include "_ansi.h" williamr@2: williamr@2: #include williamr@2: williamr@2: /* FIX THIS FIX THIS FIX THIS: williamr@2: Neither of __ieee_{float,double}_shape_tape seem to be used anywhere williamr@2: except in libm/test. If that is the case, please delete these from here. williamr@2: If that is not the case, please insert documentation here describing why williamr@2: they're needed. */ williamr@2: williamr@2: #ifdef __IEEE_BIG_ENDIAN williamr@2: williamr@2: typedef union williamr@2: { williamr@2: double value; williamr@2: struct williamr@2: { williamr@2: unsigned int sign : 1; williamr@2: unsigned int exponent: 11; williamr@2: unsigned int fraction0:4; williamr@2: unsigned int fraction1:16; williamr@2: unsigned int fraction2:16; williamr@2: unsigned int fraction3:16; williamr@2: williamr@2: } number; williamr@2: struct williamr@2: { williamr@2: unsigned int sign : 1; williamr@2: unsigned int exponent: 11; williamr@2: unsigned int quiet:1; williamr@2: unsigned int function0:3; williamr@2: unsigned int function1:16; williamr@2: unsigned int function2:16; williamr@2: unsigned int function3:16; williamr@2: } nan; williamr@2: struct williamr@2: { williamr@2: unsigned long msw; williamr@2: unsigned long lsw; williamr@2: } parts; williamr@2: long aslong[2]; williamr@2: } __ieee_double_shape_type; williamr@2: williamr@2: #endif williamr@2: williamr@2: #ifdef __IEEE_LITTLE_ENDIAN williamr@2: williamr@2: typedef union williamr@2: { williamr@2: double value; williamr@2: struct williamr@2: { williamr@2: #ifdef __SMALL_BITFIELDS williamr@2: unsigned int fraction3:16; williamr@2: unsigned int fraction2:16; williamr@2: unsigned int fraction1:16; williamr@2: unsigned int fraction0: 4; williamr@2: #else williamr@2: unsigned int fraction1:32; williamr@2: unsigned int fraction0:20; williamr@2: #endif williamr@2: unsigned int exponent :11; williamr@2: unsigned int sign : 1; williamr@2: } number; williamr@2: struct williamr@2: { williamr@2: #ifdef __SMALL_BITFIELDS williamr@2: unsigned int function3:16; williamr@2: unsigned int function2:16; williamr@2: unsigned int function1:16; williamr@2: unsigned int function0:3; williamr@2: #else williamr@2: unsigned int function1:32; williamr@2: unsigned int function0:19; williamr@2: #endif williamr@2: unsigned int quiet:1; williamr@2: unsigned int exponent: 11; williamr@2: unsigned int sign : 1; williamr@2: } nan; williamr@2: struct williamr@2: { williamr@2: unsigned long lsw; williamr@2: unsigned long msw; williamr@2: } parts; williamr@2: williamr@2: long aslong[2]; williamr@2: williamr@2: } __ieee_double_shape_type; williamr@2: williamr@2: #endif williamr@2: williamr@2: #ifdef __IEEE_BIG_ENDIAN williamr@2: williamr@2: typedef union williamr@2: { williamr@2: float value; williamr@2: struct williamr@2: { williamr@2: unsigned int sign : 1; williamr@2: unsigned int exponent: 8; williamr@2: unsigned int fraction0: 7; williamr@2: unsigned int fraction1: 16; williamr@2: } number; williamr@2: struct williamr@2: { williamr@2: unsigned int sign:1; williamr@2: unsigned int exponent:8; williamr@2: unsigned int quiet:1; williamr@2: unsigned int function0:6; williamr@2: unsigned int function1:16; williamr@2: } nan; williamr@2: long p1; williamr@2: williamr@2: } __ieee_float_shape_type; williamr@2: williamr@2: #endif williamr@2: williamr@2: #ifdef __IEEE_LITTLE_ENDIAN williamr@2: williamr@2: typedef union williamr@2: { williamr@2: float value; williamr@2: struct williamr@2: { williamr@2: unsigned int fraction0: 7; williamr@2: unsigned int fraction1: 16; williamr@2: unsigned int exponent: 8; williamr@2: unsigned int sign : 1; williamr@2: } number; williamr@2: struct williamr@2: { williamr@2: unsigned int function1:16; williamr@2: unsigned int function0:6; williamr@2: unsigned int quiet:1; williamr@2: unsigned int exponent:8; williamr@2: unsigned int sign:1; williamr@2: } nan; williamr@2: long p1; williamr@2: williamr@2: } __ieee_float_shape_type; williamr@2: williamr@2: #endif williamr@2: williamr@2: williamr@2: /** williamr@2: FLOATING ROUNDING williamr@2: */ williamr@2: typedef int fp_rnd; williamr@2: williamr@2: #define FP_RN 0 /* Round to nearest */ williamr@2: #define FP_RM 1 /* Round down */ williamr@2: #define FP_RP 2 /* Round up */ williamr@2: #define FP_RZ 3 /* Round to zero (trunate) */ williamr@2: williamr@2: fp_rnd fpgetround(void); williamr@2: fp_rnd fpsetround(fp_rnd); williamr@2: williamr@2: /** williamr@2: EXCEPTIONS williamr@2: */ williamr@2: typedef int fp_except; williamr@2: williamr@2: #define FP_X_INV 0x10 /* Invalid operation */ williamr@2: #define FP_X_DX 0x80 /* Divide by zero */ williamr@2: #define FP_X_OFL 0x04 /* Overflow exception */ williamr@2: #define FP_X_UFL 0x02 /* Underflow exception */ williamr@2: #define FP_X_IMP 0x01 /* imprecise exception */ williamr@2: williamr@2: fp_except fpgetmask(void); williamr@2: fp_except fpsetmask(fp_except); williamr@2: fp_except fpgetsticky(void); williamr@2: fp_except fpsetsticky(fp_except); williamr@2: williamr@2: /** williamr@2: INTEGER ROUNDING williamr@2: */ williamr@2: typedef int fp_rdi; williamr@2: #define FP_RDI_TOZ 0 /* Round to Zero */ williamr@2: #define FP_RDI_RD 1 /* Follow float mode */ williamr@2: williamr@2: fp_rdi fpgetroundtoi(void); williamr@2: fp_rdi fpsetroundtoi(fp_rdi); williamr@2: williamr@2: int isnan(double); williamr@2: int isinf(double); williamr@2: int finite(double); williamr@2: williamr@2: int isnanf(float); williamr@2: int isinff(float); williamr@2: int finitef(float); williamr@2: williamr@2: #define __IEEE_DBL_EXPBIAS 1023 williamr@2: #define __IEEE_FLT_EXPBIAS 127 williamr@2: #define __IEEE_DBL_EXPLEN 11 williamr@2: #define __IEEE_FLT_EXPLEN 8 williamr@2: #define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1)) williamr@2: #define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1)) williamr@2: #define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1)) williamr@2: #define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1)) williamr@2: #define __IEEE_DBL_NAN_EXP 0x7ff williamr@2: #define __IEEE_FLT_NAN_EXP 0xff williamr@2: williamr@2: #define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ williamr@2: ((*(long *)&(x) & 0x007fffffL)!=0000000000L)) williamr@2: #define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ williamr@2: ((*(long *)&(x) & 0x007fffffL)==0000000000L)) williamr@2: #define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L)) williamr@2: williamr@2: #endif /* _IEEE_FP_H_ */