initial commit
[glibc.git] / sysdeps / ieee754 / dbl-64 / s_finite.c
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 <ldbl-classify-compat.h>
20 #include <shlib-compat.h>
21 #include <stdint.h>
22
23 int
24 __finite (double x)
25 {
26 int64_t lx;
27 EXTRACT_WORDS64 (lx,x);
28 return (int)((uint64_t)((lx & INT64_C(0x7ff0000000000000))
29 - INT64_C (0x7ff0000000000000)) >> 63);
30 }
31 hidden_def (__finite)
32 weak_alias (__finite, finite)
33 #ifdef NO_LONG_DOUBLE
34 # if LDBL_CLASSIFY_COMPAT
35 # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
36 compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
37 # endif
38 # if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_23)
39 compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
40 # endif
41 # endif
42 weak_alias (__finite, finitel)
43 #endif