Subversion Repositories Kolibri OS

Rev

Rev 1906 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1906 Rev 3362
1
/* @(#)fdlibm.h 5.1 93/09/24 */
1
/* @(#)fdlibm.h 5.1 93/09/24 */
2
/*
2
/*
3
 * ====================================================
3
 * ====================================================
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5
 *
5
 *
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
 * Permission to use, copy, modify, and distribute this
7
 * Permission to use, copy, modify, and distribute this
8
 * software is freely granted, provided that this notice 
8
 * software is freely granted, provided that this notice 
9
 * is preserved.
9
 * is preserved.
10
 * ====================================================
10
 * ====================================================
11
 */
11
 */
12
 
12
 
13
/* REDHAT LOCAL: Include files.  */
13
/* REDHAT LOCAL: Include files.  */
14
#include 
14
#include 
15
#include 
15
#include 
16
#include 
16
#include 
17
 
17
 
18
/* REDHAT LOCAL: Default to XOPEN_MODE.  */
18
/* REDHAT LOCAL: Default to XOPEN_MODE.  */
19
#define _XOPEN_MODE
19
#define _XOPEN_MODE
20
 
20
 
21
/* Most routines need to check whether a float is finite, infinite, or not a
21
/* Most routines need to check whether a float is finite, infinite, or not a
22
   number, and many need to know whether the result of an operation will
22
   number, and many need to know whether the result of an operation will
23
   overflow.  These conditions depend on whether the largest exponent is
23
   overflow.  These conditions depend on whether the largest exponent is
24
   used for NaNs & infinities, or whether it's used for finite numbers.  The
24
   used for NaNs & infinities, or whether it's used for finite numbers.  The
25
   macros below wrap up that kind of information:
25
   macros below wrap up that kind of information:
26
 
26
 
27
   FLT_UWORD_IS_FINITE(X)
27
   FLT_UWORD_IS_FINITE(X)
28
	True if a positive float with bitmask X is finite.
28
	True if a positive float with bitmask X is finite.
29
 
29
 
30
   FLT_UWORD_IS_NAN(X)
30
   FLT_UWORD_IS_NAN(X)
31
	True if a positive float with bitmask X is not a number.
31
	True if a positive float with bitmask X is not a number.
32
 
32
 
33
   FLT_UWORD_IS_INFINITE(X)
33
   FLT_UWORD_IS_INFINITE(X)
34
	True if a positive float with bitmask X is +infinity.
34
	True if a positive float with bitmask X is +infinity.
35
 
35
 
36
   FLT_UWORD_MAX
36
   FLT_UWORD_MAX
37
	The bitmask of FLT_MAX.
37
	The bitmask of FLT_MAX.
38
 
38
 
39
   FLT_UWORD_HALF_MAX
39
   FLT_UWORD_HALF_MAX
40
	The bitmask of FLT_MAX/2.
40
	The bitmask of FLT_MAX/2.
41
 
41
 
42
   FLT_UWORD_EXP_MAX
42
   FLT_UWORD_EXP_MAX
43
	The bitmask of the largest finite exponent (129 if the largest
43
	The bitmask of the largest finite exponent (129 if the largest
44
	exponent is used for finite numbers, 128 otherwise).
44
	exponent is used for finite numbers, 128 otherwise).
45
 
45
 
46
   FLT_UWORD_LOG_MAX
46
   FLT_UWORD_LOG_MAX
47
	The bitmask of log(FLT_MAX), rounded down.  This value is the largest
47
	The bitmask of log(FLT_MAX), rounded down.  This value is the largest
48
	input that can be passed to exp() without producing overflow.
48
	input that can be passed to exp() without producing overflow.
49
 
49
 
50
   FLT_UWORD_LOG_2MAX
50
   FLT_UWORD_LOG_2MAX
51
	The bitmask of log(2*FLT_MAX), rounded down.  This value is the
51
	The bitmask of log(2*FLT_MAX), rounded down.  This value is the
52
	largest input than can be passed to cosh() without producing
52
	largest input than can be passed to cosh() without producing
53
	overflow.
53
	overflow.
54
 
54
 
55
   FLT_LARGEST_EXP
55
   FLT_LARGEST_EXP
56
	The largest biased exponent that can be used for finite numbers
56
	The largest biased exponent that can be used for finite numbers
57
	(255 if the largest exponent is used for finite numbers, 254
57
	(255 if the largest exponent is used for finite numbers, 254
58
	otherwise) */
