mirror of
https://sourceware.org/git/glibc.git
synced 2025-05-19 05:53:43 +03:00
Make inline __isnan, __isinf_ns, __finite generic.
For code generation to stay identical on x86_64, this requires that we define the fp word manipulation macros before including the generic header.
This commit is contained in:
parent
e79d442ee6
commit
4851a949b4
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
2012-03-19 Richard Henderson <rth@twiddle.net>
|
||||||
|
|
||||||
|
* sysdeps/generic/math_private.h (GET_HIGH_WORD): Define only if
|
||||||
|
not previously defined.
|
||||||
|
(GET_LOW_WORD, EXTRACT_WORDS64, INSERT_WORDS): Likewise.
|
||||||
|
(INSERT_WORDS64, SET_HIGH_WORD, SET_LOW_WORD): Likewise.
|
||||||
|
(GET_FLOAT_WORD, SET_FLOAT_WORD): Likewise.
|
||||||
|
* sysdeps/ieee754/dbl-64/wordsize-64/math_private.h: New file.
|
||||||
|
* sysdeps/ieee754/flt-32/math_private.h: New file.
|
||||||
|
* sysdeps/x86_64/fpu/math_private.h: Move the include_next of
|
||||||
|
math_private.h below SET_FLOAT_WORD.
|
||||||
|
(__isnan, __isinf_ns, __finite): Remove.
|
||||||
|
(__isnanf, __isinf_nsf, __finitef): Remove.
|
||||||
|
|
||||||
2012-03-18 Andreas Schwab <schwab@linux-m68k.org>
|
2012-03-18 Andreas Schwab <schwab@linux-m68k.org>
|
||||||
|
|
||||||
* sysdeps/powerpc/fpu/libm-test-ulps: Update.
|
* sysdeps/powerpc/fpu/libm-test-ulps: Update.
|
||||||
|
@ -76,32 +76,38 @@ do { \
|
|||||||
|
|
||||||
/* Get the more significant 32 bit int from a double. */
|
/* Get the more significant 32 bit int from a double. */
|
||||||
|
|
||||||
|
#ifndef GET_HIGH_WORD
|
||||||
# define GET_HIGH_WORD(i,d) \
|
# define GET_HIGH_WORD(i,d) \
|
||||||
do { \
|
do { \
|
||||||
ieee_double_shape_type gh_u; \
|
ieee_double_shape_type gh_u; \
|
||||||
gh_u.value = (d); \
|
gh_u.value = (d); \
|
||||||
(i) = gh_u.parts.msw; \
|
(i) = gh_u.parts.msw; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get the less significant 32 bit int from a double. */
|
/* Get the less significant 32 bit int from a double. */
|
||||||
|
|
||||||
|
#ifndef GET_LOW_WORD
|
||||||
# define GET_LOW_WORD(i,d) \
|
# define GET_LOW_WORD(i,d) \
|
||||||
do { \
|
do { \
|
||||||
ieee_double_shape_type gl_u; \
|
ieee_double_shape_type gl_u; \
|
||||||
gl_u.value = (d); \
|
gl_u.value = (d); \
|
||||||
(i) = gl_u.parts.lsw; \
|
(i) = gl_u.parts.lsw; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get all in one, efficient on 64-bit machines. */
|
/* Get all in one, efficient on 64-bit machines. */
|
||||||
|
#ifndef EXTRACT_WORDS64
|
||||||
# define EXTRACT_WORDS64(i,d) \
|
# define EXTRACT_WORDS64(i,d) \
|
||||||
do { \
|
do { \
|
||||||
ieee_double_shape_type gh_u; \
|
ieee_double_shape_type gh_u; \
|
||||||
gh_u.value = (d); \
|
gh_u.value = (d); \
|
||||||
(i) = gh_u.word; \
|
(i) = gh_u.word; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Set a double from two 32 bit ints. */
|
/* Set a double from two 32 bit ints. */
|
||||||
|
#ifndef INSERT_WORDS
|
||||||
# define INSERT_WORDS(d,ix0,ix1) \
|
# define INSERT_WORDS(d,ix0,ix1) \
|
||||||
do { \
|
do { \
|
||||||
ieee_double_shape_type iw_u; \
|
ieee_double_shape_type iw_u; \
|
||||||
@ -109,17 +115,20 @@ do { \
|
|||||||
iw_u.parts.lsw = (ix1); \
|
iw_u.parts.lsw = (ix1); \
|
||||||
(d) = iw_u.value; \
|
(d) = iw_u.value; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get all in one, efficient on 64-bit machines. */
|
/* Get all in one, efficient on 64-bit machines. */
|
||||||
|
#ifndef INSERT_WORDS64
|
||||||
# define INSERT_WORDS64(d,i) \
|
# define INSERT_WORDS64(d,i) \
|
||||||
do { \
|
do { \
|
||||||
ieee_double_shape_type iw_u; \
|
ieee_double_shape_type iw_u; \
|
||||||
iw_u.word = (i); \
|
iw_u.word = (i); \
|
||||||
(d) = iw_u.value; \
|
(d) = iw_u.value; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Set the more significant 32 bits of a double from an int. */
|
/* Set the more significant 32 bits of a double from an int. */
|
||||||
|
#ifndef SET_HIGH_WORD
|
||||||
#define SET_HIGH_WORD(d,v) \
|
#define SET_HIGH_WORD(d,v) \
|
||||||
do { \
|
do { \
|
||||||
ieee_double_shape_type sh_u; \
|
ieee_double_shape_type sh_u; \
|
||||||
@ -127,9 +136,10 @@ do { \
|
|||||||
sh_u.parts.msw = (v); \
|
sh_u.parts.msw = (v); \
|
||||||
(d) = sh_u.value; \
|
(d) = sh_u.value; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Set the less significant 32 bits of a double from an int. */
|
/* Set the less significant 32 bits of a double from an int. */
|
||||||
|
#ifndef SET_LOW_WORD
|
||||||
# define SET_LOW_WORD(d,v) \
|
# define SET_LOW_WORD(d,v) \
|
||||||
do { \
|
do { \
|
||||||
ieee_double_shape_type sl_u; \
|
ieee_double_shape_type sl_u; \
|
||||||
@ -137,6 +147,7 @@ do { \
|
|||||||
sl_u.parts.lsw = (v); \
|
sl_u.parts.lsw = (v); \
|
||||||
(d) = sl_u.value; \
|
(d) = sl_u.value; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* A union which permits us to convert between a float and a 32 bit
|
/* A union which permits us to convert between a float and a 32 bit
|
||||||
int. */
|
int. */
|
||||||
@ -148,22 +159,24 @@ typedef union
|
|||||||
} ieee_float_shape_type;
|
} ieee_float_shape_type;
|
||||||
|
|
||||||
/* Get a 32 bit int from a float. */
|
/* Get a 32 bit int from a float. */
|
||||||
|
#ifndef GET_FLOAT_WORD
|
||||||
# define GET_FLOAT_WORD(i,d) \
|
# define GET_FLOAT_WORD(i,d) \
|
||||||
do { \
|
do { \
|
||||||
ieee_float_shape_type gf_u; \
|
ieee_float_shape_type gf_u; \
|
||||||
gf_u.value = (d); \
|
gf_u.value = (d); \
|
||||||
(i) = gf_u.word; \
|
(i) = gf_u.word; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Set a float from a 32 bit int. */
|
/* Set a float from a 32 bit int. */
|
||||||
|
#ifndef SET_FLOAT_WORD
|
||||||
# define SET_FLOAT_WORD(d,i) \
|
# define SET_FLOAT_WORD(d,i) \
|
||||||
do { \
|
do { \
|
||||||
ieee_float_shape_type sf_u; \
|
ieee_float_shape_type sf_u; \
|
||||||
sf_u.word = (i); \
|
sf_u.word = (i); \
|
||||||
(d) = sf_u.value; \
|
(d) = sf_u.value; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get long double macros from a separate header. */
|
/* Get long double macros from a separate header. */
|
||||||
#include <math_ldbl.h>
|
#include <math_ldbl.h>
|
||||||
|
35
sysdeps/ieee754/dbl-64/wordsize-64/math_private.h
Normal file
35
sysdeps/ieee754/dbl-64/wordsize-64/math_private.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef _MATH_PRIVATE_H_
|
||||||
|
|
||||||
|
#include_next <math_private.h>
|
||||||
|
|
||||||
|
#ifndef __isnan
|
||||||
|
extern __always_inline int
|
||||||
|
__isnan (double d)
|
||||||
|
{
|
||||||
|
uint64_t di;
|
||||||
|
EXTRACT_WORDS64 (di, d);
|
||||||
|
return (di & 0x7fffffffffffffffull) > 0x7ff0000000000000ull;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __isinf_ns
|
||||||
|
extern __always_inline int
|
||||||
|
__isinf_ns (double d)
|
||||||
|
{
|
||||||
|
uint64_t di;
|
||||||
|
EXTRACT_WORDS64 (di, d);
|
||||||
|
return (di & 0x7fffffffffffffffull) == 0x7ff0000000000000ull;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __finite
|
||||||
|
extern __always_inline int
|
||||||
|
__finite (double d)
|
||||||
|
{
|
||||||
|
uint64_t di;
|
||||||
|
EXTRACT_WORDS64 (di, d);
|
||||||
|
return (di & 0x7fffffffffffffffull) < 0x7ff0000000000000ull;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _MATH_PRIVATE_H_ */
|
35
sysdeps/ieee754/flt-32/math_private.h
Normal file
35
sysdeps/ieee754/flt-32/math_private.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef _MATH_PRIVATE_H_
|
||||||
|
|
||||||
|
#include_next <math_private.h>
|
||||||
|
|
||||||
|
#ifndef __isnanf
|
||||||
|
extern __always_inline int
|
||||||
|
__isnanf (float d)
|
||||||
|
{
|
||||||
|
u_int32_t di;
|
||||||
|
GET_FLOAT_WORD (di, d);
|
||||||
|
return (di & 0x7fffffff) > 0x7f800000;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __isinf_nsf
|
||||||
|
extern __always_inline int
|
||||||
|
__isinf_nsf (float d)
|
||||||
|
{
|
||||||
|
u_int32_t di;
|
||||||
|
GET_FLOAT_WORD (di, d);
|
||||||
|
return (di & 0x7fffffff) == 0x7f800000;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __finitef
|
||||||
|
extern __always_inline int
|
||||||
|
__finitef (float d)
|
||||||
|
{
|
||||||
|
u_int32_t di;
|
||||||
|
GET_FLOAT_WORD (di, d);
|
||||||
|
return (di & 0x7fffffff) < 0x7f800000;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _MATH_PRIVATE_H_ */
|
@ -16,8 +16,6 @@
|
|||||||
__asm __volatile ("" : : "f" (x)); \
|
__asm __volatile ("" : : "f" (x)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#include_next <math_private.h>
|
|
||||||
|
|
||||||
/* We can do a few things better on x86-64. */
|
/* We can do a few things better on x86-64. */
|
||||||
|
|
||||||
#if defined __AVX__ || defined SSE2AVX
|
#if defined __AVX__ || defined SSE2AVX
|
||||||
@ -31,7 +29,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Direct movement of float into integer register. */
|
/* Direct movement of float into integer register. */
|
||||||
#undef EXTRACT_WORDS64
|
|
||||||
#define EXTRACT_WORDS64(i, d) \
|
#define EXTRACT_WORDS64(i, d) \
|
||||||
do { \
|
do { \
|
||||||
long int i_; \
|
long int i_; \
|
||||||
@ -40,7 +37,6 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* And the reverse. */
|
/* And the reverse. */
|
||||||
#undef INSERT_WORDS64
|
|
||||||
#define INSERT_WORDS64(d, i) \
|
#define INSERT_WORDS64(d, i) \
|
||||||
do { \
|
do { \
|
||||||
long int i_ = i; \
|
long int i_ = i; \
|
||||||
@ -50,7 +46,6 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Direct movement of float into integer register. */
|
/* Direct movement of float into integer register. */
|
||||||
#undef GET_FLOAT_WORD
|
|
||||||
#define GET_FLOAT_WORD(i, d) \
|
#define GET_FLOAT_WORD(i, d) \
|
||||||
do { \
|
do { \
|
||||||
int i_; \
|
int i_; \
|
||||||
@ -59,7 +54,6 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* And the reverse. */
|
/* And the reverse. */
|
||||||
#undef SET_FLOAT_WORD
|
|
||||||
#define SET_FLOAT_WORD(f, i) \
|
#define SET_FLOAT_WORD(f, i) \
|
||||||
do { \
|
do { \
|
||||||
int i_ = i; \
|
int i_ = i; \
|
||||||
@ -68,27 +62,7 @@
|
|||||||
f = f__; \
|
f = f__; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#include_next <math_private.h>
|
||||||
#define __isnan(d) \
|
|
||||||
({ long int __di; EXTRACT_WORDS64 (__di, (double) (d)); \
|
|
||||||
(__di & 0x7fffffffffffffffl) > 0x7ff0000000000000l; })
|
|
||||||
#define __isnanf(d) \
|
|
||||||
({ int __di; GET_FLOAT_WORD (__di, (float) d); \
|
|
||||||
(__di & 0x7fffffff) > 0x7f800000; })
|
|
||||||
|
|
||||||
#define __isinf_ns(d) \
|
|
||||||
({ long int __di; EXTRACT_WORDS64 (__di, (double) (d)); \
|
|
||||||
(__di & 0x7fffffffffffffffl) == 0x7ff0000000000000l; })
|
|
||||||
#define __isinf_nsf(d) \
|
|
||||||
({ int __di; GET_FLOAT_WORD (__di, (float) d); \
|
|
||||||
(__di & 0x7fffffff) == 0x7f800000; })
|
|
||||||
|
|
||||||
#define __finite(d) \
|
|
||||||
({ long int __di; EXTRACT_WORDS64 (__di, (double) (d)); \
|
|
||||||
(__di & 0x7fffffffffffffffl) < 0x7ff0000000000000l; })
|
|
||||||
#define __finitef(d) \
|
|
||||||
({ int __di; GET_FLOAT_WORD (__di, (float) d); \
|
|
||||||
(__di & 0x7fffffff) < 0x7f800000; })
|
|
||||||
|
|
||||||
extern __always_inline double
|
extern __always_inline double
|
||||||
__ieee754_sqrt (double d)
|
__ieee754_sqrt (double d)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user