epoc32/include/libc/ieeefp.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/libc/ieeefp.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/libc/ieeefp.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,240 @@
     1.4 -ieeefp.h
     1.5 +/*
     1.6 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* 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
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +
    1.27 +/**
    1.28 + @file
    1.29 + @publishedAll
    1.30 + @released
    1.31 +*/
    1.32 +
    1.33 +#ifndef _IEEE_FP_H_
    1.34 +#define _IEEE_FP_H_
    1.35 +
    1.36 +#include "_ansi.h"
    1.37 +
    1.38 +#include <machine/ieeefp.h>
    1.39 +
    1.40 +/* FIX THIS FIX THIS FIX THIS:
    1.41 +   Neither of __ieee_{float,double}_shape_tape seem to be used anywhere
    1.42 +   except in libm/test.  If that is the case, please delete these from here.
    1.43 +   If that is not the case, please insert documentation here describing why
    1.44 +   they're needed.  */
    1.45 +
    1.46 +#ifdef __IEEE_BIG_ENDIAN
    1.47 +
    1.48 +typedef union 
    1.49 +{
    1.50 +  double value;
    1.51 +  struct 
    1.52 +  {
    1.53 +    unsigned int sign : 1;
    1.54 +    unsigned int exponent: 11;
    1.55 +    unsigned int fraction0:4;
    1.56 +    unsigned int fraction1:16;
    1.57 +    unsigned int fraction2:16;
    1.58 +    unsigned int fraction3:16;
    1.59 +    
    1.60 +  } number;
    1.61 +  struct 
    1.62 +  {
    1.63 +    unsigned int sign : 1;
    1.64 +    unsigned int exponent: 11;
    1.65 +    unsigned int quiet:1;
    1.66 +    unsigned int function0:3;
    1.67 +    unsigned int function1:16;
    1.68 +    unsigned int function2:16;
    1.69 +    unsigned int function3:16;
    1.70 +  } nan;
    1.71 +  struct 
    1.72 +  {
    1.73 +    unsigned long msw;
    1.74 +    unsigned long lsw;
    1.75 +  } parts;
    1.76 +    long aslong[2];
    1.77 +} __ieee_double_shape_type;
    1.78 +
    1.79 +#endif
    1.80 +
    1.81 +#ifdef __IEEE_LITTLE_ENDIAN
    1.82 +
    1.83 +typedef union 
    1.84 +{
    1.85 +  double value;
    1.86 +  struct 
    1.87 +  {
    1.88 +#ifdef __SMALL_BITFIELDS
    1.89 +    unsigned int fraction3:16;
    1.90 +    unsigned int fraction2:16;
    1.91 +    unsigned int fraction1:16;
    1.92 +    unsigned int fraction0: 4;
    1.93 +#else
    1.94 +    unsigned int fraction1:32;
    1.95 +    unsigned int fraction0:20;
    1.96 +#endif
    1.97 +    unsigned int exponent :11;
    1.98 +    unsigned int sign     : 1;
    1.99 +  } number;
   1.100 +  struct 
   1.101 +  {
   1.102 +#ifdef __SMALL_BITFIELDS
   1.103 +    unsigned int function3:16;
   1.104 +    unsigned int function2:16;
   1.105 +    unsigned int function1:16;
   1.106 +    unsigned int function0:3;
   1.107 +#else
   1.108 +    unsigned int function1:32;
   1.109 +    unsigned int function0:19;
   1.110 +#endif
   1.111 +    unsigned int quiet:1;
   1.112 +    unsigned int exponent: 11;
   1.113 +    unsigned int sign : 1;
   1.114 +  } nan;
   1.115 +  struct 
   1.116 +  {
   1.117 +    unsigned long lsw;
   1.118 +    unsigned long msw;
   1.119 +  } parts;
   1.120 +
   1.121 +  long aslong[2];
   1.122 +
   1.123 +} __ieee_double_shape_type;
   1.124 +
   1.125 +#endif
   1.126 +
   1.127 +#ifdef __IEEE_BIG_ENDIAN
   1.128 +
   1.129 +typedef union
   1.130 +{
   1.131 +  float value;
   1.132 +  struct 
   1.133 +  {
   1.134 +    unsigned int sign : 1;
   1.135 +    unsigned int exponent: 8;
   1.136 +    unsigned int fraction0: 7;
   1.137 +    unsigned int fraction1: 16;
   1.138 +  } number;
   1.139 +  struct 
   1.140 +  {
   1.141 +    unsigned int sign:1;
   1.142 +    unsigned int exponent:8;
   1.143 +    unsigned int quiet:1;
   1.144 +    unsigned int function0:6;
   1.145 +    unsigned int function1:16;
   1.146 +  } nan;
   1.147 +  long p1;
   1.148 +  
   1.149 +} __ieee_float_shape_type;
   1.150 +
   1.151 +#endif
   1.152 +
   1.153 +#ifdef __IEEE_LITTLE_ENDIAN
   1.154 +
   1.155 +typedef union
   1.156 +{
   1.157 +  float value;
   1.158 +  struct 
   1.159 +  {
   1.160 +    unsigned int fraction0: 7;
   1.161 +    unsigned int fraction1: 16;
   1.162 +    unsigned int exponent: 8;
   1.163 +    unsigned int sign : 1;
   1.164 +  } number;
   1.165 +  struct 
   1.166 +  {
   1.167 +    unsigned int function1:16;
   1.168 +    unsigned int function0:6;
   1.169 +    unsigned int quiet:1;
   1.170 +    unsigned int exponent:8;
   1.171 +    unsigned int sign:1;
   1.172 +  } nan;
   1.173 +  long p1;
   1.174 +  
   1.175 +} __ieee_float_shape_type;
   1.176 +
   1.177 +#endif
   1.178 +
   1.179 +
   1.180 +/**
   1.181 +FLOATING ROUNDING
   1.182 +*/
   1.183 +typedef int fp_rnd;
   1.184 +
   1.185 +#define FP_RN 0 	/* Round to nearest 		*/
   1.186 +#define FP_RM 1		/* Round down 			*/
   1.187 +#define FP_RP 2		/* Round up 			*/
   1.188 +#define FP_RZ 3		/* Round to zero (trunate) 	*/
   1.189 +
   1.190 +fp_rnd fpgetround(void);
   1.191 +fp_rnd fpsetround(fp_rnd);
   1.192 +
   1.193 +/**
   1.194 +EXCEPTIONS 
   1.195 +*/
   1.196 +typedef int fp_except;
   1.197 +
   1.198 +#define FP_X_INV 0x10	/* Invalid operation 		*/
   1.199 +#define FP_X_DX  0x80	/* Divide by zero		*/
   1.200 +#define FP_X_OFL 0x04	/* Overflow exception		*/
   1.201 +#define FP_X_UFL 0x02	/* Underflow exception		*/
   1.202 +#define FP_X_IMP 0x01	/* imprecise exception		*/
   1.203 +
   1.204 +fp_except fpgetmask(void);
   1.205 +fp_except fpsetmask(fp_except);
   1.206 +fp_except fpgetsticky(void);
   1.207 +fp_except fpsetsticky(fp_except);
   1.208 +
   1.209 +/**
   1.210 +INTEGER ROUNDING 
   1.211 +*/
   1.212 +typedef int fp_rdi;
   1.213 +#define FP_RDI_TOZ 0	/* Round to Zero 		*/
   1.214 +#define FP_RDI_RD  1	/* Follow float mode		*/
   1.215 +
   1.216 +fp_rdi fpgetroundtoi(void);
   1.217 +fp_rdi fpsetroundtoi(fp_rdi);
   1.218 +
   1.219 +int isnan(double);
   1.220 +int isinf(double);
   1.221 +int finite(double);
   1.222 +
   1.223 +int isnanf(float);
   1.224 +int isinff(float);
   1.225 +int finitef(float);
   1.226 +
   1.227 +#define __IEEE_DBL_EXPBIAS 1023
   1.228 +#define __IEEE_FLT_EXPBIAS 127
   1.229 +#define __IEEE_DBL_EXPLEN 11
   1.230 +#define __IEEE_FLT_EXPLEN 8
   1.231 +#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
   1.232 +#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))
   1.233 +#define __IEEE_DBL_MAXPOWTWO	((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
   1.234 +#define __IEEE_FLT_MAXPOWTWO	((float)(1L << (32-8) - 1))
   1.235 +#define __IEEE_DBL_NAN_EXP 0x7ff
   1.236 +#define __IEEE_FLT_NAN_EXP 0xff
   1.237 +
   1.238 +#define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
   1.239 +		   ((*(long *)&(x) & 0x007fffffL)!=0000000000L))
   1.240 +#define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
   1.241 +		   ((*(long *)&(x) & 0x007fffffL)==0000000000L))
   1.242 +#define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))
   1.243 +
   1.244 +#endif /* _IEEE_FP_H_ */