58
	otherwise) */
59
 
59
 
60
#ifdef _FLT_LARGEST_EXPONENT_IS_NORMAL
60
#ifdef _FLT_LARGEST_EXPONENT_IS_NORMAL
61
#define FLT_UWORD_IS_FINITE(x) 1
61
#define FLT_UWORD_IS_FINITE(x) 1
62
#define FLT_UWORD_IS_NAN(x) 0
62
#define FLT_UWORD_IS_NAN(x) 0
63
#define FLT_UWORD_IS_INFINITE(x) 0
63
#define FLT_UWORD_IS_INFINITE(x) 0
64
#define FLT_UWORD_MAX 0x7fffffff
64
#define FLT_UWORD_MAX 0x7fffffff
65
#define FLT_UWORD_EXP_MAX 0x43010000
65
#define FLT_UWORD_EXP_MAX 0x43010000
66
#define FLT_UWORD_LOG_MAX 0x42b2d4fc
66
#define FLT_UWORD_LOG_MAX 0x42b2d4fc
67
#define FLT_UWORD_LOG_2MAX 0x42b437e0
67
#define FLT_UWORD_LOG_2MAX 0x42b437e0
68
#define HUGE ((float)0X1.FFFFFEP128)
68
#define HUGE ((float)0X1.FFFFFEP128)
69
#else
69
#else
70
#define FLT_UWORD_IS_FINITE(x) ((x)<0x7f800000L)
70
#define FLT_UWORD_IS_FINITE(x) ((x)<0x7f800000L)
71
#define FLT_UWORD_IS_NAN(x) ((x)>0x7f800000L)
71
#define FLT_UWORD_IS_NAN(x) ((x)>0x7f800000L)
72
#define FLT_UWORD_IS_INFINITE(x) ((x)==0x7f800000L)
72
#define FLT_UWORD_IS_INFINITE(x) ((x)==0x7f800000L)
73
#define FLT_UWORD_MAX 0x7f7fffffL
73
#define FLT_UWORD_MAX 0x7f7fffffL
74
#define FLT_UWORD_EXP_MAX 0x43000000
74
#define FLT_UWORD_EXP_MAX 0x43000000
75
#define FLT_UWORD_LOG_MAX 0x42b17217
75
#define FLT_UWORD_LOG_MAX 0x42b17217
76
#define FLT_UWORD_LOG_2MAX 0x42b2d4fc
76
#define FLT_UWORD_LOG_2MAX 0x42b2d4fc
77
#define HUGE ((float)3.40282346638528860e+38)
77
#define HUGE ((float)3.40282346638528860e+38)
78
#endif
78
#endif
79
#define FLT_UWORD_HALF_MAX (FLT_UWORD_MAX-(1L<<23))
79
#define FLT_UWORD_HALF_MAX (FLT_UWORD_MAX-(1L<<23))
80
#define FLT_LARGEST_EXP (FLT_UWORD_MAX>>23)
80
#define FLT_LARGEST_EXP (FLT_UWORD_MAX>>23)
81
 
81
 
