mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-23 13:30:06 +00:00
6f9a3dd8b8
The general rule in glibc is that it's better for a macro to be always defined, and tested with #if, than for it to be tested with #ifdef, because the latter is prone to typos in the macro name as well as to the header with the macro accidentally not being included in a file testing it. (Testing with an "if" statement is even better, in those cases where it's possible to do things that way, as it then means both cases in the code get checked for syntax in glibc builds with either value of the condition.) math_private.h has several different groups of macros, meaning that architectures wanting to override some of them need to define those then include the generic version, which then defines macros if not already defined. It's hard to avoid that arrangement completely, but various cases can be improved by splitting out macros or groups of macros into separate files. This patch splits out the LDBL_CLASSIFY_COMPAT macro into a separate ldbl-classify-compat.h header. This macro is tested with #ifdef; this patch changes it to testing with #if, with a default definition to 0 in the generic header and then architecture-specific headers defining it to 1. Tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by the patch. * sysdeps/generic/ldbl-classify-compat.h: New file. * sysdeps/arm/ldbl-classify-compat.h: Likewise. * sysdeps/m68k/coldfire/ldbl-classify-compat.h: Likewise. * sysdeps/microblaze/ldbl-classify-compat.h: Likewise. * sysdeps/mips/ldbl-classify-compat.h: Likewise. * sysdeps/nios2/ldbl-classify-compat.h: Likewise. * sysdeps/sh/ldbl-classify-compat.h: Likewise. * sysdeps/ieee754/dbl-64/s_finite.c: Include <ldbl-classify-compat.h>. [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined. * sysdeps/ieee754/dbl-64/s_isinf.c: Include <ldbl-classify-compat.h>. [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined. * sysdeps/ieee754/dbl-64/s_isnan.c: Include <ldbl-classify-compat.h>. [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined. * sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c: Include <ldbl-classify-compat.h>. [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined. * sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c: Include <ldbl-classify-compat.h>. [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined. * sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c: Include <ldbl-classify-compat.h>. [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined. * sysdeps/arm/math_private.h (LDBL_CLASSIFY_COMPAT): Remove macro. * sysdeps/mips/math_private.h (LDBL_CLASSIFY_COMPAT): Likewise. * sysdeps/m68k/coldfire/math_private.h: Remove file. * sysdeps/microblaze/math_private.h: Likewise. * sysdeps/nios2/math_private.h: Likewise. * sysdeps/sh/math_private.h: Likewise.
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/* @(#)s_isnan.c 5.1 93/09/24 */
|
|
/*
|
|
* ====================================================
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
*
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
* Permission to use, copy, modify, and distribute this
|
|
* software is freely granted, provided that this notice
|
|
* is preserved.
|
|
* ====================================================
|
|
*/
|
|
|
|
#if defined(LIBM_SCCS) && !defined(lint)
|
|
static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
|
|
#endif
|
|
|
|
/*
|
|
* isnan(x) returns 1 is x is nan, else 0;
|
|
* no branching!
|
|
*/
|
|
|
|
#include <math.h>
|
|
#include <math_private.h>
|
|
#include <ldbl-classify-compat.h>
|
|
#include <shlib-compat.h>
|
|
|
|
#undef __isnan
|
|
int
|
|
__isnan (double x)
|
|
{
|
|
int32_t hx, lx;
|
|
EXTRACT_WORDS (hx, lx, x);
|
|
hx &= 0x7fffffff;
|
|
hx |= (uint32_t) (lx | (-lx)) >> 31;
|
|
hx = 0x7ff00000 - hx;
|
|
return (int) (((uint32_t) hx) >> 31);
|
|
}
|
|
hidden_def (__isnan)
|
|
weak_alias (__isnan, isnan)
|
|
#ifdef NO_LONG_DOUBLE
|
|
# if LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
|
|
compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
|
|
# endif
|
|
weak_alias (__isnan, isnanl)
|
|
#endif
|