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 /*
27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
31 #include "libm.h"
32
33 #if defined(__sparc)
34 int
35 isinfl(long double x)
36 {
37 int *px = (int *)&x;
38
39 return ((px[0] & ~0x80000000) == 0x7fff0000 && px[1] == 0 && px[2] ==
40 0 && px[3] == 0);
41 }
42
43 int
44 isnormall(long double x)
45 {
46 int *px = (int *)&x;
47
48 return ((unsigned)((px[0] & 0x7fff0000) - 0x10000) < 0x7ffe0000);
49 }
50
51 int
52 issubnormall(long double x)
53 {
54 int *px = (int *)&x;
55
56 px[0] &= ~0x80000000;
57 return (px[0] < 0x00010000 && (px[0] | px[1] | px[2] | px[3]) != 0);
58 }
59
60 int
61 iszerol(long double x)
62 {
63 int *px = (int *)&x;
64
65 return (((px[0] & ~0x80000000) | px[1] | px[2] | px[3]) == 0);
66 }
67
68 int
69 signbitl(long double x)
70 {
71 unsigned *px = (unsigned *)&x;
72
73 return (px[0] >> 31);
74 }
75 #elif defined(__x86)
76 int
77 isinfl(long double x)
78 {
79 int *px = (int *)&x;
80
81 #if defined(HANDLE_UNSUPPORTED)
82 return ((px[2] & 0x7fff) == 0x7fff && ((px[1] ^ 0x80000000) | px[0]) ==
83 0);
84 #else
85 return ((px[2] & 0x7fff) == 0x7fff && ((px[1] & ~0x80000000) | px[0]) ==
86 0);
87 #endif
88 }
89
90 int
91 isnormall(long double x)
92 {
93 int *px = (int *)&x;
94
95 #if defined(HANDLE_UNSUPPORTED)
96 return ((unsigned)((px[2] & 0x7fff) - 1) < 0x7ffe && (px[1] &
97 0x80000000) != 0);
98 #else
99 return ((unsigned)((px[2] & 0x7fff) - 1) < 0x7ffe);
100 #endif
101 }
102
103 int
104 issubnormall(long double x)
105 {
106 int *px = (int *)&x;
107
108 return ((px[2] & 0x7fff) == 0 && (px[0] | px[1]) != 0);
109 }
110
111 int
112 iszerol(long double x)
113 {
114 int *px = (int *)&x;
115
116 return (((px[2] & 0x7fff) | px[0] | px[1]) == 0);
117 }
118
119 int
120 signbitl(long double x)
121 {
122 unsigned *px = (unsigned *)&x;
123
124 return ((px[2] >> 15) & 1);
125 }
126 #endif /* defined(__sparc) || defined(__x86) */