xref: /openbsd/lib/libc/arch/sparc64/gen/fpclassifyl.c (revision af3276d5)
1*af3276d5Sguenther /*	$OpenBSD: fpclassifyl.c,v 1.2 2015/10/27 05:54:49 guenther 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>
207b36286aSmartynas #include <math.h>
217b36286aSmartynas 
227b36286aSmartynas int
__fpclassifyl(long double e)237b36286aSmartynas __fpclassifyl(long double e)
247b36286aSmartynas {
257b36286aSmartynas 	struct ieee_ext *p = (struct ieee_ext *)&e;
267b36286aSmartynas 
277b36286aSmartynas 	if (p->ext_exp == 0) {
287b36286aSmartynas 		if (p->ext_frach == 0 && p->ext_frachm == 0 &&
297b36286aSmartynas 		    p->ext_fraclm == 0 && p->ext_fracl == 0)
307b36286aSmartynas 			return FP_ZERO;
317b36286aSmartynas 		else
327b36286aSmartynas 			return FP_SUBNORMAL;
337b36286aSmartynas 	}
347b36286aSmartynas 
357b36286aSmartynas 	if (p->ext_exp == EXT_EXP_INFNAN) {
367b36286aSmartynas 		if (p->ext_frach == 0 && p->ext_frachm == 0 &&
377b36286aSmartynas 		    p->ext_fraclm == 0 && p->ext_fracl == 0)
387b36286aSmartynas 			return FP_INFINITE;
397b36286aSmartynas 		else
407b36286aSmartynas 			return FP_NAN;
417b36286aSmartynas 	}
427b36286aSmartynas 
437b36286aSmartynas 	return FP_NORMAL;
447b36286aSmartynas }
45*af3276d5Sguenther DEF_STRONG(__fpclassifyl);
46