Search
lxdream.org :: lxdream/test/include/ieeefp.h
lxdream 0.9.1
released Jun 29
Download Now
filename test/include/ieeefp.h
changeset 185:6755a04c447f
author nkeynes
date Sat Aug 05 00:18:21 2006 +0000 (16 years ago)
permissions -rw-r--r--
last change Add error lines to tests with incomplete polys
Split clip tests to separate data file
Add tests for cmd bit 23 ("use list size field")
file annotate diff log raw
nkeynes@185
     1
#ifndef _IEEE_FP_H_
nkeynes@185
     2
#define _IEEE_FP_H_
nkeynes@185
     3
nkeynes@185
     4
#include "_ansi.h"
nkeynes@185
     5
nkeynes@185
     6
#include <machine/ieeefp.h>
nkeynes@185
     7
nkeynes@185
     8
/* FIXME FIXME FIXME:
nkeynes@185
     9
   Neither of __ieee_{float,double}_shape_tape seem to be used anywhere
nkeynes@185
    10
   except in libm/test.  If that is the case, please delete these from here.
nkeynes@185
    11
   If that is not the case, please insert documentation here describing why
nkeynes@185
    12
   they're needed.  */
nkeynes@185
    13
nkeynes@185
    14
#ifdef __IEEE_BIG_ENDIAN
nkeynes@185
    15
nkeynes@185
    16
typedef union 
nkeynes@185
    17
{
nkeynes@185
    18
  double value;
nkeynes@185
    19
  struct 
nkeynes@185
    20
  {
nkeynes@185
    21
    unsigned int sign : 1;
nkeynes@185
    22
    unsigned int exponent: 11;
nkeynes@185
    23
    unsigned int fraction0:4;
nkeynes@185
    24
    unsigned int fraction1:16;
nkeynes@185
    25
    unsigned int fraction2:16;
nkeynes@185
    26
    unsigned int fraction3:16;
nkeynes@185
    27
    
nkeynes@185
    28
  } number;
nkeynes@185
    29
  struct 
nkeynes@185
    30
  {
nkeynes@185
    31
    unsigned int sign : 1;
nkeynes@185
    32
    unsigned int exponent: 11;
nkeynes@185
    33
    unsigned int quiet:1;
nkeynes@185
    34
    unsigned int function0:3;
nkeynes@185
    35
    unsigned int function1:16;
nkeynes@185
    36
    unsigned int function2:16;
nkeynes@185
    37
    unsigned int function3:16;
nkeynes@185
    38
  } nan;
nkeynes@185
    39
  struct 
nkeynes@185
    40
  {
nkeynes@185
    41
    unsigned long msw;
nkeynes@185
    42
    unsigned long lsw;
nkeynes@185
    43
  } parts;
nkeynes@185
    44
    long aslong[2];
nkeynes@185
    45
} __ieee_double_shape_type;
nkeynes@185
    46
nkeynes@185
    47
#endif
nkeynes@185
    48
nkeynes@185
    49
#ifdef __IEEE_LITTLE_ENDIAN
nkeynes@185
    50
nkeynes@185
    51
typedef union 
nkeynes@185
    52
{
nkeynes@185
    53
  double value;
nkeynes@185
    54
  struct 
nkeynes@185
    55
  {
nkeynes@185
    56
#ifdef __SMALL_BITFIELDS
nkeynes@185
    57
    unsigned int fraction3:16;
nkeynes@185
    58
    unsigned int fraction2:16;
nkeynes@185
    59
    unsigned int fraction1:16;
nkeynes@185
    60
    unsigned int fraction0: 4;
nkeynes@185
    61
#else
nkeynes@185
    62
    unsigned int fraction1:32;
nkeynes@185
    63
    unsigned int fraction0:20;
nkeynes@185
    64
#endif
nkeynes@185
    65
    unsigned int exponent :11;
nkeynes@185
    66
    unsigned int sign     : 1;
nkeynes@185
    67
  } number;
nkeynes@185
    68
  struct 
nkeynes@185
    69
  {
nkeynes@185
    70
#ifdef __SMALL_BITFIELDS
nkeynes@185
    71
    unsigned int function3:16;
nkeynes@185
    72
    unsigned int function2:16;
nkeynes@185
    73
    unsigned int function1:16;
nkeynes@185
    74
    unsigned int function0:3;
nkeynes@185
    75
#else
nkeynes@185
    76
    unsigned int function1:32;
nkeynes@185
    77
    unsigned int function0:19;
nkeynes@185
    78
#endif
nkeynes@185
    79
    unsigned int quiet:1;
nkeynes@185
    80
    unsigned int exponent: 11;
nkeynes@185
    81
    unsigned int sign : 1;
nkeynes@185
    82
  } nan;
nkeynes@185
    83
  struct 
nkeynes@185
    84
  {
nkeynes@185
    85
    unsigned long lsw;
nkeynes@185
    86
    unsigned long msw;
nkeynes@185
    87
  } parts;
nkeynes@185
    88
nkeynes@185
    89
  long aslong[2];
nkeynes@185
    90
nkeynes@185
    91
} __ieee_double_shape_type;
nkeynes@185
    92