82
/* Many routines check for zero and subnormal numbers.  Such things depend
82
/* Many routines check for zero and subnormal numbers.  Such things depend
83
   on whether the target supports denormals or not:
83
   on whether the target supports denormals or not:
84
 
84
 
85
   FLT_UWORD_IS_ZERO(X)
85
   FLT_UWORD_IS_ZERO(X)
86
	True if a positive float with bitmask X is +0.	Without denormals,
86
	True if a positive float with bitmask X is +0.	Without denormals,
87
	any float with a zero exponent is a +0 representation.	With
87
	any float with a zero exponent is a +0 representation.	With
88
	denormals, the only +0 representation is a 0 bitmask.
88
	denormals, the only +0 representation is a 0 bitmask.
89
 
89
 
90
   FLT_UWORD_IS_SUBNORMAL(X)
90
   FLT_UWORD_IS_SUBNORMAL(X)
91
	True if a non-zero positive float with bitmask X is subnormal.
91
	True if a non-zero positive float with bitmask X is subnormal.
92
	(Routines should check for zeros first.)
92
	(Routines should check for zeros first.)
93
 
93
 
94
   FLT_UWORD_MIN
94
   FLT_UWORD_MIN
95
	The bitmask of the smallest float above +0.  Call this number
95
	The bitmask of the smallest float above +0.  Call this number
96
	REAL_FLT_MIN...
96
	REAL_FLT_MIN...
97
 
97
 
98
   FLT_UWORD_EXP_MIN
98
   FLT_UWORD_EXP_MIN
99
	The bitmask of the float representation of REAL_FLT_MIN's exponent.
99
	The bitmask of the float representation of REAL_FLT_MIN's exponent.
100
 
100
 
101
   FLT_UWORD_LOG_MIN
101
   FLT_UWORD_LOG_MIN
102
	The bitmask of |log(REAL_FLT_MIN)|, rounding down.
102
	The bitmask of |log(REAL_FLT_MIN)|, rounding down.
103
 
103
 
104
   FLT_SMALLEST_EXP
104
   FLT_SMALLEST_EXP
105
	REAL_FLT_MIN's exponent - EXP_BIAS (1 if denormals are not supported,
105
	REAL_FLT_MIN's exponent - EXP_BIAS (1 if denormals are not supported,
106
	-22 if they are).
106
	-22 if they are).
107
*/
107
*/
108
 
108
 
109
#ifdef _FLT_NO_DENORMALS
109
#ifdef _FLT_NO_DENORMALS
110
#define FLT_UWORD_IS_ZERO(x) ((x)<0x00800000L)
110
#define FLT_UWORD_IS_ZERO(x) ((x)<0x00800000L)
111
#define FLT_UWORD_IS_SUBNORMAL(x) 0
111
#define FLT_UWORD_IS_SUBNORMAL(x) 0
112
#define FLT_UWORD_MIN 0x00800000
112
#define FLT_UWORD_MIN 0x00800000
113
#define FLT_UWORD_EXP_MIN 0x42fc0000
113
#define FLT_UWORD_EXP_MIN 0x42fc0000
114
#define FLT_UWORD_LOG_MIN 0x42aeac50
114
#define FLT_UWORD_LOG_MIN 0x42aeac50
115
#define FLT_SMALLEST_EXP 1
115
#define FLT_SMALLEST_EXP 1
116
#else
116
#else
117
#define FLT_UWORD_IS_ZERO(x) ((x)==0)
117
#define FLT_UWORD_IS_ZERO(x) ((x)==0)
118
#define FLT_UWORD_IS_SUBNORMAL(x) ((x)<0x00800000L)
118
#define FLT_UWORD_IS_SUBNORMAL(x) ((x)<0x00800000L)
119
#define FLT_UWORD_MIN 0x00000001
119
#define FLT_UWORD_MIN 0x00000001
120
#define FLT_UWORD_EXP_MIN 0x43160000
120
#define FLT_UWORD_EXP_MIN 0x43160000
121
#define FLT_UWORD_LOG_MIN 0x42cff1b5
121
#define FLT_UWORD_LOG_MIN 0x42cff1b5
122
#define FLT_SMALLEST_EXP -22
122
#define FLT_SMALLEST_EXP -22
123
#endif
123
#endif
124
 
124
 
125
#ifdef __STDC__
125
#ifdef __STDC__
126
#undef __P
126
#undef __P
127
#define	__P(p)	p
127
#define	__P(p)	p
128
#else
128
#else
129
#define	__P(p)	()
129
#define	__P(p)	()
130
#endif
130
#endif
131
 
131
 
