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