summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch/sparc/gen/fpclassifyl.c
diff options
context:
space:
mode:
authormartynas <martynas@openbsd.org>2008-09-07 20:36:06 +0000
committermartynas <martynas@openbsd.org>2008-09-07 20:36:06 +0000
commit7b36286a70b46b494e2bca4a889ab49ef62ba86c (patch)
treeb2b9870e3495ed88715e57b0d4a9888b16264fe0 /lib/libc/arch/sparc/gen/fpclassifyl.c
parentsparc now requires this bloated library to be -fPIC (diff)
downloadwireguard-openbsd-7b36286a70b46b494e2bca4a889ab49ef62ba86c.tar.xz
wireguard-openbsd-7b36286a70b46b494e2bca4a889ab49ef62ba86c.zip
- replace dtoa w/ David's gdtoa, version 2008-03-15
- provide proper dtoa locks - use the real strtof implementation - add strtold, __hdtoa, __hldtoa - add %a/%A support - don't lose precision in printf, don't round to double anymore - implement extended-precision versions of libc functions: fpclassify, isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is fixed - separate vax versions of strtof, and __hdtoa - add complex math support. added functions: cacos, casin, catan, ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp, clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf, casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf, ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf, cimagf, conjf, cprojf, crealf - add fdim, fmax, fmin - add log2. (adapted implementation e_log.c. could be more acruate & faster, but it's good enough for now) - remove wrappers & cruft in libm, supposed to work-around mistakes in SVID, etc.; use ieee versions. fixes issues in python 2.6 for djm@ - make _digittoint static - proper definitions for i386, and amd64 in ieee.h - sh, powerpc don't really have extended-precision - add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h for LDBL_* - merge lead to frac for m{6,8}k, for gdtoa to work properly - add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa to use - add EXT_IMPLICIT_NBIT definition, which indicates implicit normalization bit - add regression tests for libc: fpclassify and printf - arith.h & gd_qnan.h definitions - update ieee.h: hppa doesn't have quad-precision, hppa64 does - add missing prototypes to gdtoaimp - on 64-bit platforms make sure gdtoa doesn't use a long when it really wants an int - etc., what i may have forgotten... - bump libm major, due to removed&changed symbols - no libc bump, since this is riding on djm's libc major crank from a day ago discussed with / requested by / testing theo, sthen@, djm@, jsg@, merdely@, jsing@, tedu@, brad@, jakemsr@, and others. looks good to millert@ parts of the diff ok kettenis@ this commit does not include: - man page changes
Diffstat (limited to 'lib/libc/arch/sparc/gen/fpclassifyl.c')
-rw-r--r--lib/libc/arch/sparc/gen/fpclassifyl.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/libc/arch/sparc/gen/fpclassifyl.c b/lib/libc/arch/sparc/gen/fpclassifyl.c
new file mode 100644
index 00000000000..d569ef90430
--- /dev/null
+++ b/lib/libc/arch/sparc/gen/fpclassifyl.c
@@ -0,0 +1,44 @@
+/* $OpenBSD: fpclassifyl.c,v 1.1 2008/09/07 20:36:08 martynas Exp $ */
+/*
+ * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+#include <math.h>
+
+int
+__fpclassifyl(long double e)
+{
+ struct ieee_ext *p = (struct ieee_ext *)&e;
+
+ if (p->ext_exp == 0) {
+ if (p->ext_frach == 0 && p->ext_frachm == 0 &&
+ p->ext_fraclm == 0 && p->ext_fracl == 0)
+ return FP_ZERO;
+ else
+ return FP_SUBNORMAL;
+ }
+
+ if (p->ext_exp == EXT_EXP_INFNAN) {
+ if (p->ext_frach == 0 && p->ext_frachm == 0 &&
+ p->ext_fraclm == 0 && p->ext_fracl == 0)
+ return FP_INFINITE;
+ else
+ return FP_NAN;
+ }
+
+ return FP_NORMAL;
+}