aboutsummaryrefslogtreecommitdiff
path: root/newlib/libm/common/s_fpclassify.c
diff options
context:
space:
mode:
authorThomas Fitzsimmons <fitzsim@redhat.com>2002-06-07 21:59:57 +0000
committerThomas Fitzsimmons <fitzsim@redhat.com>2002-06-07 21:59:57 +0000
commit0953fe640f177b565578ed7ecc77169ec1a914fa (patch)
treef63c2a55e4d0e5a067da91cea95ae88a7c15af7e /newlib/libm/common/s_fpclassify.c
parent2bd6505b3991588a15c865618e1edb76d4a6373c (diff)
downloadnewlib-0953fe640f177b565578ed7ecc77169ec1a914fa.zip
newlib-0953fe640f177b565578ed7ecc77169ec1a914fa.tar.gz
newlib-0953fe640f177b565578ed7ecc77169ec1a914fa.tar.bz2
* libm/common/s_fdim.c: New file.
* libm/common/s_fma.c: Likewise. * libm/common/s_fmax.c: Likewise. * libm/common/s_fmin.c: Likewise. * libm/common/s_fpclassify.c: Likewise. * libm/common/s_lrint.c: Likewise. * libm/common/s_lround.c: Likewise. * libm/common/s_nearbyint.c: Likewise. * libm/common/s_remquo.c: Likewise. * libm/common/s_round.c: Likewise. * libm/common/s_scalbln.c: Likewise. * libm/common/s_signbit.c: Likewise. * libm/common/s_trunc.c: Likewise. * libm/common/sf_fdim.c: Likewise. * libm/common/sf_fma.c: Likewise. * libm/common/sf_fmax.c: Likewise. * libm/common/sf_fmin.c: Likewise. * libm/common/sf_lrint.c: Likewise. * libm/common/sf_lround.c: Likewise. * libm/common/sf_nearbyint.c: Likewise. * libm/common/sf_remquo.c: Likewise. * libm/common/sf_round.c: Likewise. * libm/common/sf_scalbln.c: Likewise. * libm/common/sf_trunc.c: Likewise. * libm/math/w_exp2.c: Likewise. * libm/math/w_tgamma.c: Likewise. * libm/math/wf_exp2.c: Likewise. * libm/math/wf_tgamma.c: Likewise. * libm/mathfp/s_exp2.c: Likewise. * libm/mathfp/s_tgamma.c: Likewise. * libm/mathfp/sf_exp2.c: Likewise. * libm/mathfp/sf_tgamma.c: Likewise. * libm/math/er_gamma.c: Fix return value. * libm/math/erf_gamma.c: Likewise. * libm/mathfp/er_gamma.c: Likewise. * libm/mathfp/erf_gamma.c: Likewise. * libc/include/math.h (!__STRICT_ANSI__): Include ISOC99-specific declarations and macros. Regenerated all Makefile.in, aclocal.m4 and configure files to use new libtool macros in top-level libtool.m4
Diffstat (limited to 'newlib/libm/common/s_fpclassify.c')
-rw-r--r--newlib/libm/common/s_fpclassify.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/newlib/libm/common/s_fpclassify.c b/newlib/libm/common/s_fpclassify.c
new file mode 100644
index 0000000..0911915
--- /dev/null
+++ b/newlib/libm/common/s_fpclassify.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#include "fdlibm.h"
+
+int
+__fpclassifyf (float x)
+{
+ unsigned int w;
+
+ GET_FLOAT_WORD(w,x);
+
+ if (w == 0x00000000 || w == 0x80000000)
+ return FP_ZERO;
+ else if ((w >= 0x00800000 && w <= 0x7f7fffff) ||
+ (w >= 0xff7fffff && w <= 0x80800000))
+ return FP_NORMAL;
+ else if ((w >= 0x00000001 && w <= 0x007fffff) ||
+ (w >= 0x807fffff && w <= 0x80000001))
+ return FP_SUBNORMAL;
+ else if (w == 0x7f800000 || w == 0xff800000)
+ return FP_INFINITE;
+ else
+ return FP_NAN;
+}
+
+int
+__fpclassifyd (double x)
+{
+ unsigned int msw, lsw;
+
+ EXTRACT_WORDS(msw,lsw,x);
+
+ if ((msw == 0x00000000 && lsw == 0x00000000) ||
+ (msw == 0x80000000 && lsw == 0x00000000))
+ return FP_ZERO;
+ else if ((msw >= 0x00100000 && msw <= 0x7fefffff) ||
+ (msw >= 0xffefffff && msw <= 0x80100000))
+ return FP_NORMAL;
+ else if ((msw >= 0x00000000 && msw <= 0x000fffff) ||
+ (msw >= 0x800fffff && msw <= 0x80000000))
+ /* zero is already handled above */
+ return FP_SUBNORMAL;
+ else if ((msw == 0x7ff00000 && lsw == 0x00000000) ||
+ (msw == 0xfff00000 && lsw == 0x00000000))
+ return FP_INFINITE;
+ else
+ return FP_NAN;
+}