isinfd_ieee754.c revision 1.1
11.1Skleink/*	$NetBSD: isinfd_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $	*/
21.1Skleink
31.1Skleink/*
41.1Skleink * Copyright (c) 1992, 1993
51.1Skleink *	The Regents of the University of California.  All rights reserved.
61.1Skleink *
71.1Skleink * This software was developed by the Computer Systems Engineering group
81.1Skleink * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
91.1Skleink * contributed to Berkeley.
101.1Skleink *
111.1Skleink * Redistribution and use in source and binary forms, with or without
121.1Skleink * modification, are permitted provided that the following conditions
131.1Skleink * are met:
141.1Skleink * 1. Redistributions of source code must retain the above copyright
151.1Skleink *    notice, this list of conditions and the following disclaimer.
161.1Skleink * 2. Redistributions in binary form must reproduce the above copyright
171.1Skleink *    notice, this list of conditions and the following disclaimer in the
181.1Skleink *    documentation and/or other materials provided with the distribution.
191.1Skleink * 3. Neither the name of the University nor the names of its contributors
201.1Skleink *    may be used to endorse or promote products derived from this software
211.1Skleink *    without specific prior written permission.
221.1Skleink *
231.1Skleink * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.1Skleink * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.1Skleink * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.1Skleink * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.1Skleink * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.1Skleink * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.1Skleink * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.1Skleink * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.1Skleink * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.1Skleink * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.1Skleink * SUCH DAMAGE.
341.1Skleink *
351.1Skleink * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
361.1Skleink */
371.1Skleink
381.1Skleink#include <sys/cdefs.h>
391.1Skleink#if defined(LIBC_SCCS) && !defined(lint)
401.1Skleink#if 0
411.1Skleinkstatic char sccsid[] = "@(#)isinf.c	8.1 (Berkeley) 6/4/93";
421.1Skleink#else
431.1Skleink__RCSID("$NetBSD: isinfd_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $");
441.1Skleink#endif
451.1Skleink#endif /* LIBC_SCCS and not lint */
461.1Skleink
471.1Skleink#include <machine/ieee.h>
481.1Skleink#include <math.h>
491.1Skleink
501.1Skleink/* libc.so.12 ABI compatbility */
511.1Skleink#ifdef __weak_alias
521.1Skleink__weak_alias(isinf,__isinfd)
531.1Skleink#endif
541.1Skleink
551.1Skleink/*
561.1Skleink * 7.12.3.3 isinf - test for infinity
571.1Skleink *          IEEE 754 double-precision version
581.1Skleink */
591.1Skleinkint
601.1Skleink__isinfd(double x)
611.1Skleink{
621.1Skleink	union ieee_double_u u;
631.1Skleink
641.1Skleink	u.dblu_d = x;
651.1Skleink
661.1Skleink	return (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN &&
671.1Skleink	    (u.dblu_dbl.dbl_frach == 0 && u.dblu_dbl.dbl_fracl == 0));
681.1Skleink}
69