132
/* 
132
/* 
133
 * set X_TLOSS = pi*2**52, which is possibly defined in 
133
 * set X_TLOSS = pi*2**52, which is possibly defined in 
134
 * (one may replace the following line by "#include ")
134
 * (one may replace the following line by "#include ")
135
 */
135
 */
136
 
136
 
137
#define X_TLOSS		1.41484755040568800000e+16 
137
#define X_TLOSS		1.41484755040568800000e+16 
138
 
138
 
139
/* Functions that are not documented, and are not in .  */
139
/* Functions that are not documented, and are not in .  */
140
 
140
 
141
extern double logb __P((double));
-
 
142
#ifdef _SCALB_INT
141
#ifdef _SCALB_INT
143
extern double scalb __P((double, int));
142
extern double scalb __P((double, int));
144
#else
143
#else
145
extern double scalb __P((double, double));
144
extern double scalb __P((double, double));
146
#endif
145
#endif
147
extern double significand __P((double));
146
extern double significand __P((double));
148
 
147
 
149
/* ieee style elementary functions */
148
/* ieee style elementary functions */
150
extern double __ieee754_sqrt __P((double));			
149
extern double __ieee754_sqrt __P((double));			
151
extern double __ieee754_acos __P((double));			
150
extern double __ieee754_acos __P((double));			
152
extern double __ieee754_acosh __P((double));			
151
extern double __ieee754_acosh __P((double));			
153
extern double __ieee754_log __P((double));			
152
extern double __ieee754_log __P((double));			
154
extern double __ieee754_atanh __P((double));			
153
extern double __ieee754_atanh __P((double));			
155
extern double __ieee754_asin __P((double));			
154
extern double __ieee754_asin __P((double));			
156
extern double __ieee754_atan2 __P((double,double));			
155
extern double __ieee754_atan2 __P((double,double));			
157
extern double __ieee754_exp __P((double));
156
extern double __ieee754_exp __P((double));
158
extern double __ieee754_cosh __P((double));
157
extern double __ieee754_cosh __P((double));
159
extern double __ieee754_fmod __P((double,double));
158
extern double __ieee754_fmod __P((double,double));
160
extern double __ieee754_pow __P((double,double));
159
extern double __ieee754_pow __P((double,double));
161
extern double __ieee754_lgamma_r __P((double,int *));
160
extern double __ieee754_lgamma_r __P((double,int *));
162
extern double __ieee754_gamma_r __P((double,int *));
161
extern double __ieee754_gamma_r __P((double,int *));
163
extern double __ieee754_log10 __P((double));
162
extern double __ieee754_log10 __P((double));
164
extern double __ieee754_sinh __P((double));
163
extern double __ieee754_sinh __P((double));
165
extern double __ieee754_hypot __P((double,double));
164
extern double __ieee754_hypot __P((double,double));
166
extern double __ieee754_j0 __P((double));
165
extern double __ieee754_j0 __P((double));
167
extern double __ieee754_j1 __P((double));
166
extern double __ieee754_j1 __P((double));
168
extern double __ieee754_y0 __P((double));
167
extern double __ieee754_y0 __P((double));
169
extern double __ieee754_y1 __P((double));
168
extern double __ieee754_y1 __P((double));
170
extern double __ieee754_jn __P((int,double));
169
extern double __ieee754_jn __P((int,double));
171
extern double __ieee754_yn __P((int,double));
170
extern double __ieee754_yn __P((int,double));
172
extern double __ieee754_remainder __P((double,double));
171
extern double __ieee754_remainder __P((double,double));
173
extern __int32_t __ieee754_rem_pio2 __P((double,double*));
172
extern __int32_t __ieee754_rem_pio2 __P((double,double*));
174
#ifdef _SCALB_INT
173
#ifdef _SCALB_INT
175
extern double __ieee754_scalb __P((double,int));
174
extern double __ieee754_scalb __P((double,int));
176
#else
175
#else
177
extern double __ieee754_scalb __P((double,double));
176
extern double __ieee754_scalb __P((double,double));
178
#endif
177
#endif
179
 