nkeynes@185
    93
#endif
nkeynes@185
    94
nkeynes@185
    95
#ifdef __IEEE_BIG_ENDIAN
nkeynes@185
    96
nkeynes@185
    97
typedef union
nkeynes@185
    98
{
nkeynes@185
    99
  float value;
nkeynes@185
   100
  struct 
nkeynes@185
   101
  {
nkeynes@185
   102
    unsigned int sign : 1;
nkeynes@185
   103
    unsigned int exponent: 8;
nkeynes@185
   104
    unsigned int fraction0: 7;
nkeynes@185
   105
    unsigned int fraction1: 16;
nkeynes@185
   106
  } number;
nkeynes@185
   107
  struct 
nkeynes@185
   108
  {
nkeynes@185
   109
    unsigned int sign:1;
nkeynes@185
   110
    unsigned int exponent:8;
nkeynes@185
   111
    unsigned int quiet:1;
nkeynes@185
   112
    unsigned int function0:6;
nkeynes@185
   113
    unsigned int function1:16;
nkeynes@185
   114
  } nan;
nkeynes@185
   115
  long p1;
nkeynes@185
   116
  
nkeynes@185
   117
} __ieee_float_shape_type;
nkeynes@185
   118
nkeynes@185
   119
#endif
nkeynes@185
   120
nkeynes@185
   121
#ifdef __IEEE_LITTLE_ENDIAN
nkeynes@185
   122
nkeynes@185
   123
typedef union
nkeynes@185
   124
{
nkeynes@185
   125
  float value;
nkeynes@185
   126
  struct 
nkeynes@185
   127
  {
nkeynes@185
   128
    unsigned int fraction0: 7;
nkeynes@185
   129
    unsigned int fraction1: 16;
nkeynes@185
   130
    unsigned int exponent: 8;
nkeynes@185
   131
    unsigned int sign : 1;
nkeynes@185
   132
  } number;
nkeynes@185
   133
  struct 
nkeynes@185
   134
  {
nkeynes@185
   135
    unsigned int function1:16;
nkeynes@185
   136
    unsigned int function0:6;
nkeynes@185
   137
    unsigned int quiet:1;
nkeynes@185
   138
    unsigned int exponent:8;
nkeynes@185
   139
    unsigned int sign:1;
nkeynes@185
   140
  } nan;
nkeynes@185
   141
  long p1;
nkeynes@185
   142
  
nkeynes@185
   143
} __ieee_float_shape_type;
nkeynes@185
   144
nkeynes@185
   145
#endif
nkeynes@185
   146
nkeynes@185
   147
nkeynes@185
   148
nkeynes@185
   149
nkeynes@185
   150
nkeynes@185
   151
/* FLOATING ROUNDING */
nkeynes@185
   152
nkeynes@185
   153
typedef int fp_rnd;
nkeynes@185
   154
#define FP_RN 0 	/* Round to nearest 		*/
nkeynes@185
   155
#define FP_RM 1		/* Round down 			*/
nkeynes@185
   156
#define FP_RP 2		/* Round up 			*/
nkeynes@185
   157
#define FP_RZ 3		/* Round to zero (trunate) 	*/
nkeynes@185
   158
nkeynes@185
   159
fp_rnd _EXFUN(fpgetround,(void));
nkeynes@185
   160
fp_rnd _EXFUN(fpsetround, (fp_rnd));
nkeynes@185
   161
nkeynes@185
   162
/* EXCEPTIONS */
nkeynes@185
   163
nkeynes@185
   164
typedef int fp_except;
nkeynes@185
   165
#define FP_X_INV 0x10	/* Invalid operation 		*/
nkeynes@185
   166
