xref: /openbsd-src/lib/libc/arch/amd64/gen/isinfl.c (revision 4914100a9a976afb8e70010709918b347d2eae89)
1*4914100aSmartynas /*	$OpenBSD: isinfl.c,v 1.2 2008/12/09 19:52:33 martynas Exp $	*/
27b36286aSmartynas /*
37b36286aSmartynas  * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org>
47b36286aSmartynas  *
57b36286aSmartynas  * Permission to use, copy, modify, and distribute this software for any
67b36286aSmartynas  * purpose with or without fee is hereby granted, provided that the above
77b36286aSmartynas  * copyright notice and this permission notice appear in all copies.
87b36286aSmartynas  *
97b36286aSmartynas  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
107b36286aSmartynas  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
117b36286aSmartynas  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
127b36286aSmartynas  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
137b36286aSmartynas  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
147b36286aSmartynas  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
157b36286aSmartynas  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
167b36286aSmartynas  */
177b36286aSmartynas 
187b36286aSmartynas #include <sys/types.h>
197b36286aSmartynas #include <machine/ieee.h>
20*4914100aSmartynas #include <math.h>
217b36286aSmartynas 
227b36286aSmartynas int
__isinfl(long double e)237b36286aSmartynas __isinfl(long double e)
247b36286aSmartynas {
257b36286aSmartynas 	struct ieee_ext *p = (struct ieee_ext *)&e;
267b36286aSmartynas 
277b36286aSmartynas 	p->ext_frach &= ~0x80000000;	/* clear normalization bit */
287b36286aSmartynas 
297b36286aSmartynas 	return (p->ext_exp == EXT_EXP_INFNAN &&
307b36286aSmartynas 	    p->ext_frach == 0 && p->ext_fracl == 0);
317b36286aSmartynas }
32