178
 
180
/* fdlibm kernel function */
179
/* fdlibm kernel function */
181
extern double __kernel_standard __P((double,double,int));
180
extern double __kernel_standard __P((double,double,int));
182
extern double __kernel_sin __P((double,double,int));
181
extern double __kernel_sin __P((double,double,int));
183
extern double __kernel_cos __P((double,double));
182
extern double __kernel_cos __P((double,double));
184
extern double __kernel_tan __P((double,double,int));
183
extern double __kernel_tan __P((double,double,int));
185
extern int    __kernel_rem_pio2 __P((double*,double*,int,int,int,const __int32_t*));
184
extern int    __kernel_rem_pio2 __P((double*,double*,int,int,int,const __int32_t*));
186
 
185
 
187
/* Undocumented float functions.  */
186
/* Undocumented float functions.  */
188
extern float logbf __P((float));
187
#ifdef _SCALB_INT
189
#ifdef _SCALB_INT
-
 
190
extern float scalbf __P((float, int));
188
extern float scalbf __P((float, int));
191
#else
189
#else
192
extern float scalbf __P((float, float));
190
extern float scalbf __P((float, float));
193
#endif
191
#endif
194
extern float significandf __P((float));
192
extern float significandf __P((float));
195
 
193
 
196
/* ieee style elementary float functions */
194
/* ieee style elementary float functions */
197
extern float __ieee754_sqrtf __P((float));			
195
extern float __ieee754_sqrtf __P((float));			
198
extern float __ieee754_acosf __P((float));			
196
extern float __ieee754_acosf __P((float));			
199
extern float __ieee754_acoshf __P((float));			
197
extern float __ieee754_acoshf __P((float));			
200
extern float __ieee754_logf __P((float));			
198
extern float __ieee754_logf __P((float));			
201
extern float __ieee754_atanhf __P((float));			
199
extern float __ieee754_atanhf __P((float));			
202
extern float __ieee754_asinf __P((float));			
200
extern float __ieee754_asinf __P((float));			
203
extern float __ieee754_atan2f __P((float,float));			
201
extern float __ieee754_atan2f __P((float,float));			
204
extern float __ieee754_expf __P((float));
202
extern float __ieee754_expf __P((float));
205
extern float __ieee754_coshf __P((float));
203
extern float __ieee754_coshf __P((float));
206
extern float __ieee754_fmodf __P((float,float));
204
extern float __ieee754_fmodf __P((float,float));
207
extern float __ieee754_powf __P((float,float));
205
extern float __ieee754_powf __P((float,float));
208
extern float __ieee754_lgammaf_r __P((float,int *));
206
extern float __ieee754_lgammaf_r __P((float,int *));
209
extern float __ieee754_gammaf_r __P((float,int *));
207
extern float __ieee754_gammaf_r __P((float,int *));
210
extern float __ieee754_log10f __P((float));
208
extern float __ieee754_log10f __P((float));
211
extern float __ieee754_sinhf __P((float));
209
extern float __ieee754_sinhf __P((float));
212
extern float __ieee754_hypotf __P((float,float));
210
extern float __ieee754_hypotf __P((float,float));
213
extern float __ieee754_j0f __P((float));
211
extern float __ieee754_j0f __P((float));
214
extern float __ieee754_j1f __P((float));
212
extern float __ieee754_j1f __P((float));
215
extern float __ieee754_y0f __P((float));
213
extern float __ieee754_y0f __P((float));
216
extern float __ieee754_y1f __P((float));
214
extern float __ieee754_y1f __P((float));
217
extern float __ieee754_jnf __P((int,float));
215
extern float __ieee754_jnf __P((int,float));
218
extern float __ieee754_ynf __P((int,float));
216
extern float __ieee754_ynf __P((int,float));
219
extern float __ieee754_remainderf __P((float,float));
217
extern float __ieee754_remainderf __P((float,float));
220
extern __int32_t __ieee754_rem_pio2f __P((float,float*));
218
extern __int32_t __ieee754_rem_pio2f __P((float,float*));
221
#ifdef _SCALB_INT
219
#ifdef _SCALB_INT
222
extern float __ieee754_scalbf __P((float,int));
220
extern float __ieee754_scalbf __P((float,int));
223
#else
221
#else
224
extern float __ieee754_scalbf __P((float,float));
222
extern float __ieee754_scalbf __P((float,float));
225
#endif
223
#endif
226
 