#define FP_X_DX  0x80	/* Divide by zero		*/
nkeynes@185
   167
#define FP_X_OFL 0x04	/* Overflow exception		*/
nkeynes@185
   168
#define FP_X_UFL 0x02	/* Underflow exception		*/
nkeynes@185
   169
#define FP_X_IMP 0x01	/* imprecise exception		*/
nkeynes@185
   170
nkeynes@185
   171
fp_except _EXFUN(fpgetmask,(void));
nkeynes@185
   172
fp_except _EXFUN(fpsetmask,(fp_except));
nkeynes@185
   173
fp_except _EXFUN(fpgetsticky,(void));
nkeynes@185
   174
fp_except _EXFUN(fpsetsticky, (fp_except));
nkeynes@185
   175
nkeynes@185
   176
/* INTEGER ROUNDING */
nkeynes@185
   177
nkeynes@185
   178
typedef int fp_rdi;
nkeynes@185
   179
#define FP_RDI_TOZ 0	/* Round to Zero 		*/
nkeynes@185
   180
#define FP_RDI_RD  1	/* Follow float mode		*/
nkeynes@185
   181
nkeynes@185
   182
fp_rdi _EXFUN(fpgetroundtoi,(void));
nkeynes@185
   183
fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi));
nkeynes@185
   184
nkeynes@185
   185
int _EXFUN(isnan, (double));
nkeynes@185
   186
int _EXFUN(isinf, (double));
nkeynes@185
   187
int _EXFUN(finite, (double));
nkeynes@185
   188
nkeynes@185
   189
nkeynes@185
   190
nkeynes@185
   191
int _EXFUN(isnanf, (float));
nkeynes@185
   192
int _EXFUN(isinff, (float));
nkeynes@185
   193
int _EXFUN(finitef, (float));
nkeynes@185
   194
nkeynes@185
   195
#define __IEEE_DBL_EXPBIAS 1023
nkeynes@185
   196
#define __IEEE_FLT_EXPBIAS 127
nkeynes@185
   197
nkeynes@185
   198
#define __IEEE_DBL_EXPLEN 11
nkeynes@185
   199
#define __IEEE_FLT_EXPLEN 8
nkeynes@185
   200
nkeynes@185
   201
nkeynes@185
   202
#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
nkeynes@185
   203
#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))
nkeynes@185
   204
nkeynes@185
   205
#define __IEEE_DBL_MAXPOWTWO	((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
nkeynes@185
   206
#define __IEEE_FLT_MAXPOWTWO	((float)(1L << (32-8) - 1))
nkeynes@185
   207
nkeynes@185
   208
#define __IEEE_DBL_NAN_EXP 0x7ff
nkeynes@185
   209
#define __IEEE_FLT_NAN_EXP 0xff
nkeynes@185
   210
nkeynes@185
   211
nkeynes@185
   212
#define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
nkeynes@185
   213
		   ((*(long *)&(x) & 0x007fffffL)!=0000000000L))
nkeynes@185
   214
nkeynes@185
   215
#define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
nkeynes@185
   216
		   ((*(long *)&(x) & 0x007fffffL)==0000000000L))
nkeynes@185
   217
nkeynes@185
   218
#define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))
nkeynes@185
   219
nkeynes@185
   220
#ifdef _DOUBLE_IS_32BITS
nkeynes@185
   221
#undef __IEEE_DBL_EXPBIAS
nkeynes@185
   222
#define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS
nkeynes@185
   223
nkeynes@185
   224
#undef __IEEE_DBL_EXPLEN
nkeynes@185
   225
#define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN
nkeynes@185
   226
nkeynes@185
   227
#undef __IEEE_DBL_FRACLEN
nkeynes@185
   228
#define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN
nkeynes@185
   229
nkeynes@185
   230
#undef __IEEE_DBL_MAXPOWTWO
nkeynes@185
   231
#define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO
nkeynes@185
   232
nkeynes@185
   233
#undef __IEEE_DBL_NAN_EXP
nkeynes@185
   234
#define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP
nkeynes@185
   235
nkeynes@185
   236
#undef __ieee_double_shape_type
nkeynes@185
   237
#define __ieee_double_shape_type __ieee_float_shape_type
nkeynes@185
   238
nkeynes@185
   239
#endif /* _DOUBLE_IS_32BITS */
nkeynes@185
   240
nkeynes@185
   241
#endif /* _IEEE_FP_H_ */
.