math_private.h (186461) | math_private.h (189803) |
---|---|
1/* 2 * ==================================================== 3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 * 5 * Developed at SunPro, a Sun Microsystems, Inc. business. 6 * Permission to use, copy, modify, and distribute this 7 * software is freely granted, provided that this notice 8 * is preserved. 9 * ==================================================== 10 */ 11 12/* 13 * from: @(#)fdlibm.h 5.1 93/09/24 | 1/* 2 * ==================================================== 3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 * 5 * Developed at SunPro, a Sun Microsystems, Inc. business. 6 * Permission to use, copy, modify, and distribute this 7 * software is freely granted, provided that this notice 8 * is preserved. 9 * ==================================================== 10 */ 11 12/* 13 * from: @(#)fdlibm.h 5.1 93/09/24 |
14 * $FreeBSD: head/lib/msun/src/math_private.h 186461 2008-12-23 22:20:59Z marcel $ | 14 * $FreeBSD: head/lib/msun/src/math_private.h 189803 2009-03-14 18:24:15Z das $ |
15 */ 16 17#ifndef _MATH_PRIVATE_H_ 18#define _MATH_PRIVATE_H_ 19 20#include <sys/types.h> 21#include <machine/endian.h> 22 --- 162 unchanged lines hidden (view full) --- 185#endif 186 187/* 188 * Common routine to process the arguments to nan(), nanf(), and nanl(). 189 */ 190void _scan_nan(uint32_t *__words, int __num_words, const char *__s); 191 192#ifdef _COMPLEX_H | 15 */ 16 17#ifndef _MATH_PRIVATE_H_ 18#define _MATH_PRIVATE_H_ 19 20#include <sys/types.h> 21#include <machine/endian.h> 22 --- 162 unchanged lines hidden (view full) --- 185#endif 186 187/* 188 * Common routine to process the arguments to nan(), nanf(), and nanl(). 189 */ 190void _scan_nan(uint32_t *__words, int __num_words, const char *__s); 191 192#ifdef _COMPLEX_H |
193 |
|
193/* | 194/* |
195 * C99 specifies that complex numbers have the same representation as 196 * an array of two elements, where the first element is the real part 197 * and the second element is the imaginary part. 198 */ 199typedef union { 200 float complex f; 201 float a[2]; 202} float_complex; 203typedef union { 204 double complex f; 205 double a[2]; 206} double_complex; 207typedef union { 208 long double complex f; 209 long double a[2]; 210} long_double_complex; 211#define REALPART(z) ((z).a[0]) 212#define IMAGPART(z) ((z).a[1]) 213 214/* |
|
194 * Inline functions that can be used to construct complex values. 195 * 196 * The C99 standard intends x+I*y to be used for this, but x+I*y is 197 * currently unusable in general since gcc introduces many overflow, 198 * underflow, sign and efficiency bugs by rewriting I*y as 199 * (0.0+I)*(y+0.0*I) and laboriously computing the full complex product. 200 * In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted 201 * to -0.0+I*0.0. 202 */ 203static __inline float complex 204cpackf(float x, float y) 205{ | 215 * Inline functions that can be used to construct complex values. 216 * 217 * The C99 standard intends x+I*y to be used for this, but x+I*y is 218 * currently unusable in general since gcc introduces many overflow, 219 * underflow, sign and efficiency bugs by rewriting I*y as 220 * (0.0+I)*(y+0.0*I) and laboriously computing the full complex product. 221 * In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted 222 * to -0.0+I*0.0. 223 */ 224static __inline float complex 225cpackf(float x, float y) 226{ |
206 float complex z; | 227 float_complex z; |
207 | 228 |
208 __real__ z = x; 209 __imag__ z = y; 210 return (z); | 229 REALPART(z) = x; 230 IMAGPART(z) = y; 231 return (z.f); |
211} 212 213static __inline double complex 214cpack(double x, double y) 215{ | 232} 233 234static __inline double complex 235cpack(double x, double y) 236{ |
216 double complex z; | 237 double_complex z; |
217 | 238 |
218 __real__ z = x; 219 __imag__ z = y; 220 return (z); | 239 REALPART(z) = x; 240 IMAGPART(z) = y; 241 return (z.f); |
221} 222 223static __inline long double complex 224cpackl(long double x, long double y) 225{ | 242} 243 244static __inline long double complex 245cpackl(long double x, long double y) 246{ |
226 long double complex z; | 247 long_double_complex z; |
227 | 248 |
228 __real__ z = x; 229 __imag__ z = y; 230 return (z); | 249 REALPART(z) = x; 250 IMAGPART(z) = y; 251 return (z.f); |
231} 232#endif /* _COMPLEX_H */ 233 234#ifdef __GNUCLIKE_ASM 235 236/* Asm versions of some functions. */ 237 238#ifdef __amd64__ --- 105 unchanged lines hidden --- | 252} 253#endif /* _COMPLEX_H */ 254 255#ifdef __GNUCLIKE_ASM 256 257/* Asm versions of some functions. */ 258 259#ifdef __amd64__ --- 105 unchanged lines hidden --- |