224
 
227
/* float versions of fdlibm kernel functions */
225
/* float versions of fdlibm kernel functions */
228
extern float __kernel_sinf __P((float,float,int));
226
extern float __kernel_sinf __P((float,float,int));
229
extern float __kernel_cosf __P((float,float));
227
extern float __kernel_cosf __P((float,float));
230
extern float __kernel_tanf __P((float,float,int));
228
extern float __kernel_tanf __P((float,float,int));
231
extern int   __kernel_rem_pio2f __P((float*,float*,int,int,int,const __int32_t*));
229
extern int   __kernel_rem_pio2f __P((float*,float*,int,int,int,const __int32_t*));
232
 
230
 
233
/* The original code used statements like
231
/* The original code used statements like
234
	n0 = ((*(int*)&one)>>29)^1;		* index of high word *
232
	n0 = ((*(int*)&one)>>29)^1;		* index of high word *
235
	ix0 = *(n0+(int*)&x);			* high word of x *
233
	ix0 = *(n0+(int*)&x);			* high word of x *
236
	ix1 = *((1-n0)+(int*)&x);		* low word of x *
234
	ix1 = *((1-n0)+(int*)&x);		* low word of x *
237
   to dig two 32 bit words out of the 64 bit IEEE floating point
235
   to dig two 32 bit words out of the 64 bit IEEE floating point
238
   value.  That is non-ANSI, and, moreover, the gcc instruction
236
   value.  That is non-ANSI, and, moreover, the gcc instruction
239
   scheduler gets it wrong.  We instead use the following macros.
237
   scheduler gets it wrong.  We instead use the following macros.
240
   Unlike the original code, we determine the endianness at compile
238
   Unlike the original code, we determine the endianness at compile
241
   time, not at run time; I don't see much benefit to selecting
239
   time, not at run time; I don't see much benefit to selecting
242
   endianness at run time.  */
240
   endianness at run time.  */
243
 
241
 
244
#ifndef __IEEE_BIG_ENDIAN
242
#ifndef __IEEE_BIG_ENDIAN
245
#ifndef __IEEE_LITTLE_ENDIAN
243
#ifndef __IEEE_LITTLE_ENDIAN
246
 #error Must define endianness
244
 #error Must define endianness
247
#endif
245
#endif
248
#endif
246
#endif
249
 
247
 
250
/* A union which permits us to convert between a double and two 32 bit
248
/* A union which permits us to convert between a double and two 32 bit
251
   ints.  */
249
   ints.  */
252
 
250
 
253
#ifdef __IEEE_BIG_ENDIAN
251
#ifdef __IEEE_BIG_ENDIAN
254
 
252
 
255
typedef union 
253
typedef union 
256
{
254
{
257
  double value;
255
  double value;
258
  struct 
256
  struct 
259
  {
257
  {
260
    __uint32_t msw;
258
    __uint32_t msw;
261
    __uint32_t lsw;
259
    __uint32_t lsw;
262
  } parts;
260
  } parts;
263
} ieee_double_shape_type;
261
} ieee_double_shape_type;
264
 
262
 
265
#endif
263
#endif
266
 
264
 
267
#ifdef __IEEE_LITTLE_ENDIAN
265
#ifdef __IEEE_LITTLE_ENDIAN
268
 
266
 
269
typedef union 
267
typedef union 
270
{
268
{
271
  double value;
269
  double value;
272
  struct 
270
  struct 
273
  {
271
  {
274
    __uint32_t lsw;
272
    __uint32_t lsw;
275
    __uint32_t msw;
273
    __uint32_t msw;
276
  } parts;
274
  } parts;
277
} ieee_double_shape_type;
275
} ieee_double_shape_type;
278
 
