Search
lxdream.org :: lxdream/test/include/ieeefp.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/include/ieeefp.h
changeset 185:6755a04c447f
author nkeynes
date Tue Sep 18 08:58:23 2007 +0000 (16 years ago)
permissions -rw-r--r--
last change Add instruction statistics gathering module
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/include/ieeefp.h Tue Sep 18 08:58:23 2007 +0000
1.3 @@ -0,0 +1,241 @@
1.4 +#ifndef _IEEE_FP_H_
1.5 +#define _IEEE_FP_H_
1.6 +
1.7 +#include "_ansi.h"
1.8 +
1.9 +#include <machine/ieeefp.h>
1.10 +
1.11 +/* FIXME FIXME FIXME:
1.12 + Neither of __ieee_{float,double}_shape_tape seem to be used anywhere
1.13 + except in libm/test. If that is the case, please delete these from here.
1.14 + If that is not the case, please insert documentation here describing why
1.15 + they're needed. */
1.16 +
1.17 +#ifdef __IEEE_BIG_ENDIAN
1.18 +
1.19 +typedef union
1.20 +{
1.21 + double value;
1.22 + struct
1.23 + {
1.24 + unsigned int sign : 1;
1.25 + unsigned int exponent: 11;
1.26 + unsigned int fraction0:4;
1.27 + unsigned int fraction1:16;
1.28 + unsigned int fraction2:16;
1.29 + unsigned int fraction3:16;
1.30 +
1.31 + } number;
1.32 + struct
1.33 + {
1.34 + unsigned int sign : 1;
1.35 + unsigned int exponent: 11;
1.36 + unsigned int quiet:1;
1.37 + unsigned int function0:3;
1.38 + unsigned int function1:16;
1.39 + unsigned int function2:16;
1.40 + unsigned int function3:16;
1.41 + } nan;
1.42 + struct
1.43 + {
1.44 + unsigned long msw;
1.45 + unsigned long lsw;
1.46 + } parts;
1.47 + long aslong[2];
1.48 +} __ieee_double_shape_type;
1.49 +
1.50 +#endif
1.51 +
1.52 +#ifdef __IEEE_LITTLE_ENDIAN
1.53 +
1.54 +typedef union
1.55 +{
1.56 + double value;
1.57 + struct
1.58 + {
1.59 +#ifdef __SMALL_BITFIELDS
1.60 + unsigned int fraction3:16;
1.61 + unsigned int fraction2:16;
1.62 + unsigned int fraction1:16;
1.63 + unsigned int fraction0: 4;
1.64 +#else
1.65 + unsigned int fraction1:32;
1.66 + unsigned int fraction0:20;
1.67 +#endif
1.68 + unsigned int exponent :11;
1.69 + unsigned int sign : 1;
1.70 + } number;
1.71 + struct
1.72 + {
1.73 +#ifdef __SMALL_BITFIELDS
1.74 + unsigned int function3:16;
1.75 + unsigned int function2:16;
1.76 + unsigned int function1:16;
1.77 + unsigned int function0:3;
1.78 +#else
1.79 + unsigned int function1:32;
1.80 + unsigned int function0:19;
1.81 +#endif
1.82 + unsigned int quiet:1;
1.83 + unsigned int exponent: 11;
1.84 + unsigned int sign : 1;
1.85 + } nan;
1.86 + struct
1.87 + {
1.88 + unsigned long lsw;
1.89 + unsigned long msw;
1.90 + } parts;
1.91 +
1.92 + long aslong[2];
1.93 +
1.94 +} __ieee_double_shape_type;
1.95 +
1.96 +#endif
1.97 +
1.98 +#ifdef __IEEE_BIG_ENDIAN
1.99 +
1.100 +typedef union
1.101 +{
1.102 + float value;
1.103 + struct
1.104 + {
1.105 + unsigned int sign : 1;
1.106 + unsigned int exponent: 8;
1.107 + unsigned int fraction0: 7;
1.108 + unsigned int fraction1: 16;
1.109 + } number;
1.110 + struct
1.111 + {
1.112 + unsigned int sign:1;
1.113 + unsigned int exponent:8;
1.114 + unsigned int quiet:1;
1.115 + unsigned int function0:6;
1.116 + unsigned int function1:16;
1.117 + } nan;
1.118 + long p1;
1.119 +
1.120 +} __ieee_float_shape_type;
1.121 +
1.122 +#endif
1.123 +
1.124 +#ifdef __IEEE_LITTLE_ENDIAN
1.125 +
1.126 +typedef union
1.127 +{
1.128 + float value;
1.129 + struct
1.130 + {
1.131 + unsigned int fraction0: 7;
1.132 + unsigned int fraction1: 16;
1.133 + unsigned int exponent: 8;
1.134 + unsigned int sign : 1;
1.135 + } number;
1.136 + struct
1.137 + {
1.138 + unsigned int function1:16;
1.139 + unsigned int function0:6;
1.140 + unsigned int quiet:1;
1.141 + unsigned int exponent:8;
1.142 + unsigned int sign:1;
1.143 + } nan;
1.144 + long p1;
1.145 +
1.146 +} __ieee_float_shape_type;
1.147 +
1.148 +#endif
1.149 +
1.150 +
1.151 +
1.152 +
1.153 +
1.154 +/* FLOATING ROUNDING */
1.155 +
1.156 +typedef int fp_rnd;
1.157 +#define FP_RN 0 /* Round to nearest */
1.158 +#define FP_RM 1 /* Round down */
1.159 +#define FP_RP 2 /* Round up */
1.160 +#define FP_RZ 3 /* Round to zero (trunate) */
1.161 +
1.162 +fp_rnd _EXFUN(fpgetround,(void));
1.163 +fp_rnd _EXFUN(fpsetround, (fp_rnd));
1.164 +
1.165 +/* EXCEPTIONS */
1.166 +
1.167 +typedef int fp_except;
1.168 +#define FP_X_INV 0x10 /* Invalid operation */
1.169 +#define FP_X_DX 0x80 /* Divide by zero */
1.170 +#define FP_X_OFL 0x04 /* Overflow exception */
1.171 +#define FP_X_UFL 0x02 /* Underflow exception */
1.172 +#define FP_X_IMP 0x01 /* imprecise exception */
1.173 +
1.174 +fp_except _EXFUN(fpgetmask,(void));
1.175 +fp_except _EXFUN(fpsetmask,(fp_except));
1.176 +fp_except _EXFUN(fpgetsticky,(void));
1.177 +fp_except _EXFUN(fpsetsticky, (fp_except));
1.178 +
1.179 +/* INTEGER ROUNDING */
1.180 +
1.181 +typedef int fp_rdi;
1.182 +#define FP_RDI_TOZ 0 /* Round to Zero */
1.183 +#define FP_RDI_RD 1 /* Follow float mode */
1.184 +
1.185 +fp_rdi _EXFUN(fpgetroundtoi,(void));
1.186 +fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi));
1.187 +
1.188 +int _EXFUN(isnan, (double));
1.189 +int _EXFUN(isinf, (double));
1.190 +int _EXFUN(finite, (double));
1.191 +
1.192 +
1.193 +
1.194 +int _EXFUN(isnanf, (float));
1.195 +int _EXFUN(isinff, (float));
1.196 +int _EXFUN(finitef, (float));
1.197 +
1.198 +#define __IEEE_DBL_EXPBIAS 1023
1.199 +#define __IEEE_FLT_EXPBIAS 127
1.200 +
1.201 +#define __IEEE_DBL_EXPLEN 11
1.202 +#define __IEEE_FLT_EXPLEN 8
1.203 +
1.204 +
1.205 +#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
1.206 +#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))
1.207 +
1.208 +#define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
1.209 +#define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1))
1.210 +
1.211 +#define __IEEE_DBL_NAN_EXP 0x7ff
1.212 +#define __IEEE_FLT_NAN_EXP 0xff
1.213 +
1.214 +
1.215 +#define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
1.216 + ((*(long *)&(x) & 0x007fffffL)!=0000000000L))
1.217 +
1.218 +#define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
1.219 + ((*(long *)&(x) & 0x007fffffL)==0000000000L))
1.220 +
1.221 +#define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))
1.222 +
1.223 +#ifdef _DOUBLE_IS_32BITS
1.224 +#undef __IEEE_DBL_EXPBIAS
1.225 +#define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS
1.226 +
1.227 +#undef __IEEE_DBL_EXPLEN
1.228 +#define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN
1.229 +
1.230 +#undef __IEEE_DBL_FRACLEN
1.231 +#define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN
1.232 +
1.233 +#undef __IEEE_DBL_MAXPOWTWO
1.234 +#define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO
1.235 +
1.236 +#undef __IEEE_DBL_NAN_EXP
1.237 +#define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP
1.238 +
1.239 +#undef __ieee_double_shape_type
1.240 +#define __ieee_double_shape_type __ieee_float_shape_type
1.241 +
1.242 +#endif /* _DOUBLE_IS_32BITS */
1.243 +
1.244 +#endif /* _IEEE_FP_H_ */
.