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 * finite(x) returns 1 is x is finite, else 0;
14 * no branching!
15 */
16
17#include <math.h>
18#include <math_private.h>
19#include <shlib-compat.h>
20#include <stdint.h>
21
22#undef __finite
23int
24__finite(double x)
25{
26 int64_t lx;
27 EXTRACT_WORDS64(lx,x);
28 return (int)((uint64_t)((lx&INT64_C(0x7ff0000000000000))-INT64_C(0x7ff0000000000000))>>63);
29}
30hidden_def (__finite)
31weak_alias (__finite, finite)
32#ifdef NO_LONG_DOUBLE
33# ifdef LDBL_CLASSIFY_COMPAT
34# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
35compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
36# endif
37# if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_23)
38compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
39# endif
40# endif
41weak_alias (__finite, finitel)
42#endif
43