276
 
279
#endif
277
#endif
280
 
278
 
281
/* Get two 32 bit ints from a double.  */
279
/* Get two 32 bit ints from a double.  */
282
 
280
 
283
#define EXTRACT_WORDS(ix0,ix1,d)				\
281
#define EXTRACT_WORDS(ix0,ix1,d)				\
284
do {								\
282
do {								\
285
  ieee_double_shape_type ew_u;					\
283
  ieee_double_shape_type ew_u;					\
286
  ew_u.value = (d);						\
284
  ew_u.value = (d);						\
287
  (ix0) = ew_u.parts.msw;					\
285
  (ix0) = ew_u.parts.msw;					\
288
  (ix1) = ew_u.parts.lsw;					\
286
  (ix1) = ew_u.parts.lsw;					\
289
} while (0)
287
} while (0)
290
 
288
 
291
/* Get the more significant 32 bit int from a double.  */
289
/* Get the more significant 32 bit int from a double.  */
292
 
290
 
293
#define GET_HIGH_WORD(i,d)					\
291
#define GET_HIGH_WORD(i,d)					\
294
do {								\
292
do {								\
295
  ieee_double_shape_type gh_u;					\
293
  ieee_double_shape_type gh_u;					\
296
  gh_u.value = (d);						\
294
  gh_u.value = (d);						\
297
  (i) = gh_u.parts.msw;						\
295
  (i) = gh_u.parts.msw;						\
298
} while (0)
296
} while (0)
299
 
297
 
300
/* Get the less significant 32 bit int from a double.  */
298
/* Get the less significant 32 bit int from a double.  */
301
 
299
 
302
#define GET_LOW_WORD(i,d)					\
300
#define GET_LOW_WORD(i,d)					\
303
do {								\
301
do {								\
304
  ieee_double_shape_type gl_u;					\
302
  ieee_double_shape_type gl_u;					\
305
  gl_u.value = (d);						\
303
  gl_u.value = (d);						\
306
  (i) = gl_u.parts.lsw;						\
304
  (i) = gl_u.parts.lsw;						\
307
} while (0)
305
} while (0)
308
 
306
 
309
/* Set a double from two 32 bit ints.  */
307
/* Set a double from two 32 bit ints.  */
310
 
308
 
311
#define INSERT_WORDS(d,ix0,ix1)					\
309
#define INSERT_WORDS(d,ix0,ix1)					\
312
do {								\
310
do {								\
313
  ieee_double_shape_type iw_u;					\
311
  ieee_double_shape_type iw_u;					\
314
  iw_u.parts.msw = (ix0);					\
312
  iw_u.parts.msw = (ix0);					\
315
  iw_u.parts.lsw = (ix1);					\
313
  iw_u.parts.lsw = (ix1);					\
316
  (d) = iw_u.value;						\
314
  (d) = iw_u.value;						\
317
} while (0)
315
} while (0)
318
 
316
 
319
/* Set the more significant 32 bits of a double from an int.  */
317
/* Set the more significant 32 bits of a double from an int.  */
320
 
318
 
321
#define SET_HIGH_WORD(d,v)					\
319
#define SET_HIGH_WORD(d,v)					\
322
do {								\
320
do {								\
323
  ieee_double_shape_type sh_u;					\
321
  ieee_double_shape_type sh_u;					\
324
  sh_u.value = (d);						\
322
  sh_u.value = (d);						\
325
  sh_u.parts.msw = (v);						\
323
  sh_u.parts.msw = (v);						\
326
  (d) = sh_u.value;						\
324
  (d) = sh_u.value;						\
327
} while (0)
325
} while (0)
328
 
326
 
329
/* Set the less significant 32 bits of a double from an int.  */
327
/* Set the less significant 32 bits of a double from an int.  */
330
 
328
 
