1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25 /*
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #include "libm.h"
31
32 #if defined(__sparc)
33 int
isinfl(long double x)34 isinfl(long double x) {
35 int *px = (int *) &x;
36 return ((px[0] & ~0x80000000) == 0x7fff0000 && px[1] == 0 &&
37 px[2] == 0 && px[3] == 0);
38 }
39
40 int
isnormall(long double x)41 isnormall(long double x) {
42 int *px = (int *) &x;
43 return ((unsigned) ((px[0] & 0x7fff0000) - 0x10000) < 0x7ffe0000);
44 }
45
46 int
issubnormall(long double x)47 issubnormall(long double x) {
48 int *px = (int *) &x;
49 px[0] &= ~0x80000000;
50 return (px[0] < 0x00010000 && (px[0] | px[1] | px[2] | px[3]) != 0);
51 }
52
53 int
iszerol(long double x)54 iszerol(long double x) {
55 int *px = (int *) &x;
56 return (((px[0] & ~0x80000000) | px[1] | px[2] | px[3]) == 0);
57 }
58
59 int
signbitl(long double x)60 signbitl(long double x) {
61 unsigned *px = (unsigned *) &x;
62 return (px[0] >> 31);
63 }
64 #elif defined(__x86)
65 int
isinfl(long double x)66 isinfl(long double x) {
67 int *px = (int *) &x;
68 #if defined(HANDLE_UNSUPPORTED)
69 return ((px[2] & 0x7fff) == 0x7fff &&
70 ((px[1] ^ 0x80000000) | px[0]) == 0);
71 #else
72 return ((px[2] & 0x7fff) == 0x7fff &&
73 ((px[1] & ~0x80000000) | px[0]) == 0);
74 #endif
75 }
76
77 int
isnormall(long double x)78 isnormall(long double x) {
79 int *px = (int *) &x;
80 #if defined(HANDLE_UNSUPPORTED)
81 return ((unsigned) ((px[2] & 0x7fff) - 1) < 0x7ffe &&
82 (px[1] & 0x80000000) != 0);
83 #else
84 return ((unsigned) ((px[2] & 0x7fff) - 1) < 0x7ffe);
85 #endif
86 }
87
88 int
issubnormall(long double x)89 issubnormall(long double x) {
90 int *px = (int *) &x;
91 return ((px[2] & 0x7fff) == 0 && (px[0] | px[1]) != 0);
92 }
93
94 int
iszerol(long double x)95 iszerol(long double x) {
96 int *px = (int *) &x;
97 return (((px[2] & 0x7fff) | px[0] | px[1]) == 0);
98 }
99
100 int
signbitl(long double x)101 signbitl(long double x) {
102 unsigned *px = (unsigned *) &x;
103 return ((px[2] >> 15) & 1);
104 }
105 #endif /* defined(__sparc) || defined(__x86) */
106