xref: /netbsd-src/lib/libc/arch/sparc64/gen/isinfl.c (revision acdd726fe56c6fa766e8bdd8ede344b25c712c34)
1*acdd726fSmartin /*	$NetBSD: isinfl.c,v 1.5 2013/11/20 22:22:20 martin Exp $	*/
2712c8de2Skleink 
3712c8de2Skleink /*
4712c8de2Skleink  * Copyright (c) 1992, 1993
5712c8de2Skleink  *	The Regents of the University of California.  All rights reserved.
6712c8de2Skleink  *
7712c8de2Skleink  * This software was developed by the Computer Systems Engineering group
8712c8de2Skleink  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9712c8de2Skleink  * contributed to Berkeley.
10712c8de2Skleink  *
11712c8de2Skleink  * Redistribution and use in source and binary forms, with or without
12712c8de2Skleink  * modification, are permitted provided that the following conditions
13712c8de2Skleink  * are met:
14712c8de2Skleink  * 1. Redistributions of source code must retain the above copyright
15712c8de2Skleink  *    notice, this list of conditions and the following disclaimer.
16712c8de2Skleink  * 2. Redistributions in binary form must reproduce the above copyright
17712c8de2Skleink  *    notice, this list of conditions and the following disclaimer in the
18712c8de2Skleink  *    documentation and/or other materials provided with the distribution.
19712c8de2Skleink  * 3. Neither the name of the University nor the names of its contributors
20712c8de2Skleink  *    may be used to endorse or promote products derived from this software
21712c8de2Skleink  *    without specific prior written permission.
22712c8de2Skleink  *
23712c8de2Skleink  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24712c8de2Skleink  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25712c8de2Skleink  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26712c8de2Skleink  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27712c8de2Skleink  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28712c8de2Skleink  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29712c8de2Skleink  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30712c8de2Skleink  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31712c8de2Skleink  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32712c8de2Skleink  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33712c8de2Skleink  * SUCH DAMAGE.
34712c8de2Skleink  *
35712c8de2Skleink  * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
36712c8de2Skleink  */
37712c8de2Skleink 
38712c8de2Skleink #include <sys/cdefs.h>
39712c8de2Skleink #if defined(LIBC_SCCS) && !defined(lint)
40712c8de2Skleink #if 0
41712c8de2Skleink static char sccsid[] = "@(#)isinf.c	8.1 (Berkeley) 6/4/93";
42712c8de2Skleink #else
43*acdd726fSmartin __RCSID("$NetBSD: isinfl.c,v 1.5 2013/11/20 22:22:20 martin Exp $");
44712c8de2Skleink #endif
45712c8de2Skleink #endif /* LIBC_SCCS and not lint */
46712c8de2Skleink 
47712c8de2Skleink #include <machine/ieee.h>
48712c8de2Skleink #include <math.h>
49712c8de2Skleink 
508e54f10bSkleink /*
518e54f10bSkleink  * 7.12.3.3 isinf - test for infinity
528e54f10bSkleink  *          IEEE 754 compatible 128-bit extended-precision version
538e54f10bSkleink  */
54712c8de2Skleink int
__isinfl(long double x)558e54f10bSkleink __isinfl(long double x)
56712c8de2Skleink {
575976f8aaSkleink 	union ieee_ext_u u;
58712c8de2Skleink 
598e54f10bSkleink 	u.extu_ld = x;
608e54f10bSkleink 
61964d6747Skleink 	return (u.extu_ext.ext_exp == EXT_EXP_INFNAN &&
62*acdd726fSmartin 	    (u.extu_ext.ext_frach  == 0 && u.extu_ext.ext_fracl  == 0));
63712c8de2Skleink }
64