331
#define SET_LOW_WORD(d,v)					\
329
#define SET_LOW_WORD(d,v)					\
332
do {								\
330
do {								\
333
  ieee_double_shape_type sl_u;					\
331
  ieee_double_shape_type sl_u;					\
334
  sl_u.value = (d);						\
332
  sl_u.value = (d);						\
335
  sl_u.parts.lsw = (v);						\
333
  sl_u.parts.lsw = (v);						\
336
  (d) = sl_u.value;						\
334
  (d) = sl_u.value;						\
337
} while (0)
335
} while (0)
338
 
336
 
339
/* A union which permits us to convert between a float and a 32 bit
337
/* A union which permits us to convert between a float and a 32 bit
340
   int.  */
338
   int.  */
341
 
339
 
342
typedef union
340
typedef union
343
{
341
{
344
  float value;
342
  float value;
345
  __uint32_t word;
343
  __uint32_t word;
346
} ieee_float_shape_type;
344
} ieee_float_shape_type;
347
 
345
 
348
/* Get a 32 bit int from a float.  */
346
/* Get a 32 bit int from a float.  */
349
 
347
 
350
#define GET_FLOAT_WORD(i,d)					\
348
#define GET_FLOAT_WORD(i,d)					\
351
do {								\
349
do {								\
352
  ieee_float_shape_type gf_u;					\
350
  ieee_float_shape_type gf_u;					\
353
  gf_u.value = (d);						\
351
  gf_u.value = (d);						\
354
  (i) = gf_u.word;						\
352
  (i) = gf_u.word;						\
355
} while (0)
353
} while (0)
356
 
354
 
357
/* Set a float from a 32 bit int.  */
355
/* Set a float from a 32 bit int.  */
358
 
356
 
359
#define SET_FLOAT_WORD(d,i)					\
357
#define SET_FLOAT_WORD(d,i)					\
360
do {								\
358
do {								\
361
  ieee_float_shape_type sf_u;					\
359
  ieee_float_shape_type sf_u;					\
362
  sf_u.word = (i);						\
360
  sf_u.word = (i);						\
363
  (d) = sf_u.value;						\
361
  (d) = sf_u.value;						\
364
} while (0)
362
} while (0)
365
#define>
363
 
-
 
364
/* Macros to avoid undefined behaviour that can arise if the amount
-
 
365
   of a shift is exactly equal to the size of the shifted operand.  */
-
 
366
 
-
 
367
#define SAFE_LEFT_SHIFT(op,amt)					\
-
 
368
  (((amt) < 8 * sizeof(op)) ? ((op) << (amt)) : 0)
-
 
369
 
-
 
370
#define SAFE_RIGHT_SHIFT(op,amt)				\
-
 
371
  (((amt) < 8 * sizeof(op)) ? ((op) >> (amt)) : 0)
-
 
372
 
-
 
373
#ifdef  _COMPLEX_H
-
 
374
 
-
 
375
/*
-
 
376
 * Quoting from ISO/IEC 9899:TC2:
-
 
377
 *
-
 
378
 * 6.2.5.13 Types
-
 
379
 * Each complex type has the same representation and alignment requirements as
-
 
380
 * an array type containing exactly two elements of the corresponding real type;
-
 
381
 * the first element is equal to the real part, and the second element to the
-
 
382
 * imaginary part, of the complex number.
-
 
383
 */
-
 
384
typedef union {
-
 
385
        float complex z;
-
 
386
        float parts[2];
-
 
387
} float_complex;
-
 
388
 
-
 
389
typedef union {
-
 
390
        double complex z;
-
 
391
        double parts[2];
-
 
392
} double_complex;
-
 
393
 
-
 
394
typedef union {
-
 
395
        long double complex z;
-
 
396
        long double parts[2];
-
 
397
} long_double_complex;
-
 
398
 
-
 
399
#define REAL_PART(z)    ((z).parts[0])
-
 
400
#define IMAG_PART(z)    ((z).parts[1])
-
 
401
 
-
 
402
#endif  /* _COMPLEX_H */
-
 
403
#define>
-
 
404
#define>
366
#define>
405
#define>
367
#define>
406
#define>
368
#define>
407
#define>
369
#define>
-