Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libm/mathfp')
-rw-r--r--newlib/libm/mathfp/Makefile.am184
-rw-r--r--newlib/libm/mathfp/Makefile.in410
-rw-r--r--newlib/libm/mathfp/e_acosh.c135
-rw-r--r--newlib/libm/mathfp/e_atanh.c139
-rw-r--r--newlib/libm/mathfp/e_hypot.c170
-rw-r--r--newlib/libm/mathfp/e_j0.c487
-rw-r--r--newlib/libm/mathfp/e_j1.c486
-rw-r--r--newlib/libm/mathfp/e_remainder.c113
-rw-r--r--newlib/libm/mathfp/e_scalb.c55
-rw-r--r--newlib/libm/mathfp/ef_acosh.c53
-rw-r--r--newlib/libm/mathfp/ef_atanh.c54
-rw-r--r--newlib/libm/mathfp/ef_hypot.c82
-rw-r--r--newlib/libm/mathfp/ef_j0.c439
-rw-r--r--newlib/libm/mathfp/ef_j1.c439
-rw-r--r--newlib/libm/mathfp/ef_remainder.c68
-rw-r--r--newlib/libm/mathfp/ef_scalb.c53
-rw-r--r--newlib/libm/mathfp/er_gamma.c32
-rw-r--r--newlib/libm/mathfp/er_lgamma.c422
-rw-r--r--newlib/libm/mathfp/erf_gamma.c34
-rw-r--r--newlib/libm/mathfp/erf_lgamma.c244
-rw-r--r--newlib/libm/mathfp/mathfp.tex199
-rw-r--r--newlib/libm/mathfp/s_acos.c93
-rw-r--r--newlib/libm/mathfp/s_asin.c29
-rw-r--r--newlib/libm/mathfp/s_asine.c186
-rw-r--r--newlib/libm/mathfp/s_asinh.c107
-rw-r--r--newlib/libm/mathfp/s_atan.c83
-rw-r--r--newlib/libm/mathfp/s_atan2.c89
-rw-r--r--newlib/libm/mathfp/s_atangent.c213
-rw-r--r--newlib/libm/mathfp/s_ceil.c38
-rw-r--r--newlib/libm/mathfp/s_cos.c29
-rw-r--r--newlib/libm/mathfp/s_cosh.c80
-rw-r--r--newlib/libm/mathfp/s_erf.c373
-rw-r--r--newlib/libm/mathfp/s_exp.c133
-rw-r--r--newlib/libm/mathfp/s_fabs.c80
-rw-r--r--newlib/libm/mathfp/s_floor.c92
-rw-r--r--newlib/libm/mathfp/s_fmod.c187
-rw-r--r--newlib/libm/mathfp/s_frexp.c110
-rw-r--r--newlib/libm/mathfp/s_infconst.c15
-rw-r--r--newlib/libm/mathfp/s_isinf.c37
-rw-r--r--newlib/libm/mathfp/s_isnan.c125
-rw-r--r--newlib/libm/mathfp/s_ispos.c35
-rw-r--r--newlib/libm/mathfp/s_ldexp.c125
-rw-r--r--newlib/libm/mathfp/s_log.c29
-rw-r--r--newlib/libm/mathfp/s_log10.c68
-rw-r--r--newlib/libm/mathfp/s_logarithm.c135
-rw-r--r--newlib/libm/mathfp/s_mathcnst.c24
-rw-r--r--newlib/libm/mathfp/s_numtest.c58
-rw-r--r--newlib/libm/mathfp/s_pow.c146
-rw-r--r--newlib/libm/mathfp/s_signif.c34
-rw-r--r--newlib/libm/mathfp/s_sin.c29
-rw-r--r--newlib/libm/mathfp/s_sine.c166
-rw-r--r--newlib/libm/mathfp/s_sineh.c185
-rw-r--r--newlib/libm/mathfp/s_sinf.c34
-rw-r--r--newlib/libm/mathfp/s_sinh.c29
-rw-r--r--newlib/libm/mathfp/s_sqrt.c129
-rw-r--r--newlib/libm/mathfp/s_tan.c139
-rw-r--r--newlib/libm/mathfp/s_tanh.c117
-rw-r--r--newlib/libm/mathfp/sf_acos.c33
-rw-r--r--newlib/libm/mathfp/sf_asin.c34
-rw-r--r--newlib/libm/mathfp/sf_asine.c105
-rw-r--r--newlib/libm/mathfp/sf_asinh.c66
-rw-r--r--newlib/libm/mathfp/sf_atan.c45
-rw-r--r--newlib/libm/mathfp/sf_atan2.c34
-rw-r--r--newlib/libm/mathfp/sf_atangent.c140
-rw-r--r--newlib/libm/mathfp/sf_ceil.c42
-rw-r--r--newlib/libm/mathfp/sf_cos.c34
-rw-r--r--newlib/libm/mathfp/sf_cosh.c33
-rw-r--r--newlib/libm/mathfp/sf_erf.c246
-rw-r--r--newlib/libm/mathfp/sf_exp.c92
-rw-r--r--newlib/libm/mathfp/sf_fabs.c45
-rw-r--r--newlib/libm/mathfp/sf_floor.c43
-rw-r--r--newlib/libm/mathfp/sf_fmod.c103
-rw-r--r--newlib/libm/mathfp/sf_frexp.c58
-rw-r--r--newlib/libm/mathfp/sf_isinf.c33
-rw-r--r--newlib/libm/mathfp/sf_isnan.c33
-rw-r--r--newlib/libm/mathfp/sf_ispos.c40
-rw-r--r--newlib/libm/mathfp/sf_ldexp.c81
-rw-r--r--newlib/libm/mathfp/sf_log.c34
-rw-r--r--newlib/libm/mathfp/sf_log10.c34
-rw-r--r--newlib/libm/mathfp/sf_logarithm.c72
-rw-r--r--newlib/libm/mathfp/sf_numtest.c63
-rw-r--r--newlib/libm/mathfp/sf_pow.c107
-rw-r--r--newlib/libm/mathfp/sf_signif.c40
-rw-r--r--newlib/libm/mathfp/sf_sin.c34
-rw-r--r--newlib/libm/mathfp/sf_sine.c112
-rw-r--r--newlib/libm/mathfp/sf_sineh.c110
-rw-r--r--newlib/libm/mathfp/sf_sinh.c34
-rw-r--r--newlib/libm/mathfp/sf_sqrt.c100
-rw-r--r--newlib/libm/mathfp/sf_tan.c104
-rw-r--r--newlib/libm/mathfp/sf_tanh.c77
-rw-r--r--newlib/libm/mathfp/w_cabs.c20
-rw-r--r--newlib/libm/mathfp/w_drem.c15
-rw-r--r--newlib/libm/mathfp/w_jn.c248
-rw-r--r--newlib/libm/mathfp/wf_cabs.c20
-rw-r--r--newlib/libm/mathfp/wf_drem.c19
-rw-r--r--newlib/libm/mathfp/wf_jn.c138
-rw-r--r--newlib/libm/mathfp/zmath.h55
97 files changed, 10655 insertions, 0 deletions
diff --git a/newlib/libm/mathfp/Makefile.am b/newlib/libm/mathfp/Makefile.am
new file mode 100644
index 000000000..562653f58
--- /dev/null
+++ b/newlib/libm/mathfp/Makefile.am
@@ -0,0 +1,184 @@
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = cygnus
+
+INCLUDES = -I$(srcdir)/../common $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+
+noinst_LIBRARIES = lib.a
+src = s_acos.c s_frexp.c s_mathcnst.c \
+ s_cos.c s_sinh.c \
+ s_asin.c\
+ s_asine.c s_cosh.c s_ispos.c s_numtest.c s_sqrt.c \
+ s_exp.c s_ldexp.c s_pow.c s_tan.c \
+ s_atan.c \
+ s_atan2.c s_fabs.c s_log.c s_tanh.c \
+ s_log10.c s_sin.c \
+ s_floor.c s_sine.c \
+ s_atangent.c s_logarithm.c \
+ s_sineh.c \
+ s_ceil.c s_isnan.c s_isinf.c \
+ e_acosh.c e_atanh.c e_remainder.c \
+ er_gamma.c er_lgamma.c \
+ s_erf.c e_j0.c e_j1.c w_jn.c e_hypot.c \
+ w_cabs.c w_drem.c s_asinh.c s_fmod.c \
+ e_scalb.c s_infconst.c s_signif.c
+
+fsrc = sf_ceil.c \
+ sf_acos.c sf_frexp.c \
+ sf_cos.c sf_sinh.c \
+ sf_asine.c sf_cosh.c sf_ispos.c sf_numtest.c sf_sqrt.c \
+ sf_asin.c \
+ sf_exp.c sf_ldexp.c sf_pow.c sf_tan.c \
+ sf_atan2.c sf_fabs.c sf_tanh.c \
+ sf_atan.c sf_log10.c sf_sin.c\
+ sf_floor.c sf_sine.c \
+ sf_atangent.c sf_logarithm.c sf_sineh.c \
+ sf_log.c sf_sineh.c \
+ sf_isnan.c sf_isinf.c \
+ ef_acosh.c ef_atanh.c ef_remainder.c \
+ erf_gamma.c erf_lgamma.c \
+ sf_erf.c ef_j0.c ef_j1.c wf_jn.c ef_hypot.c \
+ wf_cabs.c wf_drem.c sf_asinh.c sf_fmod.c \
+ ef_scalb.c sf_signif.c
+
+lib_a_SOURCES = $(src) $(fsrc)
+
+chobj = eacosh.def \
+ eatanh.def \
+ ehypot.def \
+ eremainder.def \
+ erlgamma.def \
+ sacos.def \
+ sasine.def \
+ sasinh.def \
+ satan.def \
+ satan2.def \
+ satangent.def \
+ scosh.def \
+ serf.def \
+ sexp.def \
+ sfabs.def \
+ sfloor.def \
+ sfmod.def \
+ sfrexp.def \
+ sisnan.def \
+ sldexp.def \
+ slog10.def \
+ slogarithm.def \
+ spow.def \
+ ssine.def \
+ ssineh.def \
+ ssqrt.def \
+ stan.def \
+ stanh.def \
+ wjn.def
+
+SUFFIXES = .def
+
+CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
+
+.c.def:
+ $(CHEW) < $< > $*.def 2> $*.ref
+ touch stmp-def
+
+TARGETDOC = ../tmp.texi
+
+doc: $(chobj)
+ cat $(srcdir)/mathfp.tex >> $(TARGETDOC)
+
+CLEANFILES = $(chobj) *.ref
+
+# Texinfo does not appear to support underscores in file names, so we
+# name the .def files without underscores.
+
+eacosh.def: e_acosh.c
+ $(CHEW) < $(srcdir)/e_acosh.c >$@ 2>/dev/null
+ touch stmp-def
+eatanh.def: e_atanh.c
+ $(CHEW) < $(srcdir)/e_atanh.c >$@ 2>/dev/null
+ touch stmp-def
+ehypot.def: e_hypot.c
+ $(CHEW) < $(srcdir)/e_hypot.c >$@ 2>/dev/null
+ touch stmp-def
+eremainder.def: e_remainder.c
+ $(CHEW) < $(srcdir)/e_remainder.c >$@ 2>/dev/null
+ touch stmp-def
+erlgamma.def: er_lgamma.c
+ $(CHEW) < $(srcdir)/er_lgamma.c >$@ 2>/dev/null
+ touch stmp-def
+sacos.def: s_acos.c
+ $(CHEW) < $(srcdir)/s_acos.c >$@ 2>/dev/null
+ touch stmp-def
+sasine.def: s_asine.c
+ $(CHEW) < $(srcdir)/s_asine.c >$@ 2>/dev/null
+ touch stmp-def
+sasinh.def: s_asinh.c
+ $(CHEW) < $(srcdir)/s_asinh.c >$@ 2>/dev/null
+ touch stmp-def
+satan.def: s_atan.c
+ $(CHEW) < $(srcdir)/s_atan.c >$@ 2>/dev/null
+ touch stmp-def
+satan2.def: s_atan2.c
+ $(CHEW) < $(srcdir)/s_atan2.c >$@ 2>/dev/null
+ touch stmp-def
+satangent.def: s_atangent.c
+ $(CHEW) < $(srcdir)/s_atangent.c >$@ 2>/dev/null
+ touch stmp-def
+scosh.def: s_cosh.c
+ $(CHEW) < $(srcdir)/s_cosh.c >$@ 2>/dev/null
+ touch stmp-def
+serf.def: s_erf.c
+ $(CHEW) < $(srcdir)/s_erf.c >$@ 2>/dev/null
+ touch stmp-def
+sexp.def: s_exp.c
+ $(CHEW) < $(srcdir)/s_exp.c >$@ 2>/dev/null
+ touch stmp-def
+sfabs.def: s_fabs.c
+ $(CHEW) < $(srcdir)/s_fabs.c >$@ 2>/dev/null
+ touch stmp-def
+sfloor.def: s_floor.c
+ $(CHEW) < $(srcdir)/s_floor.c >$@ 2>/dev/null
+ touch stmp-def
+sfmod.def: s_fmod.c
+ $(CHEW) < $(srcdir)/s_fmod.c >$@ 2>/dev/null
+ touch stmp-def
+sfrexp.def: s_frexp.c
+ $(CHEW) < $(srcdir)/s_frexp.c >$@ 2>/dev/null
+ touch stmp-def
+sisnan.def: s_isnan.c
+ $(CHEW) < $(srcdir)/s_isnan.c >$@ 2>/dev/null
+ touch stmp-def
+sldexp.def: s_ldexp.c
+ $(CHEW) < $(srcdir)/s_ldexp.c >$@ 2>/dev/null
+ touch stmp-def
+slog10.def: s_log10.c
+ $(CHEW) < $(srcdir)/s_log10.c >$@ 2>/dev/null
+ touch stmp-def
+slogarithm.def: s_logarithm.c
+ $(CHEW) < $(srcdir)/s_logarithm.c >$@ 2>/dev/null
+ touch stmp-def
+spow.def: s_pow.c
+ $(CHEW) < $(srcdir)/s_pow.c >$@ 2>/dev/null
+ touch stmp-def
+ssine.def: s_sine.c
+ $(CHEW) < $(srcdir)/s_sine.c >$@ 2>/dev/null
+ touch stmp-def
+ssineh.def: s_sineh.c
+ $(CHEW) < $(srcdir)/s_sineh.c >$@ 2>/dev/null
+ touch stmp-def
+ssqrt.def: s_sqrt.c
+ $(CHEW) < $(srcdir)/s_sqrt.c >$@ 2>/dev/null
+ touch stmp-def
+stan.def: s_tan.c
+ $(CHEW) < $(srcdir)/s_tan.c >$@ 2>/dev/null
+ touch stmp-def
+stanh.def: s_tanh.c
+ $(CHEW) < $(srcdir)/s_tanh.c >$@ 2>/dev/null
+ touch stmp-def
+wjn.def: w_jn.c
+ $(CHEW) < $(srcdir)/w_jn.c >$@ 2>/dev/null
+ touch stmp-def
+
+# A partial dependency list.
+
+$(lib_a_OBJECTS): $(srcdir)/../../libc/include/math.h $(srcdir)/../common/fdlibm.h
diff --git a/newlib/libm/mathfp/Makefile.in b/newlib/libm/mathfp/Makefile.in
new file mode 100644
index 000000000..15575361d
--- /dev/null
+++ b/newlib/libm/mathfp/Makefile.in
@@ -0,0 +1,410 @@
+# Makefile.in generated automatically by automake 1.3b from Makefile.am
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+AR = @AR@
+AS = @AS@
+CC = @CC@
+CPP = @CPP@
+EXEEXT = @EXEEXT@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+VERSION = @VERSION@
+mach_add_objs = @mach_add_objs@
+machine_dir = @machine_dir@
+newlib_basedir = @newlib_basedir@
+sys_dir = @sys_dir@
+
+AUTOMAKE_OPTIONS = cygnus
+
+INCLUDES = -I$(srcdir)/../common $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+
+noinst_LIBRARIES = lib.a
+src = s_acos.c s_frexp.c s_mathcnst.c \
+ s_cos.c s_sinh.c \
+ s_asin.c\
+ s_asine.c s_cosh.c s_ispos.c s_numtest.c s_sqrt.c \
+ s_exp.c s_ldexp.c s_pow.c s_tan.c \
+ s_atan.c \
+ s_atan2.c s_fabs.c s_log.c s_tanh.c \
+ s_log10.c s_sin.c \
+ s_floor.c s_sine.c \
+ s_atangent.c s_logarithm.c \
+ s_sineh.c \
+ s_ceil.c s_isnan.c s_isinf.c \
+ e_acosh.c e_atanh.c e_remainder.c \
+ er_gamma.c er_lgamma.c \
+ s_erf.c e_j0.c e_j1.c w_jn.c e_hypot.c \
+ w_cabs.c w_drem.c s_asinh.c s_fmod.c \
+ e_scalb.c s_infconst.c s_signif.c
+
+fsrc = sf_ceil.c \
+ sf_acos.c sf_frexp.c \
+ sf_cos.c sf_sinh.c \
+ sf_asine.c sf_cosh.c sf_ispos.c sf_numtest.c sf_sqrt.c \
+ sf_asin.c \
+ sf_exp.c sf_ldexp.c sf_pow.c sf_tan.c \
+ sf_atan2.c sf_fabs.c sf_tanh.c \
+ sf_atan.c sf_log10.c sf_sin.c\
+ sf_floor.c sf_sine.c \
+ sf_atangent.c sf_logarithm.c sf_sineh.c \
+ sf_log.c sf_sineh.c \
+ sf_isnan.c sf_isinf.c \
+ ef_acosh.c ef_atanh.c ef_remainder.c \
+ erf_gamma.c erf_lgamma.c \
+ sf_erf.c ef_j0.c ef_j1.c wf_jn.c ef_hypot.c \
+ wf_cabs.c wf_drem.c sf_asinh.c sf_fmod.c \
+ ef_scalb.c sf_signif.c
+
+lib_a_SOURCES = $(src) $(fsrc)
+
+chobj = eacosh.def eatanh.def ehypot.def eremainder.def erlgamma.def sacos.def sasine.def sasinh.def satan.def satan2.def satangent.def scosh.def serf.def sexp.def sfabs.def sfloor.def sfmod.def sfrexp.def sisnan.def sldexp.def slog10.def slogarithm.def spow.def ssine.def ssineh.def ssqrt.def stan.def stanh.def wjn.def
+
+SUFFIXES = .def
+
+CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
+
+TARGETDOC = ../tmp.texi
+
+CLEANFILES = $(chobj) *.ref
+mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir)
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+lib_a_LIBADD =
+lib_a_OBJECTS = s_acos.o s_frexp.o s_mathcnst.o s_cos.o s_sinh.o \
+s_asin.o s_asine.o s_cosh.o s_ispos.o s_numtest.o s_sqrt.o s_exp.o \
+s_ldexp.o s_pow.o s_tan.o s_atan.o s_atan2.o s_fabs.o s_log.o s_tanh.o \
+s_log10.o s_sin.o s_floor.o s_sine.o s_atangent.o s_logarithm.o \
+s_sineh.o s_ceil.o s_isnan.o s_isinf.o e_acosh.o e_atanh.o \
+e_remainder.o er_gamma.o er_lgamma.o s_erf.o e_j0.o e_j1.o w_jn.o \
+e_hypot.o w_cabs.o w_drem.o s_asinh.o s_fmod.o e_scalb.o s_infconst.o \
+s_signif.o sf_ceil.o sf_acos.o sf_frexp.o sf_cos.o sf_sinh.o sf_asine.o \
+sf_cosh.o sf_ispos.o sf_numtest.o sf_sqrt.o sf_asin.o sf_exp.o \
+sf_ldexp.o sf_pow.o sf_tan.o sf_atan2.o sf_fabs.o sf_tanh.o sf_atan.o \
+sf_log10.o sf_sin.o sf_floor.o sf_sine.o sf_atangent.o sf_logarithm.o \
+sf_sineh.o sf_log.o sf_sineh.o sf_isnan.o sf_isinf.o ef_acosh.o \
+ef_atanh.o ef_remainder.o erf_gamma.o erf_lgamma.o sf_erf.o ef_j0.o \
+ef_j1.o wf_jn.o ef_hypot.o wf_cabs.o wf_drem.o sf_asinh.o sf_fmod.o \
+ef_scalb.o sf_signif.o
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP = --best
+SOURCES = $(lib_a_SOURCES)
+OBJECTS = $(lib_a_OBJECTS)
+
+all: Makefile $(LIBRARIES)
+
+.SUFFIXES:
+.SUFFIXES: .S .c .def .o .s
+$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --cygnus mathfp/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-noinstLIBRARIES:
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+distclean-noinstLIBRARIES:
+
+maintainer-clean-noinstLIBRARIES:
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES)
+ -rm -f lib.a
+ $(AR) cru lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD)
+ $(RANLIB) lib.a
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = mathfp
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ if test -f $$file; then d=.; else d=$(srcdir); fi; \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file; \
+ done
+info:
+dvi:
+check:
+installcheck:
+install-info:
+install-exec:
+ @$(NORMAL_INSTALL)
+
+install-data:
+ @$(NORMAL_INSTALL)
+
+install: install-exec install-data all
+ @:
+
+uninstall:
+
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
+installdirs:
+
+
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \
+ mostlyclean-tags mostlyclean-generic
+
+clean: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
+ mostlyclean
+
+distclean: distclean-noinstLIBRARIES distclean-compile distclean-tags \
+ distclean-generic clean
+ -rm -f config.status
+
+maintainer-clean: maintainer-clean-noinstLIBRARIES \
+ maintainer-clean-compile maintainer-clean-tags \
+ maintainer-clean-generic distclean
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
+clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile tags mostlyclean-tags distclean-tags \
+clean-tags maintainer-clean-tags distdir info dvi installcheck \
+install-info install-exec install-data install uninstall all \
+installdirs mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+.c.def:
+ $(CHEW) < $< > $*.def 2> $*.ref
+ touch stmp-def
+
+doc: $(chobj)
+ cat $(srcdir)/mathfp.tex >> $(TARGETDOC)
+
+# Texinfo does not appear to support underscores in file names, so we
+# name the .def files without underscores.
+
+eacosh.def: e_acosh.c
+ $(CHEW) < $(srcdir)/e_acosh.c >$@ 2>/dev/null
+ touch stmp-def
+eatanh.def: e_atanh.c
+ $(CHEW) < $(srcdir)/e_atanh.c >$@ 2>/dev/null
+ touch stmp-def
+ehypot.def: e_hypot.c
+ $(CHEW) < $(srcdir)/e_hypot.c >$@ 2>/dev/null
+ touch stmp-def
+eremainder.def: e_remainder.c
+ $(CHEW) < $(srcdir)/e_remainder.c >$@ 2>/dev/null
+ touch stmp-def
+erlgamma.def: er_lgamma.c
+ $(CHEW) < $(srcdir)/er_lgamma.c >$@ 2>/dev/null
+ touch stmp-def
+sacos.def: s_acos.c
+ $(CHEW) < $(srcdir)/s_acos.c >$@ 2>/dev/null
+ touch stmp-def
+sasine.def: s_asine.c
+ $(CHEW) < $(srcdir)/s_asine.c >$@ 2>/dev/null
+ touch stmp-def
+sasinh.def: s_asinh.c
+ $(CHEW) < $(srcdir)/s_asinh.c >$@ 2>/dev/null
+ touch stmp-def
+satan.def: s_atan.c
+ $(CHEW) < $(srcdir)/s_atan.c >$@ 2>/dev/null
+ touch stmp-def
+satan2.def: s_atan2.c
+ $(CHEW) < $(srcdir)/s_atan2.c >$@ 2>/dev/null
+ touch stmp-def
+satangent.def: s_atangent.c
+ $(CHEW) < $(srcdir)/s_atangent.c >$@ 2>/dev/null
+ touch stmp-def
+scosh.def: s_cosh.c
+ $(CHEW) < $(srcdir)/s_cosh.c >$@ 2>/dev/null
+ touch stmp-def
+serf.def: s_erf.c
+ $(CHEW) < $(srcdir)/s_erf.c >$@ 2>/dev/null
+ touch stmp-def
+sexp.def: s_exp.c
+ $(CHEW) < $(srcdir)/s_exp.c >$@ 2>/dev/null
+ touch stmp-def
+sfabs.def: s_fabs.c
+ $(CHEW) < $(srcdir)/s_fabs.c >$@ 2>/dev/null
+ touch stmp-def
+sfloor.def: s_floor.c
+ $(CHEW) < $(srcdir)/s_floor.c >$@ 2>/dev/null
+ touch stmp-def
+sfmod.def: s_fmod.c
+ $(CHEW) < $(srcdir)/s_fmod.c >$@ 2>/dev/null
+ touch stmp-def
+sfrexp.def: s_frexp.c
+ $(CHEW) < $(srcdir)/s_frexp.c >$@ 2>/dev/null
+ touch stmp-def
+sisnan.def: s_isnan.c
+ $(CHEW) < $(srcdir)/s_isnan.c >$@ 2>/dev/null
+ touch stmp-def
+sldexp.def: s_ldexp.c
+ $(CHEW) < $(srcdir)/s_ldexp.c >$@ 2>/dev/null
+ touch stmp-def
+slog10.def: s_log10.c
+ $(CHEW) < $(srcdir)/s_log10.c >$@ 2>/dev/null
+ touch stmp-def
+slogarithm.def: s_logarithm.c
+ $(CHEW) < $(srcdir)/s_logarithm.c >$@ 2>/dev/null
+ touch stmp-def
+spow.def: s_pow.c
+ $(CHEW) < $(srcdir)/s_pow.c >$@ 2>/dev/null
+ touch stmp-def
+ssine.def: s_sine.c
+ $(CHEW) < $(srcdir)/s_sine.c >$@ 2>/dev/null
+ touch stmp-def
+ssineh.def: s_sineh.c
+ $(CHEW) < $(srcdir)/s_sineh.c >$@ 2>/dev/null
+ touch stmp-def
+ssqrt.def: s_sqrt.c
+ $(CHEW) < $(srcdir)/s_sqrt.c >$@ 2>/dev/null
+ touch stmp-def
+stan.def: s_tan.c
+ $(CHEW) < $(srcdir)/s_tan.c >$@ 2>/dev/null
+ touch stmp-def
+stanh.def: s_tanh.c
+ $(CHEW) < $(srcdir)/s_tanh.c >$@ 2>/dev/null
+ touch stmp-def
+wjn.def: w_jn.c
+ $(CHEW) < $(srcdir)/w_jn.c >$@ 2>/dev/null
+ touch stmp-def
+
+# A partial dependency list.
+
+$(lib_a_OBJECTS): $(srcdir)/../../libc/include/math.h $(srcdir)/../common/fdlibm.h
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/newlib/libm/mathfp/e_acosh.c b/newlib/libm/mathfp/e_acosh.c
new file mode 100644
index 000000000..a48420304
--- /dev/null
+++ b/newlib/libm/mathfp/e_acosh.c
@@ -0,0 +1,135 @@
+
+/* @(#)e_acosh.c 5.1 93/09/24 */
+
+/*
+FUNCTION
+<<acosh>>, <<acoshf>>---inverse hyperbolic cosine
+
+INDEX
+acosh
+INDEX
+acoshf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double acosh(double <[x]>);
+ float acoshf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double acosh(<[x]>)
+ double <[x]>;
+
+ float acoshf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+<<acosh>> calculates the inverse hyperbolic cosine of <[x]>.
+<<acosh>> is defined as
+@ifinfo
+. log(<[x]> + sqrt(<[x]>*<[x]>-1))
+@end ifinfo
+@tex
+$$ln\Bigl(x + \sqrt{x^2-1}\Bigr)$$
+@end tex
+
+<[x]> must be a number greater than or equal to 1.
+
+<<acoshf>> is identical, other than taking and returning floats.
+
+RETURNS
+<<acosh>> and <<acoshf>> return the calculated value. If <[x]>
+less than 1, the return value is NaN and <<errno>> is set to <<EDOM>>.
+
+You can change the error-handling behavior with the non-ANSI
+<<matherr>> function.
+
+PORTABILITY
+Neither <<acosh>> nor <<acoshf>> are ANSI C. They are not recommended
+for portable programs.
+
+
+QUICKREF ANSI SVID POSIX RENTRANT
+ acos n,n,n,m
+ acosf n,n,n,m
+
+MATHREF
+ acosh, NAN, arg,DOMAIN,EDOM
+ acosh, < 1.0, NAN,DOMAIN,EDOM
+ acosh, >=1.0, acosh(arg),,,
+
+MATHREF
+ acoshf, NAN, arg,DOMAIN,EDOM
+ acoshf, < 1.0, NAN,DOMAIN,EDOM
+ acoshf, >=1.0, acosh(arg),,,
+
+*/
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+/* acosh(x)
+ * Method :
+ * Based on
+ * acosh(x) = log [ x + sqrt(x*x-1) ]
+ * we have
+ * acosh(x) := log(x)+ln2, if x is large; else
+ * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
+ * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
+ *
+ * Special cases:
+ * acosh(x) is NaN with signal if x<1.
+ * acosh(NaN) is NaN without signal.
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+one = 1.0,
+ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
+
+#ifdef __STDC__
+ double acosh(double x)
+#else
+ double acosh(x)
+ double x;
+#endif
+{
+ double t;
+ __int32_t hx;
+ __uint32_t lx;
+ EXTRACT_WORDS(hx,lx,x);
+ if(hx<0x3ff00000) { /* x < 1 */
+ return (x-x)/(x-x);
+ } else if(hx >=0x41b00000) { /* x > 2**28 */
+ if(hx >=0x7ff00000) { /* x is inf of NaN */
+ return x+x;
+ } else
+ return log(x)+ln2; /* acosh(huge)=log(2x) */
+ } else if(((hx-0x3ff00000)|lx)==0) {
+ return 0.0; /* acosh(1) = 0 */
+ } else if (hx > 0x40000000) { /* 2**28 > x > 2 */
+ t=x*x;
+ return log(2.0*x-one/(x+sqrt(t-one)));
+ } else { /* 1<x<2 */
+ t = x-one;
+ return log1p(t+sqrt(2.0*t+t*t));
+ }
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/e_atanh.c b/newlib/libm/mathfp/e_atanh.c
new file mode 100644
index 000000000..1ab311df4
--- /dev/null
+++ b/newlib/libm/mathfp/e_atanh.c
@@ -0,0 +1,139 @@
+
+/* @(#)e_atanh.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+/*
+FUNCTION
+ <<atanh>>, <<atanhf>>---inverse hyperbolic tangent
+
+INDEX
+ atanh
+INDEX
+ atanhf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double atanh(double <[x]>);
+ float atanhf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double atanh(<[x]>)
+ double <[x]>;
+
+ float atanhf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+ <<atanh>> calculates the inverse hyperbolic tangent of <[x]>.
+
+ <<atanhf>> is identical, other than taking and returning
+ <<float>> values.
+
+RETURNS
+ <<atanh>> and <<atanhf>> return the calculated value.
+
+ If
+ @ifinfo
+ |<[x]>|
+ @end ifinfo
+ @tex
+ $|x|$
+ @end tex
+ is greater than 1, the global <<errno>> is set to <<EDOM>> and
+ the result is a NaN. A <<DOMAIN error>> is reported.
+
+ If
+ @ifinfo
+ |<[x]>|
+ @end ifinfo
+ @tex
+ $|x|$
+ @end tex
+ is 1, the global <<errno>> is set to <<EDOM>>; and the result is
+ infinity with the same sign as <<x>>. A <<SING error>> is reported.
+
+ You can modify the error handling for these routines using
+ <<matherr>>.
+
+PORTABILITY
+ Neither <<atanh>> nor <<atanhf>> are ANSI C.
+
+QUICKREF
+ atanh - pure
+ atanhf - pure
+
+
+*/
+
+/* atanh(x)
+ * Method :
+ * 1.Reduced x to positive by atanh(-x) = -atanh(x)
+ * 2.For x>=0.5
+ * 1 2x x
+ * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
+ * 2 1 - x 1 - x
+ *
+ * For x<0.5
+ * atanh(x) = 0.5*log1p(2x+2x*x/(1-x))
+ *
+ * Special cases:
+ * atanh(x) is NaN if |x| > 1 with signal;
+ * atanh(NaN) is that NaN with no signal;
+ * atanh(+-1) is +-INF with signal.
+ *
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+static const double one = 1.0, huge = 1e300;
+#else
+static double one = 1.0, huge = 1e300;
+#endif
+
+#ifdef __STDC__
+static const double zero = 0.0;
+#else
+static double zero = 0.0;
+#endif
+
+#ifdef __STDC__
+ double atanh(double x)
+#else
+ double atanh(x)
+ double x;
+#endif
+{
+ double t;
+ __int32_t hx,ix;
+ __uint32_t lx;
+ EXTRACT_WORDS(hx,lx,x);
+ ix = hx&0x7fffffff;
+ if ((ix|((lx|(-lx))>>31))>0x3ff00000) /* |x|>1 */
+ return (x-x)/(x-x);
+ if(ix==0x3ff00000)
+ return x/zero;
+ if(ix<0x3e300000&&(huge+x)>zero) return x; /* x<2**-28 */
+ SET_HIGH_WORD(x,ix);
+ if(ix<0x3fe00000) { /* x < 0.5 */
+ t = x+x;
+ t = 0.5*log1p(t+t*x/(one-x));
+ } else
+ t = 0.5*log1p((x+x)/(one-x));
+ if(hx>=0) return t; else return -t;
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/e_hypot.c b/newlib/libm/mathfp/e_hypot.c
new file mode 100644
index 000000000..d93263ea4
--- /dev/null
+++ b/newlib/libm/mathfp/e_hypot.c
@@ -0,0 +1,170 @@
+
+/* @(#)e_hypot.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+FUNCTION
+ <<hypot>>, <<hypotf>>---distance from origin
+INDEX
+ hypot
+INDEX
+ hypotf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double hypot(double <[x]>, double <[y]>);
+ float hypotf(float <[x]>, float <[y]>);
+
+TRAD_SYNOPSIS
+ double hypot(<[x]>, <[y]>)
+ double <[x]>, <[y]>;
+
+ float hypotf(<[x]>, <[y]>)
+ float <[x]>, <[y]>;
+
+DESCRIPTION
+ <<hypot>> calculates the Euclidean distance
+ @tex
+ $\sqrt{x^2+y^2}$
+ @end tex
+ @ifinfo
+ <<sqrt(<[x]>*<[x]> + <[y]>*<[y]>)>>
+ @end ifinfo
+ between the origin (0,0) and a point represented by the
+ Cartesian coordinates (<[x]>,<[y]>). <<hypotf>> differs only
+ in the type of its arguments and result.
+
+RETURNS
+ Normally, the distance value is returned. On overflow,
+ <<hypot>> returns <<HUGE_VAL>> and sets <<errno>> to
+ <<ERANGE>>.
+
+ You can change the error treatment with <<matherr>>.
+
+PORTABILITY
+ <<hypot>> and <<hypotf>> are not ANSI C. */
+
+/* hypot(x,y)
+ *
+ * Method :
+ * If (assume round-to-nearest) z=x*x+y*y
+ * has error less than sqrt(2)/2 ulp, than
+ * sqrt(z) has error less than 1 ulp (exercise).
+ *
+ * So, compute sqrt(x*x+y*y) with some care as
+ * follows to get the error below 1 ulp:
+ *
+ * Assume x>y>0;
+ * (if possible, set rounding to round-to-nearest)
+ * 1. if x > 2y use
+ * x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y
+ * where x1 = x with lower 32 bits cleared, x2 = x-x1; else
+ * 2. if x <= 2y use
+ * t1*y1+((x-y)*(x-y)+(t1*y2+t2*y))
+ * where t1 = 2x with lower 32 bits cleared, t2 = 2x-t1,
+ * y1= y with lower 32 bits chopped, y2 = y-y1.
+ *
+ * NOTE: scaling may be necessary if some argument is too
+ * large or too tiny
+ *
+ * Special cases:
+ * hypot(x,y) is INF if x or y is +INF or -INF; else
+ * hypot(x,y) is NAN if x or y is NAN.
+ *
+ * Accuracy:
+ * hypot(x,y) returns sqrt(x^2+y^2) with error less
+ * than 1 ulps (units in the last place)
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+ double hypot(double x, double y)
+#else
+ double hypot(x,y)
+ double x, y;
+#endif
+{
+ double a=x,b=y,t1,t2,y1,y2,w;
+ __int32_t j,k,ha,hb;
+
+ GET_HIGH_WORD(ha,x);
+ ha &= 0x7fffffff;
+ GET_HIGH_WORD(hb,y);
+ hb &= 0x7fffffff;
+ if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
+ SET_HIGH_WORD(a,ha); /* a <- |a| */
+ SET_HIGH_WORD(b,hb); /* b <- |b| */
+ if((ha-hb)>0x3c00000) {return a+b;} /* x/y > 2**60 */
+ k=0;
+ if(ha > 0x5f300000) { /* a>2**500 */
+ if(ha >= 0x7ff00000) { /* Inf or NaN */
+ __uint32_t low;
+ w = a+b; /* for sNaN */
+ GET_LOW_WORD(low,a);
+ if(((ha&0xfffff)|low)==0) w = a;
+ GET_LOW_WORD(low,b);
+ if(((hb^0x7ff00000)|low)==0) w = b;
+ return w;
+ }
+ /* scale a and b by 2**-600 */
+ ha -= 0x25800000; hb -= 0x25800000; k += 600;
+ SET_HIGH_WORD(a,ha);
+ SET_HIGH_WORD(b,hb);
+ }
+ if(hb < 0x20b00000) { /* b < 2**-500 */
+ if(hb <= 0x000fffff) { /* subnormal b or 0 */
+ __uint32_t low;
+ GET_LOW_WORD(low,b);
+ if((hb|low)==0) return a;
+ t1=0;
+ SET_HIGH_WORD(t1,0x7fd00000); /* t1=2^1022 */
+ b *= t1;
+ a *= t1;
+ k -= 1022;
+ } else { /* scale a and b by 2^600 */
+ ha += 0x25800000; /* a *= 2^600 */
+ hb += 0x25800000; /* b *= 2^600 */
+ k -= 600;
+ SET_HIGH_WORD(a,ha);
+ SET_HIGH_WORD(b,hb);
+ }
+ }
+ /* medium size a and b */
+ w = a-b;
+ if (w>b) {
+ t1 = 0;
+ SET_HIGH_WORD(t1,ha);
+ t2 = a-t1;
+ w = sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
+ } else {
+ a = a+a;
+ y1 = 0;
+ SET_HIGH_WORD(y1,hb);
+ y2 = b - y1;
+ t1 = 0;
+ SET_HIGH_WORD(t1,ha+0x00100000);
+ t2 = a - t1;
+ w = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
+ }
+ if(k!=0) {
+ __uint32_t high;
+ t1 = 1.0;
+ GET_HIGH_WORD(high,t1);
+ SET_HIGH_WORD(t1,high+(k<<20));
+ return t1*w;
+ } else return w;
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/e_j0.c b/newlib/libm/mathfp/e_j0.c
new file mode 100644
index 000000000..c53cc68f4
--- /dev/null
+++ b/newlib/libm/mathfp/e_j0.c
@@ -0,0 +1,487 @@
+
+/* @(#)e_j0.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* j0(x), y0(x)
+ * Bessel function of the first and second kinds of order zero.
+ * Method -- j0(x):
+ * 1. For tiny x, we use j0(x) = 1 - x^2/4 + x^4/64 - ...
+ * 2. Reduce x to |x| since j0(x)=j0(-x), and
+ * for x in (0,2)
+ * j0(x) = 1-z/4+ z^2*R0/S0, where z = x*x;
+ * (precision: |j0-1+z/4-z^2R0/S0 |<2**-63.67 )
+ * for x in (2,inf)
+ * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0))
+ * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
+ * as follow:
+ * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
+ * = 1/sqrt(2) * (cos(x) + sin(x))
+ * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4)
+ * = 1/sqrt(2) * (sin(x) - cos(x))
+ * (To avoid cancellation, use
+ * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * to compute the worse one.)
+ *
+ * 3 Special cases
+ * j0(nan)= nan
+ * j0(0) = 1
+ * j0(inf) = 0
+ *
+ * Method -- y0(x):
+ * 1. For x<2.
+ * Since
+ * y0(x) = 2/pi*(j0(x)*(ln(x/2)+Euler) + x^2/4 - ...)
+ * therefore y0(x)-2/pi*j0(x)*ln(x) is an even function.
+ * We use the following function to approximate y0,
+ * y0(x) = U(z)/V(z) + (2/pi)*(j0(x)*ln(x)), z= x^2
+ * where
+ * U(z) = u00 + u01*z + ... + u06*z^6
+ * V(z) = 1 + v01*z + ... + v04*z^4
+ * with absolute approximation error bounded by 2**-72.
+ * Note: For tiny x, U/V = u0 and j0(x)~1, hence
+ * y0(tiny) = u0 + (2/pi)*ln(tiny), (choose tiny<2**-27)
+ * 2. For x>=2.
+ * y0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)+q0(x)*sin(x0))
+ * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
+ * by the method mentioned above.
+ * 3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0.
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+static double pzero(double), qzero(double);
+#else
+static double pzero(), qzero();
+#endif
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+huge = 1e300,
+one = 1.0,
+invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
+tpi = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
+ /* R0/S0 on [0, 2.00] */
+R02 = 1.56249999999999947958e-02, /* 0x3F8FFFFF, 0xFFFFFFFD */
+R03 = -1.89979294238854721751e-04, /* 0xBF28E6A5, 0xB61AC6E9 */
+R04 = 1.82954049532700665670e-06, /* 0x3EBEB1D1, 0x0C503919 */
+R05 = -4.61832688532103189199e-09, /* 0xBE33D5E7, 0x73D63FCE */
+S01 = 1.56191029464890010492e-02, /* 0x3F8FFCE8, 0x82C8C2A4 */
+S02 = 1.16926784663337450260e-04, /* 0x3F1EA6D2, 0xDD57DBF4 */
+S03 = 5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */
+S04 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */
+
+#ifdef __STDC__
+static const double zero = 0.0;
+#else
+static double zero = 0.0;
+#endif
+
+#ifdef __STDC__
+ double j0(double x)
+#else
+ double j0(x)
+ double x;
+#endif
+{
+ double z, s,c,ss,cc,r,u,v;
+ __int32_t hx,ix;
+
+ GET_HIGH_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7ff00000) return one/(x*x);
+ x = fabs(x);
+ if(ix >= 0x40000000) { /* |x| >= 2.0 */
+ s = sin(x);
+ c = cos(x);
+ ss = s-c;
+ cc = s+c;
+ if(ix<0x7fe00000) { /* make sure x+x not overflow */
+ z = -cos(x+x);
+ if ((s*c)<zero) cc = z/ss;
+ else ss = z/cc;
+ }
+ /*
+ * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
+ * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
+ */
+ if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(x);
+ else {
+ u = pzero(x); v = qzero(x);
+ z = invsqrtpi*(u*cc-v*ss)/sqrt(x);
+ }
+ return z;
+ }
+ if(ix<0x3f200000) { /* |x| < 2**-13 */
+ if(huge+x>one) { /* raise inexact if x != 0 */
+ if(ix<0x3e400000) return one; /* |x|<2**-27 */
+ else return one - 0.25*x*x;
+ }
+ }
+ z = x*x;
+ r = z*(R02+z*(R03+z*(R04+z*R05)));
+ s = one+z*(S01+z*(S02+z*(S03+z*S04)));
+ if(ix < 0x3FF00000) { /* |x| < 1.00 */
+ return one + z*(-0.25+(r/s));
+ } else {
+ u = 0.5*x;
+ return((one+u)*(one-u)+z*(r/s));
+ }
+}
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+u00 = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */
+u01 = 1.76666452509181115538e-01, /* 0x3FC69D01, 0x9DE9E3FC */
+u02 = -1.38185671945596898896e-02, /* 0xBF8C4CE8, 0xB16CFA97 */
+u03 = 3.47453432093683650238e-04, /* 0x3F36C54D, 0x20B29B6B */
+u04 = -3.81407053724364161125e-06, /* 0xBECFFEA7, 0x73D25CAD */
+u05 = 1.95590137035022920206e-08, /* 0x3E550057, 0x3B4EABD4 */
+u06 = -3.98205194132103398453e-11, /* 0xBDC5E43D, 0x693FB3C8 */
+v01 = 1.27304834834123699328e-02, /* 0x3F8A1270, 0x91C9C71A */
+v02 = 7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */
+v03 = 2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */
+v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
+
+#ifdef __STDC__
+ double y0(double x)
+#else
+ double y0(x)
+ double x;
+#endif
+{
+ double z, s,c,ss,cc,u,v;
+ __int32_t hx,ix,lx;
+
+ EXTRACT_WORDS(hx,lx,x);
+ ix = 0x7fffffff&hx;
+ /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */
+ if(ix>=0x7ff00000) return one/(x+x*x);
+ if((ix|lx)==0) return -one/zero;
+ if(hx<0) return zero/zero;
+ if(ix >= 0x40000000) { /* |x| >= 2.0 */
+ /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
+ * where x0 = x-pi/4
+ * Better formula:
+ * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
+ * = 1/sqrt(2) * (sin(x) + cos(x))
+ * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+ * = 1/sqrt(2) * (sin(x) - cos(x))
+ * To avoid cancellation, use
+ * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * to compute the worse one.
+ */
+ s = sin(x);
+ c = cos(x);
+ ss = s-c;
+ cc = s+c;
+ /*
+ * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
+ * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
+ */
+ if(ix<0x7fe00000) { /* make sure x+x not overflow */
+ z = -cos(x+x);
+ if ((s*c)<zero) cc = z/ss;
+ else ss = z/cc;
+ }
+ if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x);
+ else {
+ u = pzero(x); v = qzero(x);
+ z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
+ }
+ return z;
+ }
+ if(ix<=0x3e400000) { /* x < 2**-27 */
+ return(u00 + tpi*log(x));
+ }
+ z = x*x;
+ u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
+ v = one+z*(v01+z*(v02+z*(v03+z*v04)));
+ return(u/v + tpi*(j0(x)*log(x)));
+}
+
+/* The asymptotic expansions of pzero is
+ * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x.
+ * For x >= 2, We approximate pzero by
+ * pzero(x) = 1 + (R/S)
+ * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10
+ * S = 1 + pS0*s^2 + ... + pS4*s^10
+ * and
+ * | pzero(x)-1-R/S | <= 2 ** ( -60.26)
+ */
+#ifdef __STDC__
+static const double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#else
+static double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#endif
+ 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+ -7.03124999999900357484e-02, /* 0xBFB1FFFF, 0xFFFFFD32 */
+ -8.08167041275349795626e+00, /* 0xC02029D0, 0xB44FA779 */
+ -2.57063105679704847262e+02, /* 0xC0701102, 0x7B19E863 */
+ -2.48521641009428822144e+03, /* 0xC0A36A6E, 0xCD4DCAFC */
+ -5.25304380490729545272e+03, /* 0xC0B4850B, 0x36CC643D */
+};
+#ifdef __STDC__
+static const double pS8[5] = {
+#else
+static double pS8[5] = {
+#endif
+ 1.16534364619668181717e+02, /* 0x405D2233, 0x07A96751 */
+ 3.83374475364121826715e+03, /* 0x40ADF37D, 0x50596938 */
+ 4.05978572648472545552e+04, /* 0x40E3D2BB, 0x6EB6B05F */
+ 1.16752972564375915681e+05, /* 0x40FC810F, 0x8F9FA9BD */
+ 4.76277284146730962675e+04, /* 0x40E74177, 0x4F2C49DC */
+};
+
+#ifdef __STDC__
+static const double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#else
+static double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#endif
+ -1.14125464691894502584e-11, /* 0xBDA918B1, 0x47E495CC */
+ -7.03124940873599280078e-02, /* 0xBFB1FFFF, 0xE69AFBC6 */
+ -4.15961064470587782438e+00, /* 0xC010A370, 0xF90C6BBF */
+ -6.76747652265167261021e+01, /* 0xC050EB2F, 0x5A7D1783 */
+ -3.31231299649172967747e+02, /* 0xC074B3B3, 0x6742CC63 */
+ -3.46433388365604912451e+02, /* 0xC075A6EF, 0x28A38BD7 */
+};
+#ifdef __STDC__
+static const double pS5[5] = {
+#else
+static double pS5[5] = {
+#endif
+ 6.07539382692300335975e+01, /* 0x404E6081, 0x0C98C5DE */
+ 1.05125230595704579173e+03, /* 0x40906D02, 0x5C7E2864 */
+ 5.97897094333855784498e+03, /* 0x40B75AF8, 0x8FBE1D60 */
+ 9.62544514357774460223e+03, /* 0x40C2CCB8, 0xFA76FA38 */
+ 2.40605815922939109441e+03, /* 0x40A2CC1D, 0xC70BE864 */
+};
+
+#ifdef __STDC__
+static const double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#else
+static double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#endif
+ -2.54704601771951915620e-09, /* 0xBE25E103, 0x6FE1AA86 */
+ -7.03119616381481654654e-02, /* 0xBFB1FFF6, 0xF7C0E24B */
+ -2.40903221549529611423e+00, /* 0xC00345B2, 0xAEA48074 */
+ -2.19659774734883086467e+01, /* 0xC035F74A, 0x4CB94E14 */
+ -5.80791704701737572236e+01, /* 0xC04D0A22, 0x420A1A45 */
+ -3.14479470594888503854e+01, /* 0xC03F72AC, 0xA892D80F */
+};
+#ifdef __STDC__
+static const double pS3[5] = {
+#else
+static double pS3[5] = {
+#endif
+ 3.58560338055209726349e+01, /* 0x4041ED92, 0x84077DD3 */
+ 3.61513983050303863820e+02, /* 0x40769839, 0x464A7C0E */
+ 1.19360783792111533330e+03, /* 0x4092A66E, 0x6D1061D6 */
+ 1.12799679856907414432e+03, /* 0x40919FFC, 0xB8C39B7E */
+ 1.73580930813335754692e+02, /* 0x4065B296, 0xFC379081 */
+};
+
+#ifdef __STDC__
+static const double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#else
+static double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#endif
+ -8.87534333032526411254e-08, /* 0xBE77D316, 0xE927026D */
+ -7.03030995483624743247e-02, /* 0xBFB1FF62, 0x495E1E42 */
+ -1.45073846780952986357e+00, /* 0xBFF73639, 0x8A24A843 */
+ -7.63569613823527770791e+00, /* 0xC01E8AF3, 0xEDAFA7F3 */
+ -1.11931668860356747786e+01, /* 0xC02662E6, 0xC5246303 */
+ -3.23364579351335335033e+00, /* 0xC009DE81, 0xAF8FE70F */
+};
+#ifdef __STDC__
+static const double pS2[5] = {
+#else
+static double pS2[5] = {
+#endif
+ 2.22202997532088808441e+01, /* 0x40363865, 0x908B5959 */
+ 1.36206794218215208048e+02, /* 0x4061069E, 0x0EE8878F */
+ 2.70470278658083486789e+02, /* 0x4070E786, 0x42EA079B */
+ 1.53875394208320329881e+02, /* 0x40633C03, 0x3AB6FAFF */
+ 1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */
+};
+
+#ifdef __STDC__
+ static double pzero(double x)
+#else
+ static double pzero(x)
+ double x;
+#endif
+{
+#ifdef __STDC__
+ const double *p,*q;
+#else
+ double *p,*q;
+#endif
+ double z,r,s;
+ __int32_t ix;
+ GET_HIGH_WORD(ix,x);
+ ix &= 0x7fffffff;
+ if(ix>=0x40200000) {p = pR8; q= pS8;}
+ else if(ix>=0x40122E8B){p = pR5; q= pS5;}
+ else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
+ else if(ix>=0x40000000){p = pR2; q= pS2;}
+ z = one/(x*x);
+ r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+ s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
+ return one+ r/s;
+}
+
+
+/* For x >= 8, the asymptotic expansions of qzero is
+ * -1/8 s + 75/1024 s^3 - ..., where s = 1/x.
+ * We approximate pzero by
+ * qzero(x) = s*(-1.25 + (R/S))
+ * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10
+ * S = 1 + qS0*s^2 + ... + qS5*s^12
+ * and
+ * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22)
+ */
+#ifdef __STDC__
+static const double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#else
+static double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#endif
+ 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+ 7.32421874999935051953e-02, /* 0x3FB2BFFF, 0xFFFFFE2C */
+ 1.17682064682252693899e+01, /* 0x40278952, 0x5BB334D6 */
+ 5.57673380256401856059e+02, /* 0x40816D63, 0x15301825 */
+ 8.85919720756468632317e+03, /* 0x40C14D99, 0x3E18F46D */
+ 3.70146267776887834771e+04, /* 0x40E212D4, 0x0E901566 */
+};
+#ifdef __STDC__
+static const double qS8[6] = {
+#else
+static double qS8[6] = {
+#endif
+ 1.63776026895689824414e+02, /* 0x406478D5, 0x365B39BC */
+ 8.09834494656449805916e+03, /* 0x40BFA258, 0x4E6B0563 */
+ 1.42538291419120476348e+05, /* 0x41016652, 0x54D38C3F */
+ 8.03309257119514397345e+05, /* 0x412883DA, 0x83A52B43 */
+ 8.40501579819060512818e+05, /* 0x4129A66B, 0x28DE0B3D */
+ -3.43899293537866615225e+05, /* 0xC114FD6D, 0x2C9530C5 */
+};
+
+#ifdef __STDC__
+static const double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#else
+static double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#endif
+ 1.84085963594515531381e-11, /* 0x3DB43D8F, 0x29CC8CD9 */
+ 7.32421766612684765896e-02, /* 0x3FB2BFFF, 0xD172B04C */
+ 5.83563508962056953777e+00, /* 0x401757B0, 0xB9953DD3 */
+ 1.35111577286449829671e+02, /* 0x4060E392, 0x0A8788E9 */
+ 1.02724376596164097464e+03, /* 0x40900CF9, 0x9DC8C481 */
+ 1.98997785864605384631e+03, /* 0x409F17E9, 0x53C6E3A6 */
+};
+#ifdef __STDC__
+static const double qS5[6] = {
+#else
+static double qS5[6] = {
+#endif
+ 8.27766102236537761883e+01, /* 0x4054B1B3, 0xFB5E1543 */
+ 2.07781416421392987104e+03, /* 0x40A03BA0, 0xDA21C0CE */
+ 1.88472887785718085070e+04, /* 0x40D267D2, 0x7B591E6D */
+ 5.67511122894947329769e+04, /* 0x40EBB5E3, 0x97E02372 */
+ 3.59767538425114471465e+04, /* 0x40E19118, 0x1F7A54A0 */
+ -5.35434275601944773371e+03, /* 0xC0B4EA57, 0xBEDBC609 */
+};
+
+#ifdef __STDC__
+static const double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#else
+static double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#endif
+ 4.37741014089738620906e-09, /* 0x3E32CD03, 0x6ADECB82 */
+ 7.32411180042911447163e-02, /* 0x3FB2BFEE, 0x0E8D0842 */
+ 3.34423137516170720929e+00, /* 0x400AC0FC, 0x61149CF5 */
+ 4.26218440745412650017e+01, /* 0x40454F98, 0x962DAEDD */
+ 1.70808091340565596283e+02, /* 0x406559DB, 0xE25EFD1F */
+ 1.66733948696651168575e+02, /* 0x4064D77C, 0x81FA21E0 */
+};
+#ifdef __STDC__
+static const double qS3[6] = {
+#else
+static double qS3[6] = {
+#endif
+ 4.87588729724587182091e+01, /* 0x40486122, 0xBFE343A6 */
+ 7.09689221056606015736e+02, /* 0x40862D83, 0x86544EB3 */
+ 3.70414822620111362994e+03, /* 0x40ACF04B, 0xE44DFC63 */
+ 6.46042516752568917582e+03, /* 0x40B93C6C, 0xD7C76A28 */
+ 2.51633368920368957333e+03, /* 0x40A3A8AA, 0xD94FB1C0 */
+ -1.49247451836156386662e+02, /* 0xC062A7EB, 0x201CF40F */
+};
+
+#ifdef __STDC__
+static const double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#else
+static double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#endif
+ 1.50444444886983272379e-07, /* 0x3E84313B, 0x54F76BDB */
+ 7.32234265963079278272e-02, /* 0x3FB2BEC5, 0x3E883E34 */
+ 1.99819174093815998816e+00, /* 0x3FFFF897, 0xE727779C */
+ 1.44956029347885735348e+01, /* 0x402CFDBF, 0xAAF96FE5 */
+ 3.16662317504781540833e+01, /* 0x403FAA8E, 0x29FBDC4A */
+ 1.62527075710929267416e+01, /* 0x403040B1, 0x71814BB4 */
+};
+#ifdef __STDC__
+static const double qS2[6] = {
+#else
+static double qS2[6] = {
+#endif
+ 3.03655848355219184498e+01, /* 0x403E5D96, 0xF7C07AED */
+ 2.69348118608049844624e+02, /* 0x4070D591, 0xE4D14B40 */
+ 8.44783757595320139444e+02, /* 0x408A6645, 0x22B3BF22 */
+ 8.82935845112488550512e+02, /* 0x408B977C, 0x9C5CC214 */
+ 2.12666388511798828631e+02, /* 0x406A9553, 0x0E001365 */
+ -5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */
+};
+
+#ifdef __STDC__
+ static double qzero(double x)
+#else
+ static double qzero(x)
+ double x;
+#endif
+{
+#ifdef __STDC__
+ const double *p,*q;
+#else
+ double *p,*q;
+#endif
+ double s,r,z;
+ __int32_t ix;
+ GET_HIGH_WORD(ix,x);
+ ix &= 0x7fffffff;
+ if(ix>=0x40200000) {p = qR8; q= qS8;}
+ else if(ix>=0x40122E8B){p = qR5; q= qS5;}
+ else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
+ else if(ix>=0x40000000){p = qR2; q= qS2;}
+ z = one/(x*x);
+ r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+ s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
+ return (-.125 + r/s)/x;
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/e_j1.c b/newlib/libm/mathfp/e_j1.c
new file mode 100644
index 000000000..f93c77e00
--- /dev/null
+++ b/newlib/libm/mathfp/e_j1.c
@@ -0,0 +1,486 @@
+
+/* @(#)e_j1.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* j1(x), y1(x)
+ * Bessel function of the first and second kinds of order zero.
+ * Method -- j1(x):
+ * 1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ...
+ * 2. Reduce x to |x| since j1(x)=-j1(-x), and
+ * for x in (0,2)
+ * j1(x) = x/2 + x*z*R0/S0, where z = x*x;
+ * (precision: |j1/x - 1/2 - R0/S0 |<2**-61.51 )
+ * for x in (2,inf)
+ * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
+ * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
+ * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
+ * as follow:
+ * cos(x1) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
+ * = 1/sqrt(2) * (sin(x) - cos(x))
+ * sin(x1) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+ * = -1/sqrt(2) * (sin(x) + cos(x))
+ * (To avoid cancellation, use
+ * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * to compute the worse one.)
+ *
+ * 3 Special cases
+ * j1(nan)= nan
+ * j1(0) = 0
+ * j1(inf) = 0
+ *
+ * Method -- y1(x):
+ * 1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN
+ * 2. For x<2.
+ * Since
+ * y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...)
+ * therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function.
+ * We use the following function to approximate y1,
+ * y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2
+ * where for x in [0,2] (abs err less than 2**-65.89)
+ * U(z) = U0[0] + U0[1]*z + ... + U0[4]*z^4
+ * V(z) = 1 + v0[0]*z + ... + v0[4]*z^5
+ * Note: For tiny x, 1/x dominate y1 and hence
+ * y1(tiny) = -2/pi/tiny, (choose tiny<2**-54)
+ * 3. For x>=2.
+ * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
+ * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
+ * by method mentioned above.
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+static double pone(double), qone(double);
+#else
+static double pone(), qone();
+#endif
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+huge = 1e300,
+one = 1.0,
+invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
+tpi = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
+ /* R0/S0 on [0,2] */
+r00 = -6.25000000000000000000e-02, /* 0xBFB00000, 0x00000000 */
+r01 = 1.40705666955189706048e-03, /* 0x3F570D9F, 0x98472C61 */
+r02 = -1.59955631084035597520e-05, /* 0xBEF0C5C6, 0xBA169668 */
+r03 = 4.96727999609584448412e-08, /* 0x3E6AAAFA, 0x46CA0BD9 */
+s01 = 1.91537599538363460805e-02, /* 0x3F939D0B, 0x12637E53 */
+s02 = 1.85946785588630915560e-04, /* 0x3F285F56, 0xB9CDF664 */
+s03 = 1.17718464042623683263e-06, /* 0x3EB3BFF8, 0x333F8498 */
+s04 = 5.04636257076217042715e-09, /* 0x3E35AC88, 0xC97DFF2C */
+s05 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */
+
+#ifdef __STDC__
+static const double zero = 0.0;
+#else
+static double zero = 0.0;
+#endif
+
+#ifdef __STDC__
+ double j1(double x)
+#else
+ double j1(x)
+ double x;
+#endif
+{
+ double z, s,c,ss,cc,r,u,v,y;
+ __int32_t hx,ix;
+
+ GET_HIGH_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7ff00000) return one/x;
+ y = fabs(x);
+ if(ix >= 0x40000000) { /* |x| >= 2.0 */
+ s = sin(y);
+ c = cos(y);
+ ss = -s-c;
+ cc = s-c;
+ if(ix<0x7fe00000) { /* make sure y+y not overflow */
+ z = cos(y+y);
+ if ((s*c)>zero) cc = z/ss;
+ else ss = z/cc;
+ }
+ /*
+ * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
+ * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
+ */
+ if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(y);
+ else {
+ u = pone(y); v = qone(y);
+ z = invsqrtpi*(u*cc-v*ss)/sqrt(y);
+ }
+ if(hx<0) return -z;
+ else return z;
+ }
+ if(ix<0x3e400000) { /* |x|<2**-27 */
+ if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */
+ }
+ z = x*x;
+ r = z*(r00+z*(r01+z*(r02+z*r03)));
+ s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
+ r *= x;
+ return(x*0.5+r/s);
+}
+
+#ifdef __STDC__
+static const double U0[5] = {
+#else
+static double U0[5] = {
+#endif
+ -1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */
+ 5.04438716639811282616e-02, /* 0x3FA9D3C7, 0x76292CD1 */
+ -1.91256895875763547298e-03, /* 0xBF5F55E5, 0x4844F50F */
+ 2.35252600561610495928e-05, /* 0x3EF8AB03, 0x8FA6B88E */
+ -9.19099158039878874504e-08, /* 0xBE78AC00, 0x569105B8 */
+};
+#ifdef __STDC__
+static const double V0[5] = {
+#else
+static double V0[5] = {
+#endif
+ 1.99167318236649903973e-02, /* 0x3F94650D, 0x3F4DA9F0 */
+ 2.02552581025135171496e-04, /* 0x3F2A8C89, 0x6C257764 */
+ 1.35608801097516229404e-06, /* 0x3EB6C05A, 0x894E8CA6 */
+ 6.22741452364621501295e-09, /* 0x3E3ABF1D, 0x5BA69A86 */
+ 1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */
+};
+
+#ifdef __STDC__
+ double y1(double x)
+#else
+ double y1(x)
+ double x;
+#endif
+{
+ double z, s,c,ss,cc,u,v;
+ __int32_t hx,ix,lx;
+
+ EXTRACT_WORDS(hx,lx,x);
+ ix = 0x7fffffff&hx;
+ /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
+ if(ix>=0x7ff00000) return one/(x+x*x);
+ if((ix|lx)==0) return -one/zero;
+ if(hx<0) return zero/zero;
+ if(ix >= 0x40000000) { /* |x| >= 2.0 */
+ s = sin(x);
+ c = cos(x);
+ ss = -s-c;
+ cc = s-c;
+ if(ix<0x7fe00000) { /* make sure x+x not overflow */
+ z = cos(x+x);
+ if ((s*c)>zero) cc = z/ss;
+ else ss = z/cc;
+ }
+ /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0))
+ * where x0 = x-3pi/4
+ * Better formula:
+ * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
+ * = 1/sqrt(2) * (sin(x) - cos(x))
+ * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+ * = -1/sqrt(2) * (cos(x) + sin(x))
+ * To avoid cancellation, use
+ * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * to compute the worse one.
+ */
+ if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x);
+ else {
+ u = pone(x); v = qone(x);
+ z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
+ }
+ return z;
+ }
+ if(ix<=0x3c900000) { /* x < 2**-54 */
+ return(-tpi/x);
+ }
+ z = x*x;
+ u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
+ v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
+ return(x*(u/v) + tpi*(j1(x)*log(x)-one/x));
+}
+
+/* For x >= 8, the asymptotic expansions of pone is
+ * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x.
+ * We approximate pone by
+ * pone(x) = 1 + (R/S)
+ * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
+ * S = 1 + ps0*s^2 + ... + ps4*s^10
+ * and
+ * | pone(x)-1-R/S | <= 2 ** ( -60.06)
+ */
+
+#ifdef __STDC__
+static const double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#else
+static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#endif
+ 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+ 1.17187499999988647970e-01, /* 0x3FBDFFFF, 0xFFFFFCCE */
+ 1.32394806593073575129e+01, /* 0x402A7A9D, 0x357F7FCE */
+ 4.12051854307378562225e+02, /* 0x4079C0D4, 0x652EA590 */
+ 3.87474538913960532227e+03, /* 0x40AE457D, 0xA3A532CC */
+ 7.91447954031891731574e+03, /* 0x40BEEA7A, 0xC32782DD */
+};
+#ifdef __STDC__
+static const double ps8[5] = {
+#else
+static double ps8[5] = {
+#endif
+ 1.14207370375678408436e+02, /* 0x405C8D45, 0x8E656CAC */
+ 3.65093083420853463394e+03, /* 0x40AC85DC, 0x964D274F */
+ 3.69562060269033463555e+04, /* 0x40E20B86, 0x97C5BB7F */
+ 9.76027935934950801311e+04, /* 0x40F7D42C, 0xB28F17BB */
+ 3.08042720627888811578e+04, /* 0x40DE1511, 0x697A0B2D */
+};
+
+#ifdef __STDC__
+static const double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#else
+static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#endif
+ 1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */
+ 1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */
+ 6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */
+ 1.08308182990189109773e+02, /* 0x405B13B9, 0x452602ED */
+ 5.17636139533199752805e+02, /* 0x40802D16, 0xD052D649 */
+ 5.28715201363337541807e+02, /* 0x408085B8, 0xBB7E0CB7 */
+};
+#ifdef __STDC__
+static const double ps5[5] = {
+#else
+static double ps5[5] = {
+#endif
+ 5.92805987221131331921e+01, /* 0x404DA3EA, 0xA8AF633D */
+ 9.91401418733614377743e+02, /* 0x408EFB36, 0x1B066701 */
+ 5.35326695291487976647e+03, /* 0x40B4E944, 0x5706B6FB */
+ 7.84469031749551231769e+03, /* 0x40BEA4B0, 0xB8A5BB15 */
+ 1.50404688810361062679e+03, /* 0x40978030, 0x036F5E51 */
+};
+
+#ifdef __STDC__
+static const double pr3[6] = {
+#else
+static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#endif
+ 3.02503916137373618024e-09, /* 0x3E29FC21, 0xA7AD9EDD */
+ 1.17186865567253592491e-01, /* 0x3FBDFFF5, 0x5B21D17B */
+ 3.93297750033315640650e+00, /* 0x400F76BC, 0xE85EAD8A */
+ 3.51194035591636932736e+01, /* 0x40418F48, 0x9DA6D129 */
+ 9.10550110750781271918e+01, /* 0x4056C385, 0x4D2C1837 */
+ 4.85590685197364919645e+01, /* 0x4048478F, 0x8EA83EE5 */
+};
+#ifdef __STDC__
+static const double ps3[5] = {
+#else
+static double ps3[5] = {
+#endif
+ 3.47913095001251519989e+01, /* 0x40416549, 0xA134069C */
+ 3.36762458747825746741e+02, /* 0x40750C33, 0x07F1A75F */
+ 1.04687139975775130551e+03, /* 0x40905B7C, 0x5037D523 */
+ 8.90811346398256432622e+02, /* 0x408BD67D, 0xA32E31E9 */
+ 1.03787932439639277504e+02, /* 0x4059F26D, 0x7C2EED53 */
+};
+
+#ifdef __STDC__
+static const double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#else
+static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#endif
+ 1.07710830106873743082e-07, /* 0x3E7CE9D4, 0xF65544F4 */
+ 1.17176219462683348094e-01, /* 0x3FBDFF42, 0xBE760D83 */
+ 2.36851496667608785174e+00, /* 0x4002F2B7, 0xF98FAEC0 */
+ 1.22426109148261232917e+01, /* 0x40287C37, 0x7F71A964 */
+ 1.76939711271687727390e+01, /* 0x4031B1A8, 0x177F8EE2 */
+ 5.07352312588818499250e+00, /* 0x40144B49, 0xA574C1FE */
+};
+#ifdef __STDC__
+static const double ps2[5] = {
+#else
+static double ps2[5] = {
+#endif
+ 2.14364859363821409488e+01, /* 0x40356FBD, 0x8AD5ECDC */
+ 1.25290227168402751090e+02, /* 0x405F5293, 0x14F92CD5 */
+ 2.32276469057162813669e+02, /* 0x406D08D8, 0xD5A2DBD9 */
+ 1.17679373287147100768e+02, /* 0x405D6B7A, 0xDA1884A9 */
+ 8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */
+};
+
+#ifdef __STDC__
+ static double pone(double x)
+#else
+ static double pone(x)
+ double x;
+#endif
+{
+#ifdef __STDC__
+ const double *p,*q;
+#else
+ double *p,*q;
+#endif
+ double z,r,s;
+ __int32_t ix;
+ GET_HIGH_WORD(ix,x);
+ ix &= 0x7fffffff;
+ if(ix>=0x40200000) {p = pr8; q= ps8;}
+ else if(ix>=0x40122E8B){p = pr5; q= ps5;}
+ else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
+ else if(ix>=0x40000000){p = pr2; q= ps2;}
+ z = one/(x*x);
+ r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+ s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
+ return one+ r/s;
+}
+
+
+/* For x >= 8, the asymptotic expansions of qone is
+ * 3/8 s - 105/1024 s^3 - ..., where s = 1/x.
+ * We approximate pone by
+ * qone(x) = s*(0.375 + (R/S))
+ * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
+ * S = 1 + qs1*s^2 + ... + qs6*s^12
+ * and
+ * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13)
+ */
+
+#ifdef __STDC__
+static const double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#else
+static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#endif
+ 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+ -1.02539062499992714161e-01, /* 0xBFBA3FFF, 0xFFFFFDF3 */
+ -1.62717534544589987888e+01, /* 0xC0304591, 0xA26779F7 */
+ -7.59601722513950107896e+02, /* 0xC087BCD0, 0x53E4B576 */
+ -1.18498066702429587167e+04, /* 0xC0C724E7, 0x40F87415 */
+ -4.84385124285750353010e+04, /* 0xC0E7A6D0, 0x65D09C6A */
+};
+#ifdef __STDC__
+static const double qs8[6] = {
+#else
+static double qs8[6] = {
+#endif
+ 1.61395369700722909556e+02, /* 0x40642CA6, 0xDE5BCDE5 */
+ 7.82538599923348465381e+03, /* 0x40BE9162, 0xD0D88419 */
+ 1.33875336287249578163e+05, /* 0x4100579A, 0xB0B75E98 */
+ 7.19657723683240939863e+05, /* 0x4125F653, 0x72869C19 */
+ 6.66601232617776375264e+05, /* 0x412457D2, 0x7719AD5C */
+ -2.94490264303834643215e+05, /* 0xC111F969, 0x0EA5AA18 */
+};
+
+#ifdef __STDC__
+static const double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#else
+static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#endif
+ -2.08979931141764104297e-11, /* 0xBDB6FA43, 0x1AA1A098 */
+ -1.02539050241375426231e-01, /* 0xBFBA3FFF, 0xCB597FEF */
+ -8.05644828123936029840e+00, /* 0xC0201CE6, 0xCA03AD4B */
+ -1.83669607474888380239e+02, /* 0xC066F56D, 0x6CA7B9B0 */
+ -1.37319376065508163265e+03, /* 0xC09574C6, 0x6931734F */
+ -2.61244440453215656817e+03, /* 0xC0A468E3, 0x88FDA79D */
+};
+#ifdef __STDC__
+static const double qs5[6] = {
+#else
+static double qs5[6] = {
+#endif
+ 8.12765501384335777857e+01, /* 0x405451B2, 0xFF5A11B2 */
+ 1.99179873460485964642e+03, /* 0x409F1F31, 0xE77BF839 */
+ 1.74684851924908907677e+04, /* 0x40D10F1F, 0x0D64CE29 */
+ 4.98514270910352279316e+04, /* 0x40E8576D, 0xAABAD197 */
+ 2.79480751638918118260e+04, /* 0x40DB4B04, 0xCF7C364B */
+ -4.71918354795128470869e+03, /* 0xC0B26F2E, 0xFCFFA004 */
+};
+
+#ifdef __STDC__
+static const double qr3[6] = {
+#else
+static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#endif
+ -5.07831226461766561369e-09, /* 0xBE35CFA9, 0xD38FC84F */
+ -1.02537829820837089745e-01, /* 0xBFBA3FEB, 0x51AEED54 */
+ -4.61011581139473403113e+00, /* 0xC01270C2, 0x3302D9FF */
+ -5.78472216562783643212e+01, /* 0xC04CEC71, 0xC25D16DA */
+ -2.28244540737631695038e+02, /* 0xC06C87D3, 0x4718D55F */
+ -2.19210128478909325622e+02, /* 0xC06B66B9, 0x5F5C1BF6 */
+};
+#ifdef __STDC__
+static const double qs3[6] = {
+#else
+static double qs3[6] = {
+#endif
+ 4.76651550323729509273e+01, /* 0x4047D523, 0xCCD367E4 */
+ 6.73865112676699709482e+02, /* 0x40850EEB, 0xC031EE3E */
+ 3.38015286679526343505e+03, /* 0x40AA684E, 0x448E7C9A */
+ 5.54772909720722782367e+03, /* 0x40B5ABBA, 0xA61D54A6 */
+ 1.90311919338810798763e+03, /* 0x409DBC7A, 0x0DD4DF4B */
+ -1.35201191444307340817e+02, /* 0xC060E670, 0x290A311F */
+};
+
+#ifdef __STDC__
+static const double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#else
+static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#endif
+ -1.78381727510958865572e-07, /* 0xBE87F126, 0x44C626D2 */
+ -1.02517042607985553460e-01, /* 0xBFBA3E8E, 0x9148B010 */
+ -2.75220568278187460720e+00, /* 0xC0060484, 0x69BB4EDA */
+ -1.96636162643703720221e+01, /* 0xC033A9E2, 0xC168907F */
+ -4.23253133372830490089e+01, /* 0xC04529A3, 0xDE104AAA */
+ -2.13719211703704061733e+01, /* 0xC0355F36, 0x39CF6E52 */
+};
+#ifdef __STDC__
+static const double qs2[6] = {
+#else
+static double qs2[6] = {
+#endif
+ 2.95333629060523854548e+01, /* 0x403D888A, 0x78AE64FF */
+ 2.52981549982190529136e+02, /* 0x406F9F68, 0xDB821CBA */
+ 7.57502834868645436472e+02, /* 0x4087AC05, 0xCE49A0F7 */
+ 7.39393205320467245656e+02, /* 0x40871B25, 0x48D4C029 */
+ 1.55949003336666123687e+02, /* 0x40637E5E, 0x3C3ED8D4 */
+ -4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */
+};
+
+#ifdef __STDC__
+ static double qone(double x)
+#else
+ static double qone(x)
+ double x;
+#endif
+{
+#ifdef __STDC__
+ const double *p,*q;
+#else
+ double *p,*q;
+#endif
+ double s,r,z;
+ __int32_t ix;
+ GET_HIGH_WORD(ix,x);
+ ix &= 0x7fffffff;
+ if(ix>=0x40200000) {p = qr8; q= qs8;}
+ else if(ix>=0x40122E8B){p = qr5; q= qs5;}
+ else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
+ else if(ix>=0x40000000){p = qr2; q= qs2;}
+ z = one/(x*x);
+ r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+ s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
+ return (.375 + r/s)/x;
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/e_remainder.c b/newlib/libm/mathfp/e_remainder.c
new file mode 100644
index 000000000..02a714d5b
--- /dev/null
+++ b/newlib/libm/mathfp/e_remainder.c
@@ -0,0 +1,113 @@
+
+/* @(#)e_remainder.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+FUNCTION
+<<remainder>>, <<remainderf>>---round and remainder
+INDEX
+ remainder
+INDEX
+ remainderf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double remainder(double <[x]>, double <[y]>);
+ float remainderf(float <[x]>, float <[y]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double remainder(<[x]>,<[y]>)
+ double <[x]>, <[y]>;
+ float remainderf(<[x]>,<[y]>)
+ float <[x]>, <[y]>;
+
+DESCRIPTION
+<<remainder>> and <<remainderf>> find the remainder of
+<[x]>/<[y]>; this value is in the range -<[y]>/2 .. +<[y]>/2.
+
+RETURNS
+<<remainder>> returns the integer result as a double.
+
+PORTABILITY
+<<remainder>> is a System V release 4.
+<<remainderf>> is an extension.
+
+*/
+
+/* remainder(x,p)
+ * Return :
+ * returns x REM p = x - [x/p]*p as if in infinite
+ * precise arithmetic, where [x/p] is the (infinite bit)
+ * integer nearest x/p (in half way case choose the even one).
+ * Method :
+ * Based on fmod() return x-[x/p]chopped*p exactlp.
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+static const double zero = 0.0;
+#else
+static double zero = 0.0;
+#endif
+
+
+#ifdef __STDC__
+ double remainder(double x, double p)
+#else
+ double remainder(x,p)
+ double x,p;
+#endif
+{
+ __int32_t hx,hp;
+ __uint32_t sx,lx,lp;
+ double p_half;
+
+ EXTRACT_WORDS(hx,lx,x);
+ EXTRACT_WORDS(hp,lp,p);
+ sx = hx&0x80000000;
+ hp &= 0x7fffffff;
+ hx &= 0x7fffffff;
+
+ /* purge off exception values */
+ if((hp|lp)==0) return (x*p)/(x*p); /* p = 0 */
+ if((hx>=0x7ff00000)|| /* x not finite */
+ ((hp>=0x7ff00000)&& /* p is NaN */
+ (((hp-0x7ff00000)|lp)!=0)))
+ return (x*p)/(x*p);
+
+
+ if (hp<=0x7fdfffff) x = fmod(x,p+p); /* now x < 2p */
+ if (((hx-hp)|(lx-lp))==0) return zero*x;
+ x = fabs(x);
+ p = fabs(p);
+ if (hp<0x00200000) {
+ if(x+x>p) {
+ x-=p;
+ if(x+x>=p) x -= p;
+ }
+ } else {
+ p_half = 0.5*p;
+ if(x>p_half) {
+ x-=p;
+ if(x>=p_half) x -= p;
+ }
+ }
+ GET_HIGH_WORD(hx,x);
+ SET_HIGH_WORD(x,hx^sx);
+ return x;
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/e_scalb.c b/newlib/libm/mathfp/e_scalb.c
new file mode 100644
index 000000000..c4056e03b
--- /dev/null
+++ b/newlib/libm/mathfp/e_scalb.c
@@ -0,0 +1,55 @@
+
+/* @(#)e_scalb.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * __ieee754_scalb(x, fn) is provide for
+ * passing various standard test suite. One
+ * should use scalbn() instead.
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef _SCALB_INT
+#ifdef __STDC__
+ double scalb(double x, int fn)
+#else
+ double scalb(x,fn)
+ double x; int fn;
+#endif
+#else
+#ifdef __STDC__
+ double scalb(double x, double fn)
+#else
+ double scalb(x,fn)
+ double x, fn;
+#endif
+#endif
+{
+#ifdef _SCALB_INT
+ return scalbn(x,fn);
+#else
+ if (isnan(x)||isnan(fn)) return x*fn;
+ if (!finite(fn)) {
+ if(fn>0.0) return x*fn;
+ else return x/(-fn);
+ }
+ if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
+ if ( fn > 65000.0) return scalbn(x, 65000);
+ if (-fn > 65000.0) return scalbn(x,-65000);
+ return scalbn(x,(int)fn);
+#endif
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/ef_acosh.c b/newlib/libm/mathfp/ef_acosh.c
new file mode 100644
index 000000000..705be4986
--- /dev/null
+++ b/newlib/libm/mathfp/ef_acosh.c
@@ -0,0 +1,53 @@
+/* ef_acosh.c -- float version of e_acosh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const float
+#else
+static float
+#endif
+one = 1.0,
+ln2 = 6.9314718246e-01; /* 0x3f317218 */
+
+#ifdef __STDC__
+ float acoshf(float x)
+#else
+ float acoshf(x)
+ float x;
+#endif
+{
+ float t;
+ __int32_t hx;
+ GET_FLOAT_WORD(hx,x);
+ if(hx<0x3f800000) { /* x < 1 */
+ return (x-x)/(x-x);
+ } else if(hx >=0x4d800000) { /* x > 2**28 */
+ if(hx >=0x7f800000) { /* x is inf of NaN */
+ return x+x;
+ } else
+ return logf(x)+ln2; /* acosh(huge)=log(2x) */
+ } else if (hx==0x3f800000) {
+ return 0.0; /* acosh(1) = 0 */
+ } else if (hx > 0x40000000) { /* 2**28 > x > 2 */
+ t=x*x;
+ return logf((float)2.0*x-one/(x+sqrtf(t-one)));
+ } else { /* 1<x<2 */
+ t = x-one;
+ return log1pf(t+sqrtf((float)2.0*t+t*t));
+ }
+}
diff --git a/newlib/libm/mathfp/ef_atanh.c b/newlib/libm/mathfp/ef_atanh.c
new file mode 100644
index 000000000..bfc40dec1
--- /dev/null
+++ b/newlib/libm/mathfp/ef_atanh.c
@@ -0,0 +1,54 @@
+/* ef_atanh.c -- float version of e_atanh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const float one = 1.0, huge = 1e30;
+#else
+static float one = 1.0, huge = 1e30;
+#endif
+
+#ifdef __STDC__
+static const float zero = 0.0;
+#else
+static float zero = 0.0;
+#endif
+
+#ifdef __STDC__
+ float atanhf(float x)
+#else
+ float atanhf(x)
+ float x;
+#endif
+{
+ float t;
+ __int32_t hx,ix;
+ GET_FLOAT_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if (ix>0x3f800000) /* |x|>1 */
+ return (x-x)/(x-x);
+ if(ix==0x3f800000)
+ return x/zero;
+ if(ix<0x31800000&&(huge+x)>zero) return x; /* x<2**-28 */
+ SET_FLOAT_WORD(x,ix);
+ if(ix<0x3f000000) { /* x < 0.5 */
+ t = x+x;
+ t = (float)0.5*log1pf(t+t*x/(one-x));
+ } else
+ t = (float)0.5*log1pf((x+x)/(one-x));
+ if(hx>=0) return t; else return -t;
+}
diff --git a/newlib/libm/mathfp/ef_hypot.c b/newlib/libm/mathfp/ef_hypot.c
new file mode 100644
index 000000000..8e5f4ccef
--- /dev/null
+++ b/newlib/libm/mathfp/ef_hypot.c
@@ -0,0 +1,82 @@
+/* ef_hypot.c -- float version of e_hypot.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ float hypotf(float x, float y)
+#else
+ float hypotf(x,y)
+ float x, y;
+#endif
+{
+ float a=x,b=y,t1,t2,y1,y2,w;
+ __int32_t j,k,ha,hb;
+
+ GET_FLOAT_WORD(ha,x);
+ ha &= 0x7fffffffL;
+ GET_FLOAT_WORD(hb,y);
+ hb &= 0x7fffffffL;
+ if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
+ SET_FLOAT_WORD(a,ha); /* a <- |a| */
+ SET_FLOAT_WORD(b,hb); /* b <- |b| */
+ if((ha-hb)>0xf000000L) {return a+b;} /* x/y > 2**30 */
+ k=0;
+ if(ha > 0x58800000L) { /* a>2**50 */
+ if(ha >= 0x7f800000L) { /* Inf or NaN */
+ w = a+b; /* for sNaN */
+ if(ha == 0x7f800000L) w = a;
+ if(hb == 0x7f800000L) w = b;
+ return w;
+ }
+ /* scale a and b by 2**-60 */
+ ha -= 0x5d800000L; hb -= 0x5d800000L; k += 60;
+ SET_FLOAT_WORD(a,ha);
+ SET_FLOAT_WORD(b,hb);
+ }
+ if(hb < 0x26800000L) { /* b < 2**-50 */
+ if(hb <= 0x007fffffL) { /* subnormal b or 0 */
+ if(hb==0) return a;
+ SET_FLOAT_WORD(t1,0x3f000000L); /* t1=2^126 */
+ b *= t1;
+ a *= t1;
+ k -= 126;
+ } else { /* scale a and b by 2^60 */
+ ha += 0x5d800000; /* a *= 2^60 */
+ hb += 0x5d800000; /* b *= 2^60 */
+ k -= 60;
+ SET_FLOAT_WORD(a,ha);
+ SET_FLOAT_WORD(b,hb);
+ }
+ }
+ /* medium size a and b */
+ w = a-b;
+ if (w>b) {
+ SET_FLOAT_WORD(t1,ha&0xfffff000L);
+ t2 = a-t1;
+ w = sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
+ } else {
+ a = a+a;
+ SET_FLOAT_WORD(y1,hb&0xfffff000L);
+ y2 = b - y1;
+ SET_FLOAT_WORD(t1,ha+0x00800000L);
+ t2 = a - t1;
+ w = sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
+ }
+ if(k!=0) {
+ SET_FLOAT_WORD(t1,0x3f800000L+(k<<23));
+ return t1*w;
+ } else return w;
+}
diff --git a/newlib/libm/mathfp/ef_j0.c b/newlib/libm/mathfp/ef_j0.c
new file mode 100644
index 000000000..65975f4a5
--- /dev/null
+++ b/newlib/libm/mathfp/ef_j0.c
@@ -0,0 +1,439 @@
+/* ef_j0.c -- float version of e_j0.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static float pzerof(float), qzerof(float);
+#else
+static float pzerof(), qzerof();
+#endif
+
+#ifdef __STDC__
+static const float
+#else
+static float
+#endif
+huge = 1e30,
+one = 1.0,
+invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */
+tpi = 6.3661974669e-01, /* 0x3f22f983 */
+ /* R0/S0 on [0, 2.00] */
+R02 = 1.5625000000e-02, /* 0x3c800000 */
+R03 = -1.8997929874e-04, /* 0xb947352e */
+R04 = 1.8295404516e-06, /* 0x35f58e88 */
+R05 = -4.6183270541e-09, /* 0xb19eaf3c */
+S01 = 1.5619102865e-02, /* 0x3c7fe744 */
+S02 = 1.1692678527e-04, /* 0x38f53697 */
+S03 = 5.1354652442e-07, /* 0x3509daa6 */
+S04 = 1.1661400734e-09; /* 0x30a045e8 */
+
+#ifdef __STDC__
+static const float zero = 0.0;
+#else
+static float zero = 0.0;
+#endif
+
+#ifdef __STDC__
+ float j0f(float x)
+#else
+ float j0f(x)
+ float x;
+#endif
+{
+ float z, s,c,ss,cc,r,u,v;
+ __int32_t hx,ix;
+
+ GET_FLOAT_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7f800000) return one/(x*x);
+ x = fabsf(x);
+ if(ix >= 0x40000000) { /* |x| >= 2.0 */
+ s = sinf(x);
+ c = cosf(x);
+ ss = s-c;
+ cc = s+c;
+ if(ix<0x7f000000) { /* make sure x+x not overflow */
+ z = -cosf(x+x);
+ if ((s*c)<zero) cc = z/ss;
+ else ss = z/cc;
+ }
+ /*
+ * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
+ * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
+ */
+ if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(x);
+ else {
+ u = pzerof(x); v = qzerof(x);
+ z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
+ }
+ return z;
+ }
+ if(ix<0x39000000) { /* |x| < 2**-13 */
+ if(huge+x>one) { /* raise inexact if x != 0 */
+ if(ix<0x32000000) return one; /* |x|<2**-27 */
+ else return one - (float)0.25*x*x;
+ }
+ }
+ z = x*x;
+ r = z*(R02+z*(R03+z*(R04+z*R05)));
+ s = one+z*(S01+z*(S02+z*(S03+z*S04)));
+ if(ix < 0x3F800000) { /* |x| < 1.00 */
+ return one + z*((float)-0.25+(r/s));
+ } else {
+ u = (float)0.5*x;
+ return((one+u)*(one-u)+z*(r/s));
+ }
+}
+
+#ifdef __STDC__
+static const float
+#else
+static float
+#endif
+u00 = -7.3804296553e-02, /* 0xbd9726b5 */
+u01 = 1.7666645348e-01, /* 0x3e34e80d */
+u02 = -1.3818567619e-02, /* 0xbc626746 */
+u03 = 3.4745343146e-04, /* 0x39b62a69 */
+u04 = -3.8140706238e-06, /* 0xb67ff53c */
+u05 = 1.9559013964e-08, /* 0x32a802ba */
+u06 = -3.9820518410e-11, /* 0xae2f21eb */
+v01 = 1.2730483897e-02, /* 0x3c509385 */
+v02 = 7.6006865129e-05, /* 0x389f65e0 */
+v03 = 2.5915085189e-07, /* 0x348b216c */
+v04 = 4.4111031494e-10; /* 0x2ff280c2 */
+
+#ifdef __STDC__
+ float y0f(float x)
+#else
+ float y0f(x)
+ float x;
+#endif
+{
+ float z, s,c,ss,cc,u,v;
+ __int32_t hx,ix;
+
+ GET_FLOAT_WORD(hx,x);
+ ix = 0x7fffffff&hx;
+ /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */
+ if(ix>=0x7f800000) return one/(x+x*x);
+ if(ix==0) return -one/zero;
+ if(hx<0) return zero/zero;
+ if(ix >= 0x40000000) { /* |x| >= 2.0 */
+ /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
+ * where x0 = x-pi/4
+ * Better formula:
+ * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
+ * = 1/sqrt(2) * (sin(x) + cos(x))
+ * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+ * = 1/sqrt(2) * (sin(x) - cos(x))
+ * To avoid cancellation, use
+ * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * to compute the worse one.
+ */
+ s = sinf(x);
+ c = cosf(x);
+ ss = s-c;
+ cc = s+c;
+ /*
+ * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
+ * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
+ */
+ if(ix<0x7f000000) { /* make sure x+x not overflow */
+ z = -cosf(x+x);
+ if ((s*c)<zero) cc = z/ss;
+ else ss = z/cc;
+ }
+ if(ix>0x80000000) z = (invsqrtpi*ss)/sqrtf(x);
+ else {
+ u = pzerof(x); v = qzerof(x);
+ z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
+ }
+ return z;
+ }
+ if(ix<=0x32000000) { /* x < 2**-27 */
+ return(u00 + tpi*logf(x));
+ }
+ z = x*x;
+ u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
+ v = one+z*(v01+z*(v02+z*(v03+z*v04)));
+ return(u/v + tpi*(j0f(x)*logf(x)));
+}
+
+/* The asymptotic expansions of pzero is
+ * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x.
+ * For x >= 2, We approximate pzero by
+ * pzero(x) = 1 + (R/S)
+ * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10
+ * S = 1 + pS0*s^2 + ... + pS4*s^10
+ * and
+ * | pzero(x)-1-R/S | <= 2 ** ( -60.26)
+ */
+#ifdef __STDC__
+static const float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#else
+static float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#endif
+ 0.0000000000e+00, /* 0x00000000 */
+ -7.0312500000e-02, /* 0xbd900000 */
+ -8.0816707611e+00, /* 0xc1014e86 */
+ -2.5706311035e+02, /* 0xc3808814 */
+ -2.4852163086e+03, /* 0xc51b5376 */
+ -5.2530439453e+03, /* 0xc5a4285a */
+};
+#ifdef __STDC__
+static const float pS8[5] = {
+#else
+static float pS8[5] = {
+#endif
+ 1.1653436279e+02, /* 0x42e91198 */
+ 3.8337448730e+03, /* 0x456f9beb */
+ 4.0597855469e+04, /* 0x471e95db */
+ 1.1675296875e+05, /* 0x47e4087c */
+ 4.7627726562e+04, /* 0x473a0bba */
+};
+#ifdef __STDC__
+static const float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#else
+static float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#endif
+ -1.1412546255e-11, /* 0xad48c58a */
+ -7.0312492549e-02, /* 0xbd8fffff */
+ -4.1596107483e+00, /* 0xc0851b88 */
+ -6.7674766541e+01, /* 0xc287597b */
+ -3.3123129272e+02, /* 0xc3a59d9b */
+ -3.4643338013e+02, /* 0xc3ad3779 */
+};
+#ifdef __STDC__
+static const float pS5[5] = {
+#else
+static float pS5[5] = {
+#endif
+ 6.0753936768e+01, /* 0x42730408 */
+ 1.0512523193e+03, /* 0x44836813 */
+ 5.9789707031e+03, /* 0x45bad7c4 */
+ 9.6254453125e+03, /* 0x461665c8 */
+ 2.4060581055e+03, /* 0x451660ee */
+};
+
+#ifdef __STDC__
+static const float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#else
+static float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#endif
+ -2.5470459075e-09, /* 0xb12f081b */
+ -7.0311963558e-02, /* 0xbd8fffb8 */
+ -2.4090321064e+00, /* 0xc01a2d95 */
+ -2.1965976715e+01, /* 0xc1afba52 */
+ -5.8079170227e+01, /* 0xc2685112 */
+ -3.1447946548e+01, /* 0xc1fb9565 */
+};
+#ifdef __STDC__
+static const float pS3[5] = {
+#else
+static float pS3[5] = {
+#endif
+ 3.5856033325e+01, /* 0x420f6c94 */
+ 3.6151397705e+02, /* 0x43b4c1ca */
+ 1.1936077881e+03, /* 0x44953373 */
+ 1.1279968262e+03, /* 0x448cffe6 */
+ 1.7358093262e+02, /* 0x432d94b8 */
+};
+
+#ifdef __STDC__
+static const float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#else
+static float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#endif
+ -8.8753431271e-08, /* 0xb3be98b7 */
+ -7.0303097367e-02, /* 0xbd8ffb12 */
+ -1.4507384300e+00, /* 0xbfb9b1cc */
+ -7.6356959343e+00, /* 0xc0f4579f */
+ -1.1193166733e+01, /* 0xc1331736 */
+ -3.2336456776e+00, /* 0xc04ef40d */
+};
+#ifdef __STDC__
+static const float pS2[5] = {
+#else
+static float pS2[5] = {
+#endif
+ 2.2220300674e+01, /* 0x41b1c32d */
+ 1.3620678711e+02, /* 0x430834f0 */
+ 2.7047027588e+02, /* 0x43873c32 */
+ 1.5387539673e+02, /* 0x4319e01a */
+ 1.4657617569e+01, /* 0x416a859a */
+};
+
+#ifdef __STDC__
+ static float pzerof(float x)
+#else
+ static float pzerof(x)
+ float x;
+#endif
+{
+#ifdef __STDC__
+ const float *p,*q;
+#else
+ float *p,*q;
+#endif
+ float z,r,s;
+ __int32_t ix;
+ GET_FLOAT_WORD(ix,x);
+ ix &= 0x7fffffff;
+ if(ix>=0x41000000) {p = pR8; q= pS8;}
+ else if(ix>=0x40f71c58){p = pR5; q= pS5;}
+ else if(ix>=0x4036db68){p = pR3; q= pS3;}
+ else if(ix>=0x40000000){p = pR2; q= pS2;}
+ z = one/(x*x);
+ r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+ s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
+ return one+ r/s;
+}
+
+
+/* For x >= 8, the asymptotic expansions of qzero is
+ * -1/8 s + 75/1024 s^3 - ..., where s = 1/x.
+ * We approximate pzero by
+ * qzero(x) = s*(-1.25 + (R/S))
+ * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10
+ * S = 1 + qS0*s^2 + ... + qS5*s^12
+ * and
+ * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22)
+ */
+#ifdef __STDC__
+static const float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#else
+static float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#endif
+ 0.0000000000e+00, /* 0x00000000 */
+ 7.3242187500e-02, /* 0x3d960000 */
+ 1.1768206596e+01, /* 0x413c4a93 */
+ 5.5767340088e+02, /* 0x440b6b19 */
+ 8.8591972656e+03, /* 0x460a6cca */
+ 3.7014625000e+04, /* 0x471096a0 */
+};
+#ifdef __STDC__
+static const float qS8[6] = {
+#else
+static float qS8[6] = {
+#endif
+ 1.6377603149e+02, /* 0x4323c6aa */
+ 8.0983447266e+03, /* 0x45fd12c2 */
+ 1.4253829688e+05, /* 0x480b3293 */
+ 8.0330925000e+05, /* 0x49441ed4 */
+ 8.4050156250e+05, /* 0x494d3359 */
+ -3.4389928125e+05, /* 0xc8a7eb69 */
+};
+
+#ifdef __STDC__
+static const float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#else
+static float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#endif
+ 1.8408595828e-11, /* 0x2da1ec79 */
+ 7.3242180049e-02, /* 0x3d95ffff */
+ 5.8356351852e+00, /* 0x40babd86 */
+ 1.3511157227e+02, /* 0x43071c90 */
+ 1.0272437744e+03, /* 0x448067cd */
+ 1.9899779053e+03, /* 0x44f8bf4b */
+};
+#ifdef __STDC__
+static const float qS5[6] = {
+#else
+static float qS5[6] = {
+#endif
+ 8.2776611328e+01, /* 0x42a58da0 */
+ 2.0778142090e+03, /* 0x4501dd07 */
+ 1.8847289062e+04, /* 0x46933e94 */
+ 5.6751113281e+04, /* 0x475daf1d */
+ 3.5976753906e+04, /* 0x470c88c1 */
+ -5.3543427734e+03, /* 0xc5a752be */
+};
+
+#ifdef __STDC__
+static const float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#else
+static float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#endif
+ 4.3774099900e-09, /* 0x3196681b */
+ 7.3241114616e-02, /* 0x3d95ff70 */
+ 3.3442313671e+00, /* 0x405607e3 */
+ 4.2621845245e+01, /* 0x422a7cc5 */
+ 1.7080809021e+02, /* 0x432acedf */
+ 1.6673394775e+02, /* 0x4326bbe4 */
+};
+#ifdef __STDC__
+static const float qS3[6] = {
+#else
+static float qS3[6] = {
+#endif
+ 4.8758872986e+01, /* 0x42430916 */
+ 7.0968920898e+02, /* 0x44316c1c */
+ 3.7041481934e+03, /* 0x4567825f */
+ 6.4604252930e+03, /* 0x45c9e367 */
+ 2.5163337402e+03, /* 0x451d4557 */
+ -1.4924745178e+02, /* 0xc3153f59 */
+};
+
+#ifdef __STDC__
+static const float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#else
+static float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#endif
+ 1.5044444979e-07, /* 0x342189db */
+ 7.3223426938e-02, /* 0x3d95f62a */
+ 1.9981917143e+00, /* 0x3fffc4bf */
+ 1.4495602608e+01, /* 0x4167edfd */
+ 3.1666231155e+01, /* 0x41fd5471 */
+ 1.6252708435e+01, /* 0x4182058c */
+};
+#ifdef __STDC__
+static const float qS2[6] = {
+#else
+static float qS2[6] = {
+#endif
+ 3.0365585327e+01, /* 0x41f2ecb8 */
+ 2.6934811401e+02, /* 0x4386ac8f */
+ 8.4478375244e+02, /* 0x44533229 */
+ 8.8293585205e+02, /* 0x445cbbe5 */
+ 2.1266638184e+02, /* 0x4354aa98 */
+ -5.3109550476e+00, /* 0xc0a9f358 */
+};
+
+#ifdef __STDC__
+ static float qzerof(float x)
+#else
+ static float qzerof(x)
+ float x;
+#endif
+{
+#ifdef __STDC__
+ const float *p,*q;
+#else
+ float *p,*q;
+#endif
+ float s,r,z;
+ __int32_t ix;
+ GET_FLOAT_WORD(ix,x);
+ ix &= 0x7fffffff;
+ if(ix>=0x41000000) {p = qR8; q= qS8;}
+ else if(ix>=0x40f71c58){p = qR5; q= qS5;}
+ else if(ix>=0x4036db68){p = qR3; q= qS3;}
+ else if(ix>=0x40000000){p = qR2; q= qS2;}
+ z = one/(x*x);
+ r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+ s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
+ return (-(float).125 + r/s)/x;
+}
diff --git a/newlib/libm/mathfp/ef_j1.c b/newlib/libm/mathfp/ef_j1.c
new file mode 100644
index 000000000..04c12cff2
--- /dev/null
+++ b/newlib/libm/mathfp/ef_j1.c
@@ -0,0 +1,439 @@
+/* ef_j1.c -- float version of e_j1.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static float ponef(float), qonef(float);
+#else
+static float ponef(), qonef();
+#endif
+
+#ifdef __STDC__
+static const float
+#else
+static float
+#endif
+huge = 1e30,
+one = 1.0,
+invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */
+tpi = 6.3661974669e-01, /* 0x3f22f983 */
+ /* R0/S0 on [0,2] */
+r00 = -6.2500000000e-02, /* 0xbd800000 */
+r01 = 1.4070566976e-03, /* 0x3ab86cfd */
+r02 = -1.5995563444e-05, /* 0xb7862e36 */
+r03 = 4.9672799207e-08, /* 0x335557d2 */
+s01 = 1.9153760746e-02, /* 0x3c9ce859 */
+s02 = 1.8594678841e-04, /* 0x3942fab6 */
+s03 = 1.1771846857e-06, /* 0x359dffc2 */
+s04 = 5.0463624390e-09, /* 0x31ad6446 */
+s05 = 1.2354227016e-11; /* 0x2d59567e */
+
+#ifdef __STDC__
+static const float zero = 0.0;
+#else
+static float zero = 0.0;
+#endif
+
+#ifdef __STDC__
+ float j1f(float x)
+#else
+ float j1f(x)
+ float x;
+#endif
+{
+ float z, s,c,ss,cc,r,u,v,y;
+ __int32_t hx,ix;
+
+ GET_FLOAT_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7f800000) return one/x;
+ y = fabsf(x);
+ if(ix >= 0x40000000) { /* |x| >= 2.0 */
+ s = sinf(y);
+ c = cosf(y);
+ ss = -s-c;
+ cc = s-c;
+ if(ix<0x7f000000) { /* make sure y+y not overflow */
+ z = cosf(y+y);
+ if ((s*c)>zero) cc = z/ss;
+ else ss = z/cc;
+ }
+ /*
+ * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
+ * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
+ */
+ if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(y);
+ else {
+ u = ponef(y); v = qonef(y);
+ z = invsqrtpi*(u*cc-v*ss)/sqrtf(y);
+ }
+ if(hx<0) return -z;
+ else return z;
+ }
+ if(ix<0x32000000) { /* |x|<2**-27 */
+ if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */
+ }
+ z = x*x;
+ r = z*(r00+z*(r01+z*(r02+z*r03)));
+ s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
+ r *= x;
+ return(x*(float)0.5+r/s);
+}
+
+#ifdef __STDC__
+static const float U0[5] = {
+#else
+static float U0[5] = {
+#endif
+ -1.9605709612e-01, /* 0xbe48c331 */
+ 5.0443872809e-02, /* 0x3d4e9e3c */
+ -1.9125689287e-03, /* 0xbafaaf2a */
+ 2.3525259166e-05, /* 0x37c5581c */
+ -9.1909917899e-08, /* 0xb3c56003 */
+};
+#ifdef __STDC__
+static const float V0[5] = {
+#else
+static float V0[5] = {
+#endif
+ 1.9916731864e-02, /* 0x3ca3286a */
+ 2.0255257550e-04, /* 0x3954644b */
+ 1.3560879779e-06, /* 0x35b602d4 */
+ 6.2274145840e-09, /* 0x31d5f8eb */
+ 1.6655924903e-11, /* 0x2d9281cf */
+};
+
+#ifdef __STDC__
+ float y1f(float x)
+#else
+ float y1f(x)
+ float x;
+#endif
+{
+ float z, s,c,ss,cc,u,v;
+ __int32_t hx,ix;
+
+ GET_FLOAT_WORD(hx,x);
+ ix = 0x7fffffff&hx;
+ /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
+ if(ix>=0x7f800000) return one/(x+x*x);
+ if(ix==0) return -one/zero;
+ if(hx<0) return zero/zero;
+ if(ix >= 0x40000000) { /* |x| >= 2.0 */
+ s = sinf(x);
+ c = cosf(x);
+ ss = -s-c;
+ cc = s-c;
+ if(ix<0x7f000000) { /* make sure x+x not overflow */
+ z = cosf(x+x);
+ if ((s*c)>zero) cc = z/ss;
+ else ss = z/cc;
+ }
+ /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0))
+ * where x0 = x-3pi/4
+ * Better formula:
+ * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
+ * = 1/sqrt(2) * (sin(x) - cos(x))
+ * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+ * = -1/sqrt(2) * (cos(x) + sin(x))
+ * To avoid cancellation, use
+ * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * to compute the worse one.
+ */
+ if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x);
+ else {
+ u = ponef(x); v = qonef(x);
+ z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
+ }
+ return z;
+ }
+ if(ix<=0x24800000) { /* x < 2**-54 */
+ return(-tpi/x);
+ }
+ z = x*x;
+ u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
+ v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
+ return(x*(u/v) + tpi*(j1f(x)*logf(x)-one/x));
+}
+
+/* For x >= 8, the asymptotic expansions of pone is
+ * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x.
+ * We approximate pone by
+ * pone(x) = 1 + (R/S)
+ * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
+ * S = 1 + ps0*s^2 + ... + ps4*s^10
+ * and
+ * | pone(x)-1-R/S | <= 2 ** ( -60.06)
+ */
+
+#ifdef __STDC__
+static const float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#else
+static float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#endif
+ 0.0000000000e+00, /* 0x00000000 */
+ 1.1718750000e-01, /* 0x3df00000 */
+ 1.3239480972e+01, /* 0x4153d4ea */
+ 4.1205184937e+02, /* 0x43ce06a3 */
+ 3.8747453613e+03, /* 0x45722bed */
+ 7.9144794922e+03, /* 0x45f753d6 */
+};
+#ifdef __STDC__
+static const float ps8[5] = {
+#else
+static float ps8[5] = {
+#endif
+ 1.1420736694e+02, /* 0x42e46a2c */
+ 3.6509309082e+03, /* 0x45642ee5 */
+ 3.6956207031e+04, /* 0x47105c35 */
+ 9.7602796875e+04, /* 0x47bea166 */
+ 3.0804271484e+04, /* 0x46f0a88b */
+};
+
+#ifdef __STDC__
+static const float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#else
+static float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#endif
+ 1.3199052094e-11, /* 0x2d68333f */
+ 1.1718749255e-01, /* 0x3defffff */
+ 6.8027510643e+00, /* 0x40d9b023 */
+ 1.0830818176e+02, /* 0x42d89dca */
+ 5.1763616943e+02, /* 0x440168b7 */
+ 5.2871520996e+02, /* 0x44042dc6 */
+};
+#ifdef __STDC__
+static const float ps5[5] = {
+#else
+static float ps5[5] = {
+#endif
+ 5.9280597687e+01, /* 0x426d1f55 */
+ 9.9140142822e+02, /* 0x4477d9b1 */
+ 5.3532670898e+03, /* 0x45a74a23 */
+ 7.8446904297e+03, /* 0x45f52586 */
+ 1.5040468750e+03, /* 0x44bc0180 */
+};
+
+#ifdef __STDC__
+static const float pr3[6] = {
+#else
+static float pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#endif
+ 3.0250391081e-09, /* 0x314fe10d */
+ 1.1718686670e-01, /* 0x3defffab */
+ 3.9329774380e+00, /* 0x407bb5e7 */
+ 3.5119403839e+01, /* 0x420c7a45 */
+ 9.1055007935e+01, /* 0x42b61c2a */
+ 4.8559066772e+01, /* 0x42423c7c */
+};
+#ifdef __STDC__
+static const float ps3[5] = {
+#else
+static float ps3[5] = {
+#endif
+ 3.4791309357e+01, /* 0x420b2a4d */
+ 3.3676245117e+02, /* 0x43a86198 */
+ 1.0468714600e+03, /* 0x4482dbe3 */
+ 8.9081134033e+02, /* 0x445eb3ed */
+ 1.0378793335e+02, /* 0x42cf936c */
+};
+
+#ifdef __STDC__
+static const float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#else
+static float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#endif
+ 1.0771083225e-07, /* 0x33e74ea8 */
+ 1.1717621982e-01, /* 0x3deffa16 */
+ 2.3685150146e+00, /* 0x401795c0 */
+ 1.2242610931e+01, /* 0x4143e1bc */
+ 1.7693971634e+01, /* 0x418d8d41 */
+ 5.0735230446e+00, /* 0x40a25a4d */
+};
+#ifdef __STDC__
+static const float ps2[5] = {
+#else
+static float ps2[5] = {
+#endif
+ 2.1436485291e+01, /* 0x41ab7dec */
+ 1.2529022980e+02, /* 0x42fa9499 */
+ 2.3227647400e+02, /* 0x436846c7 */
+ 1.1767937469e+02, /* 0x42eb5bd7 */
+ 8.3646392822e+00, /* 0x4105d590 */
+};
+
+#ifdef __STDC__
+ static float ponef(float x)
+#else
+ static float ponef(x)
+ float x;
+#endif
+{
+#ifdef __STDC__
+ const float *p,*q;
+#else
+ float *p,*q;
+#endif
+ float z,r,s;
+ __int32_t ix;
+ GET_FLOAT_WORD(ix,x);
+ ix &= 0x7fffffff;
+ if(ix>=0x41000000) {p = pr8; q= ps8;}
+ else if(ix>=0x40f71c58){p = pr5; q= ps5;}
+ else if(ix>=0x4036db68){p = pr3; q= ps3;}
+ else if(ix>=0x40000000){p = pr2; q= ps2;}
+ z = one/(x*x);
+ r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+ s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
+ return one+ r/s;
+}
+
+
+/* For x >= 8, the asymptotic expansions of qone is
+ * 3/8 s - 105/1024 s^3 - ..., where s = 1/x.
+ * We approximate pone by
+ * qone(x) = s*(0.375 + (R/S))
+ * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
+ * S = 1 + qs1*s^2 + ... + qs6*s^12
+ * and
+ * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13)
+ */
+
+#ifdef __STDC__
+static const float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#else
+static float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
+#endif
+ 0.0000000000e+00, /* 0x00000000 */
+ -1.0253906250e-01, /* 0xbdd20000 */
+ -1.6271753311e+01, /* 0xc1822c8d */
+ -7.5960174561e+02, /* 0xc43de683 */
+ -1.1849806641e+04, /* 0xc639273a */
+ -4.8438511719e+04, /* 0xc73d3683 */
+};
+#ifdef __STDC__
+static const float qs8[6] = {
+#else
+static float qs8[6] = {
+#endif
+ 1.6139537048e+02, /* 0x43216537 */
+ 7.8253862305e+03, /* 0x45f48b17 */
+ 1.3387534375e+05, /* 0x4802bcd6 */
+ 7.1965775000e+05, /* 0x492fb29c */
+ 6.6660125000e+05, /* 0x4922be94 */
+ -2.9449025000e+05, /* 0xc88fcb48 */
+};
+
+#ifdef __STDC__
+static const float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#else
+static float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
+#endif
+ -2.0897993405e-11, /* 0xadb7d219 */
+ -1.0253904760e-01, /* 0xbdd1fffe */
+ -8.0564479828e+00, /* 0xc100e736 */
+ -1.8366960144e+02, /* 0xc337ab6b */
+ -1.3731937256e+03, /* 0xc4aba633 */
+ -2.6124443359e+03, /* 0xc523471c */
+};
+#ifdef __STDC__
+static const float qs5[6] = {
+#else
+static float qs5[6] = {
+#endif
+ 8.1276550293e+01, /* 0x42a28d98 */
+ 1.9917987061e+03, /* 0x44f8f98f */
+ 1.7468484375e+04, /* 0x468878f8 */
+ 4.9851425781e+04, /* 0x4742bb6d */
+ 2.7948074219e+04, /* 0x46da5826 */
+ -4.7191835938e+03, /* 0xc5937978 */
+};
+
+#ifdef __STDC__
+static const float qr3[6] = {
+#else
+static float qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
+#endif
+ -5.0783124372e-09, /* 0xb1ae7d4f */
+ -1.0253783315e-01, /* 0xbdd1ff5b */
+ -4.6101160049e+00, /* 0xc0938612 */
+ -5.7847221375e+01, /* 0xc267638e */
+ -2.2824453735e+02, /* 0xc3643e9a */
+ -2.1921012878e+02, /* 0xc35b35cb */
+};
+#ifdef __STDC__
+static const float qs3[6] = {
+#else
+static float qs3[6] = {
+#endif
+ 4.7665153503e+01, /* 0x423ea91e */
+ 6.7386511230e+02, /* 0x4428775e */
+ 3.3801528320e+03, /* 0x45534272 */
+ 5.5477290039e+03, /* 0x45ad5dd5 */
+ 1.9031191406e+03, /* 0x44ede3d0 */
+ -1.3520118713e+02, /* 0xc3073381 */
+};
+
+#ifdef __STDC__
+static const float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#else
+static float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
+#endif
+ -1.7838172539e-07, /* 0xb43f8932 */
+ -1.0251704603e-01, /* 0xbdd1f475 */
+ -2.7522056103e+00, /* 0xc0302423 */
+ -1.9663616180e+01, /* 0xc19d4f16 */
+ -4.2325313568e+01, /* 0xc2294d1f */
+ -2.1371921539e+01, /* 0xc1aaf9b2 */
+};
+#ifdef __STDC__
+static const float qs2[6] = {
+#else
+static float qs2[6] = {
+#endif
+ 2.9533363342e+01, /* 0x41ec4454 */
+ 2.5298155212e+02, /* 0x437cfb47 */
+ 7.5750280762e+02, /* 0x443d602e */
+ 7.3939318848e+02, /* 0x4438d92a */
+ 1.5594900513e+02, /* 0x431bf2f2 */
+ -4.9594988823e+00, /* 0xc09eb437 */
+};
+
+#ifdef __STDC__
+ static float qonef(float x)
+#else
+ static float qonef(x)
+ float x;
+#endif
+{
+#ifdef __STDC__
+ const float *p,*q;
+#else
+ float *p,*q;
+#endif
+ float s,r,z;
+ __int32_t ix;
+ GET_FLOAT_WORD(ix,x);
+ ix &= 0x7fffffff;
+ if(ix>=0x40200000) {p = qr8; q= qs8;}
+ else if(ix>=0x40f71c58){p = qr5; q= qs5;}
+ else if(ix>=0x4036db68){p = qr3; q= qs3;}
+ else if(ix>=0x40000000){p = qr2; q= qs2;}
+ z = one/(x*x);
+ r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
+ s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
+ return ((float).375 + r/s)/x;
+}
diff --git a/newlib/libm/mathfp/ef_remainder.c b/newlib/libm/mathfp/ef_remainder.c
new file mode 100644
index 000000000..92958efc4
--- /dev/null
+++ b/newlib/libm/mathfp/ef_remainder.c
@@ -0,0 +1,68 @@
+/* ef_remainder.c -- float version of e_remainder.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const float zero = 0.0;
+#else
+static float zero = 0.0;
+#endif
+
+
+#ifdef __STDC__
+ float remainderf(float x, float p)
+#else
+ float remainderf(x,p)
+ float x,p;
+#endif
+{
+ __int32_t hx,hp;
+ __uint32_t sx;
+ float p_half;
+
+ GET_FLOAT_WORD(hx,x);
+ GET_FLOAT_WORD(hp,p);
+ sx = hx&0x80000000;
+ hp &= 0x7fffffff;
+ hx &= 0x7fffffff;
+
+ /* purge off exception values */
+ if(hp==0) return (x*p)/(x*p); /* p = 0 */
+ if((hx>=0x7f800000)|| /* x not finite */
+ ((hp>0x7f800000))) /* p is NaN */
+ return (x*p)/(x*p);
+
+
+ if (hp<=0x7effffff) x = fmodf(x,p+p); /* now x < 2p */
+ if ((hx-hp)==0) return zero*x;
+ x = fabsf(x);
+ p = fabsf(p);
+ if (hp<0x01000000) {
+ if(x+x>p) {
+ x-=p;
+ if(x+x>=p) x -= p;
+ }
+ } else {
+ p_half = (float)0.5*p;
+ if(x>p_half) {
+ x-=p;
+ if(x>=p_half) x -= p;
+ }
+ }
+ GET_FLOAT_WORD(hx,x);
+ SET_FLOAT_WORD(x,hx^sx);
+ return x;
+}
diff --git a/newlib/libm/mathfp/ef_scalb.c b/newlib/libm/mathfp/ef_scalb.c
new file mode 100644
index 000000000..901f17707
--- /dev/null
+++ b/newlib/libm/mathfp/ef_scalb.c
@@ -0,0 +1,53 @@
+/* ef_scalb.c -- float version of e_scalb.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+#include <limits.h>
+
+#ifdef _SCALB_INT
+#ifdef __STDC__
+ float scalbf(float x, int fn)
+#else
+ float scalbf(x,fn)
+ float x; int fn;
+#endif
+#else
+#ifdef __STDC__
+ float scalbf(float x, float fn)
+#else
+ float scalbf(x,fn)
+ float x, fn;
+#endif
+#endif
+{
+#ifdef _SCALB_INT
+ return scalbnf(x,fn);
+#else
+ if (isnanf(x)||isnanf(fn)) return x*fn;
+ if (!finitef(fn)) {
+ if(fn>(float)0.0) return x*fn;
+ else return x/(-fn);
+ }
+ if (rintf(fn)!=fn) return (fn-fn)/(fn-fn);
+#if INT_MAX > 65000
+ if ( fn > (float)65000.0) return scalbnf(x, 65000);
+ if (-fn > (float)65000.0) return scalbnf(x,-65000);
+#else
+ if ( fn > (float)32000.0) return scalbnf(x, 32000);
+ if (-fn > (float)32000.0) return scalbnf(x,-32000);
+#endif
+ return scalbnf(x,(int)fn);
+#endif
+}
diff --git a/newlib/libm/mathfp/er_gamma.c b/newlib/libm/mathfp/er_gamma.c
new file mode 100644
index 000000000..6246c880b
--- /dev/null
+++ b/newlib/libm/mathfp/er_gamma.c
@@ -0,0 +1,32 @@
+
+/* @(#)er_gamma.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+/* gamma_r(x, signgamp)
+ * Reentrant version of the logarithm of the Gamma function
+ * with user provide pointer for the sign of Gamma(x).
+ *
+ * Method: See lgamma_r
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ double gamma_r(double x, int *signgamp)
+#else
+ double gamma_r(x,signgamp)
+ double x; int *signgamp;
+#endif
+{
+ return lgamma_r(x,signgamp);
+}
diff --git a/newlib/libm/mathfp/er_lgamma.c b/newlib/libm/mathfp/er_lgamma.c
new file mode 100644
index 000000000..9d8e370fa
--- /dev/null
+++ b/newlib/libm/mathfp/er_lgamma.c
@@ -0,0 +1,422 @@
+
+/* @(#)er_lgamma.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+/*
+FUNCTION
+ <<gamma>>, <<gammaf>>, <<lgamma>>, <<lgammaf>>, <<gamma_r>>,
+ <<gammaf_r>>, <<lgamma_r>>, <<lgammaf_r>>---logarithmic gamma
+ function
+INDEX
+gamma
+INDEX
+gammaf
+INDEX
+lgamma
+INDEX
+lgammaf
+INDEX
+gamma_r
+INDEX
+gammaf_r
+INDEX
+lgamma_r
+INDEX
+lgammaf_r
+
+ANSI_SYNOPSIS
+#include <math.h>
+double gamma(double <[x]>);
+float gammaf(float <[x]>);
+double lgamma(double <[x]>);
+float lgammaf(float <[x]>);
+double gamma_r(double <[x]>, int *<[signgamp]>);
+float gammaf_r(float <[x]>, int *<[signgamp]>);
+double lgamma_r(double <[x]>, int *<[signgamp]>);
+float lgammaf_r(float <[x]>, int *<[signgamp]>);
+
+TRAD_SYNOPSIS
+#include <math.h>
+double gamma(<[x]>)
+double <[x]>;
+float gammaf(<[x]>)
+float <[x]>;
+double lgamma(<[x]>)
+double <[x]>;
+float lgammaf(<[x]>)
+float <[x]>;
+double gamma_r(<[x]>, <[signgamp]>)
+double <[x]>;
+int <[signgamp]>;
+float gammaf_r(<[x]>, <[signgamp]>)
+float <[x]>;
+int <[signgamp]>;
+double lgamma_r(<[x]>, <[signgamp]>)
+double <[x]>;
+int <[signgamp]>;
+float lgammaf_r(<[x]>, <[signgamp]>)
+float <[x]>;
+int <[signgamp]>;
+
+DESCRIPTION
+<<gamma>> calculates
+@tex
+$\mit ln\bigl(\Gamma(x)\bigr)$,
+@end tex
+the natural logarithm of the gamma function of <[x]>. The gamma function
+(<<exp(gamma(<[x]>))>>) is a generalization of factorial, and retains
+the property that
+@ifinfo
+<<exp(gamma(N))>> is equivalent to <<N*exp(gamma(N-1))>>.
+@end ifinfo
+@tex
+$\mit \Gamma(N)\equiv N\times\Gamma(N-1)$.
+@end tex
+Accordingly, the results of the gamma function itself grow very
+quickly. <<gamma>> is defined as
+@tex
+$\mit ln\bigl(\Gamma(x)\bigr)$ rather than simply $\mit \Gamma(x)$
+@end tex
+@ifinfo
+the natural log of the gamma function, rather than the gamma function
+itself,
+@end ifinfo
+to extend the useful range of results representable.
+
+The sign of the result is returned in the global variable <<signgam>>,
+which is declared in math.h.
+
+<<gammaf>> performs the same calculation as <<gamma>>, but uses and
+returns <<float>> values.
+
+<<lgamma>> and <<lgammaf>> are alternate names for <<gamma>> and
+<<gammaf>>. The use of <<lgamma>> instead of <<gamma>> is a reminder
+that these functions compute the log of the gamma function, rather
+than the gamma function itself.
+
+The functions <<gamma_r>>, <<gammaf_r>>, <<lgamma_r>>, and
+<<lgammaf_r>> are just like <<gamma>>, <<gammaf>>, <<lgamma>>, and
+<<lgammaf>>, respectively, but take an additional argument. This
+additional argument is a pointer to an integer. This additional
+argument is used to return the sign of the result, and the global
+variable <<signgam>> is not used. These functions may be used for
+reentrant calls (but they will still set the global variable <<errno>>
+if an error occurs).
+
+RETURNS
+Normally, the computed result is returned.
+
+When <[x]> is a nonpositive integer, <<gamma>> returns <<HUGE_VAL>>
+and <<errno>> is set to <<EDOM>>. If the result overflows, <<gamma>>
+returns <<HUGE_VAL>> and <<errno>> is set to <<ERANGE>>.
+
+You can modify this error treatment using <<matherr>>.
+
+PORTABILITY
+Neither <<gamma>> nor <<gammaf>> is ANSI C. */
+
+/* lgamma_r(x, signgamp)
+ * Reentrant version of the logarithm of the Gamma function
+ * with user provide pointer for the sign of Gamma(x).
+ *
+ * Method:
+ * 1. Argument Reduction for 0 < x <= 8
+ * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
+ * reduce x to a number in [1.5,2.5] by
+ * lgamma(1+s) = log(s) + lgamma(s)
+ * for example,
+ * lgamma(7.3) = log(6.3) + lgamma(6.3)
+ * = log(6.3*5.3) + lgamma(5.3)
+ * = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)
+ * 2. Polynomial approximation of lgamma around its
+ * minimun ymin=1.461632144968362245 to maintain monotonicity.
+ * On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
+ * Let z = x-ymin;
+ * lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
+ * where
+ * poly(z) is a 14 degree polynomial.
+ * 2. Rational approximation in the primary interval [2,3]
+ * We use the following approximation:
+ * s = x-2.0;
+ * lgamma(x) = 0.5*s + s*P(s)/Q(s)
+ * with accuracy
+ * |P/Q - (lgamma(x)-0.5s)| < 2**-61.71
+ * Our algorithms are based on the following observation
+ *
+ * zeta(2)-1 2 zeta(3)-1 3
+ * lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ...
+ * 2 3
+ *
+ * where Euler = 0.5771... is the Euler constant, which is very
+ * close to 0.5.
+ *
+ * 3. For x>=8, we have
+ * lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
+ * (better formula:
+ * lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
+ * Let z = 1/x, then we approximation
+ * f(z) = lgamma(x) - (x-0.5)(log(x)-1)
+ * by
+ * 3 5 11
+ * w = w0 + w1*z + w2*z + w3*z + ... + w6*z
+ * where
+ * |w - f(z)| < 2**-58.74
+ *
+ * 4. For negative x, since (G is gamma function)
+ * -x*G(-x)*G(x) = pi/sin(pi*x),
+ * we have
+ * G(x) = pi/(sin(pi*x)*(-x)*G(-x))
+ * since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
+ * Hence, for x<0, signgam = sign(sin(pi*x)) and
+ * lgamma(x) = log(|Gamma(x)|)
+ * = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);
+ * Note: one should avoid compute pi*(-x) directly in the
+ * computation of sin(pi*(-x)).
+ *
+ * 5. Special Cases
+ * lgamma(2+s) ~ s*(1-Euler) for tiny s
+ * lgamma(1)=lgamma(2)=0
+ * lgamma(x) ~ -log(x) for tiny x
+ * lgamma(0) = lgamma(inf) = inf
+ * lgamma(-integer) = +-inf
+ *
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+two52= 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
+half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
+one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
+a0 = 7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */
+a1 = 3.22467033424113591611e-01, /* 0x3FD4A34C, 0xC4A60FAD */
+a2 = 6.73523010531292681824e-02, /* 0x3FB13E00, 0x1A5562A7 */
+a3 = 2.05808084325167332806e-02, /* 0x3F951322, 0xAC92547B */
+a4 = 7.38555086081402883957e-03, /* 0x3F7E404F, 0xB68FEFE8 */
+a5 = 2.89051383673415629091e-03, /* 0x3F67ADD8, 0xCCB7926B */
+a6 = 1.19270763183362067845e-03, /* 0x3F538A94, 0x116F3F5D */
+a7 = 5.10069792153511336608e-04, /* 0x3F40B6C6, 0x89B99C00 */
+a8 = 2.20862790713908385557e-04, /* 0x3F2CF2EC, 0xED10E54D */
+a9 = 1.08011567247583939954e-04, /* 0x3F1C5088, 0x987DFB07 */
+a10 = 2.52144565451257326939e-05, /* 0x3EFA7074, 0x428CFA52 */
+a11 = 4.48640949618915160150e-05, /* 0x3F07858E, 0x90A45837 */
+tc = 1.46163214496836224576e+00, /* 0x3FF762D8, 0x6356BE3F */
+tf = -1.21486290535849611461e-01, /* 0xBFBF19B9, 0xBCC38A42 */
+/* tt = -(tail of tf) */
+tt = -3.63867699703950536541e-18, /* 0xBC50C7CA, 0xA48A971F */
+t0 = 4.83836122723810047042e-01, /* 0x3FDEF72B, 0xC8EE38A2 */
+t1 = -1.47587722994593911752e-01, /* 0xBFC2E427, 0x8DC6C509 */
+t2 = 6.46249402391333854778e-02, /* 0x3FB08B42, 0x94D5419B */
+t3 = -3.27885410759859649565e-02, /* 0xBFA0C9A8, 0xDF35B713 */
+t4 = 1.79706750811820387126e-02, /* 0x3F9266E7, 0x970AF9EC */
+t5 = -1.03142241298341437450e-02, /* 0xBF851F9F, 0xBA91EC6A */
+t6 = 6.10053870246291332635e-03, /* 0x3F78FCE0, 0xE370E344 */
+t7 = -3.68452016781138256760e-03, /* 0xBF6E2EFF, 0xB3E914D7 */
+t8 = 2.25964780900612472250e-03, /* 0x3F6282D3, 0x2E15C915 */
+t9 = -1.40346469989232843813e-03, /* 0xBF56FE8E, 0xBF2D1AF1 */
+t10 = 8.81081882437654011382e-04, /* 0x3F4CDF0C, 0xEF61A8E9 */
+t11 = -5.38595305356740546715e-04, /* 0xBF41A610, 0x9C73E0EC */
+t12 = 3.15632070903625950361e-04, /* 0x3F34AF6D, 0x6C0EBBF7 */
+t13 = -3.12754168375120860518e-04, /* 0xBF347F24, 0xECC38C38 */
+t14 = 3.35529192635519073543e-04, /* 0x3F35FD3E, 0xE8C2D3F4 */
+u0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
+u1 = 6.32827064025093366517e-01, /* 0x3FE4401E, 0x8B005DFF */
+u2 = 1.45492250137234768737e+00, /* 0x3FF7475C, 0xD119BD6F */
+u3 = 9.77717527963372745603e-01, /* 0x3FEF4976, 0x44EA8450 */
+u4 = 2.28963728064692451092e-01, /* 0x3FCD4EAE, 0xF6010924 */
+u5 = 1.33810918536787660377e-02, /* 0x3F8B678B, 0xBF2BAB09 */
+v1 = 2.45597793713041134822e+00, /* 0x4003A5D7, 0xC2BD619C */
+v2 = 2.12848976379893395361e+00, /* 0x40010725, 0xA42B18F5 */
+v3 = 7.69285150456672783825e-01, /* 0x3FE89DFB, 0xE45050AF */
+v4 = 1.04222645593369134254e-01, /* 0x3FBAAE55, 0xD6537C88 */
+v5 = 3.21709242282423911810e-03, /* 0x3F6A5ABB, 0x57D0CF61 */
+s0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
+s1 = 2.14982415960608852501e-01, /* 0x3FCB848B, 0x36E20878 */
+s2 = 3.25778796408930981787e-01, /* 0x3FD4D98F, 0x4F139F59 */
+s3 = 1.46350472652464452805e-01, /* 0x3FC2BB9C, 0xBEE5F2F7 */
+s4 = 2.66422703033638609560e-02, /* 0x3F9B481C, 0x7E939961 */
+s5 = 1.84028451407337715652e-03, /* 0x3F5E26B6, 0x7368F239 */
+s6 = 3.19475326584100867617e-05, /* 0x3F00BFEC, 0xDD17E945 */
+r1 = 1.39200533467621045958e+00, /* 0x3FF645A7, 0x62C4AB74 */
+r2 = 7.21935547567138069525e-01, /* 0x3FE71A18, 0x93D3DCDC */
+r3 = 1.71933865632803078993e-01, /* 0x3FC601ED, 0xCCFBDF27 */
+r4 = 1.86459191715652901344e-02, /* 0x3F9317EA, 0x742ED475 */
+r5 = 7.77942496381893596434e-04, /* 0x3F497DDA, 0xCA41A95B */
+r6 = 7.32668430744625636189e-06, /* 0x3EDEBAF7, 0xA5B38140 */
+w0 = 4.18938533204672725052e-01, /* 0x3FDACFE3, 0x90C97D69 */
+w1 = 8.33333333333329678849e-02, /* 0x3FB55555, 0x5555553B */
+w2 = -2.77777777728775536470e-03, /* 0xBF66C16C, 0x16B02E5C */
+w3 = 7.93650558643019558500e-04, /* 0x3F4A019F, 0x98CF38B6 */
+w4 = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */
+w5 = 8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */
+w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */
+
+#ifdef __STDC__
+static const double zero= 0.00000000000000000000e+00;
+#else
+static double zero= 0.00000000000000000000e+00;
+#endif
+
+#ifdef __STDC__
+ static double sin_pi(double x)
+#else
+ static double sin_pi(x)
+ double x;
+#endif
+{
+ double y,z;
+ __int32_t n,ix;
+
+ GET_HIGH_WORD(ix,x);
+ ix &= 0x7fffffff;
+
+ if(ix<0x3fd00000) return __kernel_sin(pi*x,zero,0);
+ y = -x; /* x is assume negative */
+
+ /*
+ * argument reduction, make sure inexact flag not raised if input
+ * is an integer
+ */
+ z = floor(y);
+ if(z!=y) { /* inexact anyway */
+ y *= 0.5;
+ y = 2.0*(y - floor(y)); /* y = |x| mod 2.0 */
+ n = (__int32_t) (y*4.0);
+ } else {
+ if(ix>=0x43400000) {
+ y = zero; n = 0; /* y must be even */
+ } else {
+ if(ix<0x43300000) z = y+two52; /* exact */
+ GET_LOW_WORD(n,z);
+ n &= 1;
+ y = n;
+ n<<= 2;
+ }
+ }
+ switch (n) {
+ case 0: y = __kernel_sin(pi*y,zero,0); break;
+ case 1:
+ case 2: y = __kernel_cos(pi*(0.5-y),zero); break;
+ case 3:
+ case 4: y = __kernel_sin(pi*(one-y),zero,0); break;
+ case 5:
+ case 6: y = -__kernel_cos(pi*(y-1.5),zero); break;
+ default: y = __kernel_sin(pi*(y-2.0),zero,0); break;
+ }
+ return -y;
+}
+
+
+#ifdef __STDC__
+ double lgamma_r(double x, int *signgamp)
+#else
+ double lgamma_r(x,signgamp)
+ double x; int *signgamp;
+#endif
+{
+ double t,y,z,nadj,p,p1,p2,p3,q,r,w;
+ __int32_t i,hx,lx,ix;
+
+ EXTRACT_WORDS(hx,lx,x);
+
+ /* purge off +-inf, NaN, +-0, and negative arguments */
+ *signgamp = 1;
+ ix = hx&0x7fffffff;
+ if(ix>=0x7ff00000) return x*x;
+ if((ix|lx)==0) return one/zero;
+ if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */
+ if(hx<0) {
+ *signgamp = -1;
+ return -log(-x);
+ } else return -log(x);
+ }
+ if(hx<0) {
+ if(ix>=0x43300000) /* |x|>=2**52, must be -integer */
+ return one/zero;
+ t = sin_pi(x);
+ if(t==zero) return one/zero; /* -integer */
+ nadj = log(pi/fabs(t*x));
+ if(t<zero) *signgamp = -1;
+ x = -x;
+ }
+
+ /* purge off 1 and 2 */
+ if((((ix-0x3ff00000)|lx)==0)||(((ix-0x40000000)|lx)==0)) r = 0;
+ /* for x < 2.0 */
+ else if(ix<0x40000000) {
+ if(ix<=0x3feccccc) { /* lgamma(x) = lgamma(x+1)-log(x) */
+ r = -log(x);
+ if(ix>=0x3FE76944) {y = one-x; i= 0;}
+ else if(ix>=0x3FCDA661) {y= x-(tc-one); i=1;}
+ else {y = x; i=2;}
+ } else {
+ r = zero;
+ if(ix>=0x3FFBB4C3) {y=2.0-x;i=0;} /* [1.7316,2] */
+ else if(ix>=0x3FF3B4C4) {y=x-tc;i=1;} /* [1.23,1.73] */
+ else {y=x-one;i=2;}
+ }
+ switch(i) {
+ case 0:
+ z = y*y;
+ p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
+ p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
+ p = y*p1+p2;
+ r += (p-0.5*y); break;
+ case 1:
+ z = y*y;
+ w = z*y;
+ p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */
+ p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
+ p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
+ p = z*p1-(tt-w*(p2+y*p3));
+ r += (tf + p); break;
+ case 2:
+ p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
+ p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
+ r += (-0.5*y + p1/p2);
+ }
+ }
+ else if(ix<0x40200000) { /* x < 8.0 */
+ i = (__int32_t)x;
+ t = zero;
+ y = x-(double)i;
+ p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
+ q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
+ r = half*y+p/q;
+ z = one; /* lgamma(1+s) = log(s) + lgamma(s) */
+ switch(i) {
+ case 7: z *= (y+6.0); /* FALLTHRU */
+ case 6: z *= (y+5.0); /* FALLTHRU */
+ case 5: z *= (y+4.0); /* FALLTHRU */
+ case 4: z *= (y+3.0); /* FALLTHRU */
+ case 3: z *= (y+2.0); /* FALLTHRU */
+ r += log(z); break;
+ }
+ /* 8.0 <= x < 2**58 */
+ } else if (ix < 0x43900000) {
+ t = log(x);
+ z = one/x;
+ y = z*z;
+ w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
+ r = (x-half)*(t-one)+w;
+ } else
+ /* 2**58 <= x <= inf */
+ r = x*(log(x)-one);
+ if(hx<0) r = nadj - r;
+ return r;
+}
diff --git a/newlib/libm/mathfp/erf_gamma.c b/newlib/libm/mathfp/erf_gamma.c
new file mode 100644
index 000000000..96e8c46ab
--- /dev/null
+++ b/newlib/libm/mathfp/erf_gamma.c
@@ -0,0 +1,34 @@
+/* erf_gamma.c -- float version of er_gamma.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+/* gammaf_r(x, signgamp)
+ * Reentrant version of the logarithm of the Gamma function
+ * with user provide pointer for the sign of Gamma(x).
+ *
+ * Method: See lgammaf_r
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ float gammaf_r(float x, int *signgamp)
+#else
+ float gammaf_r(x,signgamp)
+ float x; int *signgamp;
+#endif
+{
+ return lgammaf_r(x,signgamp);
+}
diff --git a/newlib/libm/mathfp/erf_lgamma.c b/newlib/libm/mathfp/erf_lgamma.c
new file mode 100644
index 000000000..664812d81
--- /dev/null
+++ b/newlib/libm/mathfp/erf_lgamma.c
@@ -0,0 +1,244 @@
+/* erf_lgamma.c -- float version of er_lgamma.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const float
+#else
+static float
+#endif
+two23= 8.3886080000e+06, /* 0x4b000000 */
+half= 5.0000000000e-01, /* 0x3f000000 */
+one = 1.0000000000e+00, /* 0x3f800000 */
+pi = 3.1415927410e+00, /* 0x40490fdb */
+a0 = 7.7215664089e-02, /* 0x3d9e233f */
+a1 = 3.2246702909e-01, /* 0x3ea51a66 */
+a2 = 6.7352302372e-02, /* 0x3d89f001 */
+a3 = 2.0580807701e-02, /* 0x3ca89915 */
+a4 = 7.3855509982e-03, /* 0x3bf2027e */
+a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */
+a6 = 1.1927076848e-03, /* 0x3a9c54a1 */
+a7 = 5.1006977446e-04, /* 0x3a05b634 */
+a8 = 2.2086278477e-04, /* 0x39679767 */
+a9 = 1.0801156895e-04, /* 0x38e28445 */
+a10 = 2.5214456400e-05, /* 0x37d383a2 */
+a11 = 4.4864096708e-05, /* 0x383c2c75 */
+tc = 1.4616321325e+00, /* 0x3fbb16c3 */
+tf = -1.2148628384e-01, /* 0xbdf8cdcd */
+/* tt = -(tail of tf) */
+tt = 6.6971006518e-09, /* 0x31e61c52 */
+t0 = 4.8383611441e-01, /* 0x3ef7b95e */
+t1 = -1.4758771658e-01, /* 0xbe17213c */
+t2 = 6.4624942839e-02, /* 0x3d845a15 */
+t3 = -3.2788541168e-02, /* 0xbd064d47 */
+t4 = 1.7970675603e-02, /* 0x3c93373d */
+t5 = -1.0314224288e-02, /* 0xbc28fcfe */
+t6 = 6.1005386524e-03, /* 0x3bc7e707 */
+t7 = -3.6845202558e-03, /* 0xbb7177fe */
+t8 = 2.2596477065e-03, /* 0x3b141699 */
+t9 = -1.4034647029e-03, /* 0xbab7f476 */
+t10 = 8.8108185446e-04, /* 0x3a66f867 */
+t11 = -5.3859531181e-04, /* 0xba0d3085 */
+t12 = 3.1563205994e-04, /* 0x39a57b6b */
+t13 = -3.1275415677e-04, /* 0xb9a3f927 */
+t14 = 3.3552918467e-04, /* 0x39afe9f7 */
+u0 = -7.7215664089e-02, /* 0xbd9e233f */
+u1 = 6.3282704353e-01, /* 0x3f2200f4 */
+u2 = 1.4549225569e+00, /* 0x3fba3ae7 */
+u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */
+u4 = 2.2896373272e-01, /* 0x3e6a7578 */
+u5 = 1.3381091878e-02, /* 0x3c5b3c5e */
+v1 = 2.4559779167e+00, /* 0x401d2ebe */
+v2 = 2.1284897327e+00, /* 0x4008392d */
+v3 = 7.6928514242e-01, /* 0x3f44efdf */
+v4 = 1.0422264785e-01, /* 0x3dd572af */
+v5 = 3.2170924824e-03, /* 0x3b52d5db */
+s0 = -7.7215664089e-02, /* 0xbd9e233f */
+s1 = 2.1498242021e-01, /* 0x3e5c245a */
+s2 = 3.2577878237e-01, /* 0x3ea6cc7a */
+s3 = 1.4635047317e-01, /* 0x3e15dce6 */
+s4 = 2.6642270386e-02, /* 0x3cda40e4 */
+s5 = 1.8402845599e-03, /* 0x3af135b4 */
+s6 = 3.1947532989e-05, /* 0x3805ff67 */
+r1 = 1.3920053244e+00, /* 0x3fb22d3b */
+r2 = 7.2193557024e-01, /* 0x3f38d0c5 */
+r3 = 1.7193385959e-01, /* 0x3e300f6e */
+r4 = 1.8645919859e-02, /* 0x3c98bf54 */
+r5 = 7.7794247773e-04, /* 0x3a4beed6 */
+r6 = 7.3266842264e-06, /* 0x36f5d7bd */
+w0 = 4.1893854737e-01, /* 0x3ed67f1d */
+w1 = 8.3333335817e-02, /* 0x3daaaaab */
+w2 = -2.7777778450e-03, /* 0xbb360b61 */
+w3 = 7.9365057172e-04, /* 0x3a500cfd */
+w4 = -5.9518753551e-04, /* 0xba1c065c */
+w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */
+w6 = -1.6309292987e-03; /* 0xbad5c4e8 */
+
+#ifdef __STDC__
+static const float zero= 0.0000000000e+00;
+#else
+static float zero= 0.0000000000e+00;
+#endif
+
+#ifdef __STDC__
+ static float sin_pif(float x)
+#else
+ static float sin_pif(x)
+ float x;
+#endif
+{
+ float y,z;
+ __int32_t n,ix;
+
+ GET_FLOAT_WORD(ix,x);
+ ix &= 0x7fffffff;
+
+ if(ix<0x3e800000) return __kernel_sinf(pi*x,zero,0);
+ y = -x; /* x is assume negative */
+
+ /*
+ * argument reduction, make sure inexact flag not raised if input
+ * is an integer
+ */
+ z = floorf(y);
+ if(z!=y) { /* inexact anyway */
+ y *= (float)0.5;
+ y = (float)2.0*(y - floorf(y)); /* y = |x| mod 2.0 */
+ n = (__int32_t) (y*(float)4.0);
+ } else {
+ if(ix>=0x4b800000) {
+ y = zero; n = 0; /* y must be even */
+ } else {
+ if(ix<0x4b000000) z = y+two23; /* exact */
+ GET_FLOAT_WORD(n,z);
+ n &= 1;
+ y = n;
+ n<<= 2;
+ }
+ }
+ switch (n) {
+ case 0: y = __kernel_sinf(pi*y,zero,0); break;
+ case 1:
+ case 2: y = __kernel_cosf(pi*((float)0.5-y),zero); break;
+ case 3:
+ case 4: y = __kernel_sinf(pi*(one-y),zero,0); break;
+ case 5:
+ case 6: y = -__kernel_cosf(pi*(y-(float)1.5),zero); break;
+ default: y = __kernel_sinf(pi*(y-(float)2.0),zero,0); break;
+ }
+ return -y;
+}
+
+
+#ifdef __STDC__
+ float lgammaf_r(float x, int *signgamp)
+#else
+ float lgammaf_r(x,signgamp)
+ float x; int *signgamp;
+#endif
+{
+ float t,y,z,nadj,p,p1,p2,p3,q,r,w;
+ __int32_t i,hx,ix;
+
+ GET_FLOAT_WORD(hx,x);
+
+ /* purge off +-inf, NaN, +-0, and negative arguments */
+ *signgamp = 1;
+ ix = hx&0x7fffffff;
+ if(ix>=0x7f800000) return x*x;
+ if(ix==0) return one/zero;
+ if(ix<0x1c800000) { /* |x|<2**-70, return -log(|x|) */
+ if(hx<0) {
+ *signgamp = -1;
+ return -logf(-x);
+ } else return -logf(x);
+ }
+ if(hx<0) {
+ if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */
+ return one/zero;
+ t = sin_pif(x);
+ if(t==zero) return one/zero; /* -integer */
+ nadj = logf(pi/fabsf(t*x));
+ if(t<zero) *signgamp = -1;
+ x = -x;
+ }
+
+ /* purge off 1 and 2 */
+ if (ix==0x3f800000||ix==0x40000000) r = 0;
+ /* for x < 2.0 */
+ else if(ix<0x40000000) {
+ if(ix<=0x3f666666) { /* lgamma(x) = lgamma(x+1)-log(x) */
+ r = -logf(x);
+ if(ix>=0x3f3b4a20) {y = one-x; i= 0;}
+ else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;}
+ else {y = x; i=2;}
+ } else {
+ r = zero;
+ if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */
+ else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */
+ else {y=x-one;i=2;}
+ }
+ switch(i) {
+ case 0:
+ z = y*y;
+ p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
+ p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
+ p = y*p1+p2;
+ r += (p-(float)0.5*y); break;
+ case 1:
+ z = y*y;
+ w = z*y;
+ p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */
+ p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
+ p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
+ p = z*p1-(tt-w*(p2+y*p3));
+ r += (tf + p); break;
+ case 2:
+ p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
+ p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
+ r += (-(float)0.5*y + p1/p2);
+ }
+ }
+ else if(ix<0x41000000) { /* x < 8.0 */
+ i = (__int32_t)x;
+ t = zero;
+ y = x-(float)i;
+ p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
+ q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
+ r = half*y+p/q;
+ z = one; /* lgamma(1+s) = log(s) + lgamma(s) */
+ switch(i) {
+ case 7: z *= (y+(float)6.0); /* FALLTHRU */
+ case 6: z *= (y+(float)5.0); /* FALLTHRU */
+ case 5: z *= (y+(float)4.0); /* FALLTHRU */
+ case 4: z *= (y+(float)3.0); /* FALLTHRU */
+ case 3: z *= (y+(float)2.0); /* FALLTHRU */
+ r += logf(z); break;
+ }
+ /* 8.0 <= x < 2**58 */
+ } else if (ix < 0x5c800000) {
+ t = logf(x);
+ z = one/x;
+ y = z*z;
+ w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
+ r = (x-half)*(t-one)+w;
+ } else
+ /* 2**58 <= x <= inf */
+ r = x*(logf(x)-one);
+ if(hx<0) r = nadj - r;
+ return r;
+}
diff --git a/newlib/libm/mathfp/mathfp.tex b/newlib/libm/mathfp/mathfp.tex
new file mode 100644
index 000000000..e7f897a97
--- /dev/null
+++ b/newlib/libm/mathfp/mathfp.tex
@@ -0,0 +1,199 @@
+@node Math
+@chapter Mathematical Functions (@file{math.h})
+
+This chapter groups a wide variety of mathematical functions. The
+corresponding definitions and declarations are in @file{math.h}.
+Two definitions from @file{math.h} are of particular interest.
+
+@enumerate
+@item
+The representation of infinity as a @code{double} is defined as
+@code{HUGE_VAL}; this number is returned on overflow by many functions.
+
+@item
+The structure @code{exception} is used when you write customized error
+handlers for the mathematical functions. You can customize error
+handling for most of these functions by defining your own version of
+@code{matherr}; see the section on @code{matherr} for details.
+@end enumerate
+
+@cindex system calls
+@cindex support subroutines
+@cindex stubs
+@cindex OS stubs
+Since the error handling code calls @code{fputs}, the mathematical
+subroutines require stubs or minimal implementations for the same list
+of OS subroutines as @code{fputs}: @code{close}, @code{fstat},
+@code{isatty}, @code{lseek}, @code{read}, @code{sbrk}, @code{write}.
+@xref{syscalls,,System Calls, libc.info, The Cygnus C Support Library},
+for a discussion and for sample minimal implementations of these support
+subroutines.
+
+Alternative declarations of the mathematical functions, which exploit
+specific machine capabilities to operate faster---but generally have
+less error checking and may reflect additional limitations on some
+machines---are available when you include @file{fastmath.h} instead of
+@file{math.h}.
+
+@menu
+* version:: Version of library
+* acos:: Arccosine
+* acosh:: Inverse hyperbolic cosine
+* asin:: Arcsine
+* asinh:: Inverse hyperbolic sine
+* atan:: Arctangent
+* atan2:: Arctangent of y/x
+* atanh:: Inverse hyperbolic tangent
+* jN:: Bessel functions (jN, yN)
+* cbrt:: Cube root
+* copysign:: Sign of Y, magnitude of X
+* cosh:: Hyperbolic cosine
+* erf:: Error function (erf, erfc)
+* exp:: Exponential
+* expm1:: Exponential of x, - 1
+* fabs:: Absolute value (magnitude)
+* floor:: Floor and ceiling (floor, ceil)
+* fmod:: Floating-point remainder (modulo)
+* frexp:: Split floating-point number
+* gamma:: Logarithmic gamma function
+* hypot:: Distance from origin
+* ilogb:: Get exponent
+* infinity:: Floating infinity
+* isnan:: Check type of number
+* ldexp:: Load exponent
+* log:: Natural logarithms
+* log10:: Base 10 logarithms
+* log1p:: Log of 1 + X
+* matherr:: Modifiable math error handler
+* modf:: Split fractional and integer parts
+* nan:: Floating Not a Number
+* nextafter:: Get next representable number
+* pow:: X to the power Y
+* remainder:: remainder of X divided by Y
+* scalbn:: scalbn
+* sin:: Sine or cosine (sin, cos)
+* sinh:: Hyperbolic sine
+* sqrt:: Positive square root
+* tan:: Tangent
+* tanh:: Hyperbolic tangent
+@end menu
+
+@page
+@node version
+@section Version of library
+
+There are four different versions of the math library routines: IEEE,
+POSIX, X/Open, or SVID. The version may be selected at runtime by
+setting the global variable @code{_LIB_VERSION}, defined in
+@file{math.h}. It may be set to one of the following constants defined
+in @file{math.h}: @code{_IEEE_}, @code{_POSIX_}, @code{_XOPEN_}, or
+@code{_SVID_}. The @code{_LIB_VERSION} variable is not specific to any
+thread, and changing it will affect all threads.
+
+The versions of the library differ only in how errors are handled.
+
+In IEEE mode, the @code{matherr} function is never called, no warning
+messages are printed, and @code{errno} is never set.
+
+In POSIX mode, @code{errno} is set correctly, but the @code{matherr}
+function is never called and no warning messages are printed.
+
+In X/Open mode, @code{errno} is set correctly, and @code{matherr} is
+called, but warning message are not printed.
+
+In SVID mode, functions which overflow return 3.40282346638528860e+38,
+the maximum single precision floating point value, rather than infinity.
+Also, @code{errno} is set correctly, @code{matherr} is called, and, if
+@code{matherr} returns 0, warning messages are printed for some errors.
+For example, by default @samp{log(-1.0)} writes this message on standard
+error output:
+
+@example
+log: DOMAIN error
+@end example
+
+The library is set to X/Open mode by default.
+
+@page
+@include mathfp/sacos.def
+
+@page
+@include mathfp/eacosh.def
+
+@page
+@include mathfp/sasine.def
+
+@page
+@include mathfp/sasinh.def
+
+@page
+@include mathfp/satan.def
+
+@page
+@include mathfp/satan2.def
+
+@page
+@include mathfp/eatanh.def
+
+@page
+@include mathfp/wjn.def
+
+@page
+@include mathfp/scosh.def
+
+@page
+@include mathfp/serf.def
+
+@page
+@include mathfp/sexp.def
+
+@page
+@include mathfp/sfabs.def
+
+@page
+@include mathfp/sfloor.def
+
+@page
+@include mathfp/sfmod.def
+
+@page
+@include mathfp/sfrexp.def
+
+@page
+@include mathfp/erlgamma.def
+
+@page
+@include mathfp/ehypot.def
+
+@page
+@include mathfp/sisnan.def
+
+@page
+@include mathfp/sldexp.def
+
+@page
+@include mathfp/slogarithm.def
+
+@page
+@include mathfp/slog10.def
+
+@page
+@include mathfp/spow.def
+
+@page
+@include mathfp/eremainder.def
+
+@page
+@include mathfp/ssqrt.def
+
+@page
+@include mathfp/ssine.def
+
+@page
+@include mathfp/ssineh.def
+
+@page
+@include mathfp/stan.def
+
+@page
+@include mathfp/stanh.def
diff --git a/newlib/libm/mathfp/s_acos.c b/newlib/libm/mathfp/s_acos.c
new file mode 100644
index 000000000..e03344e7d
--- /dev/null
+++ b/newlib/libm/mathfp/s_acos.c
@@ -0,0 +1,93 @@
+
+/* @(#)z_acos.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+ <<acos>>, <<acosf>>---arc cosine
+
+INDEX
+ acos
+INDEX
+ acosf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double acos(double <[x]>);
+ float acosf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double acos(<[x]>)
+ double <[x]>;
+
+ float acosf(<[x]>)
+ float <[x]>;
+
+
+
+DESCRIPTION
+
+ <<acos>> computes the inverse cosine (arc cosine) of the input value.
+ Arguments to <<acos>> must be in the range @minus{}1 to 1.
+
+ <<acosf>> is identical to <<acos>>, except that it performs
+ its calculations on <<floats>>.
+
+RETURNS
+ @ifinfo
+ <<acos>> and <<acosf>> return values in radians, in the range of 0 to pi
+.
+ @end ifinfo
+ @tex
+ <<acos>> and <<acosf>> return values in radians, in the range of <<0>> t
+o $\pi$.
+ @end tex
+
+ If <[x]> is not between @minus{}1 and 1, the returned value is NaN
+ (not a number) the global variable <<errno>> is set to <<EDOM>>, and a
+ <<DOMAIN error>> message is sent as standard error output.
+
+ You can modify error handling for these functions using <<matherr>>.
+
+
+QUICKREF ANSI SVID POSIX RENTRANT
+ acos y,y,y,m
+ acosf n,n,n,m
+
+MATHREF
+ acos, [-1,1], acos(arg),,,
+ acos, NAN, arg,DOMAIN,EDOM
+
+MATHREF
+ acosf, [-1,1], acosf(arg),,,
+ acosf, NAN, argf,DOMAIN,EDOM
+
+*/
+
+/*****************************************************************
+ * Arccosine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * arccosine of x
+ *
+ * Description:
+ * This routine returns the arccosine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (acos, (double),
+ double x)
+{
+ return (asine (x, 1));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_asin.c b/newlib/libm/mathfp/s_asin.c
new file mode 100644
index 000000000..477bbf5cb
--- /dev/null
+++ b/newlib/libm/mathfp/s_asin.c
@@ -0,0 +1,29 @@
+
+/* @(#)z_asin.c 1.0 98/08/13 */
+/******************************************************************
+ * Arcsine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * arcsine of x
+ *
+ * Description:
+ * This routine returns the arcsine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (asin, (double),
+ double x)
+{
+ return (asine (x, 0));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_asine.c b/newlib/libm/mathfp/s_asine.c
new file mode 100644
index 000000000..efc0a8130
--- /dev/null
+++ b/newlib/libm/mathfp/s_asine.c
@@ -0,0 +1,186 @@
+
+/* @(#)z_asine.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+
+/*
+FUNCTION
+ <<asin>>, <<asinf>>, <<acos>>, <<acosf>>, <<asine>>, <<asinef>>---arc sine or cosine
+
+INDEX
+ asin
+INDEX
+ asinf
+INDEX
+ acos
+INDEX
+ acosf
+INDEX
+ asine
+INDEX
+ asinef
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double asine(double <[x]>);
+ float asinef(float <[x]>);
+ double asin(double <[x]>);
+ float asinf(float <[x]>);
+ double acos(double <[x]>);
+ float acosf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double asine(<[x]>);
+ double <[x]>;
+
+ float asinef(<[x]>);
+ float <[x]>;
+
+ double asin(<[x]>)
+ double <[x]>;
+
+ float asinf(<[x]>)
+ float <[x]>;
+
+ double acos(<[x]>)
+ double <[x]>;
+
+ float acosf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+
+<<asin>> computes the inverse sine or cosine of the argument <[x]>.
+Arguments to <<asin>> and <<acos>> must be in the range @minus{}1 to 1.
+
+<<asinf>> and <<acosf>> are identical to <<asin>> and <<acos>>, other
+than taking and returning floats.
+
+RETURNS
+@ifinfo
+<<asin>> and <<acos>> return values in radians, in the range of -pi/2 to pi/2.
+@end ifinfo
+@tex
+<<asin>> and <<acos>> return values in radians, in the range of $-\pi/2$ to $\pi/2$.
+@end tex
+
+If <[x]> is not in the range @minus{}1 to 1, <<asin>> and <<asinf>>
+return NaN (not a number), set the global variable <<errno>> to
+<<EDOM>>, and issue a <<DOMAIN error>> message.
+
+*/
+
+/******************************************************************
+ * Arcsine
+ *
+ * Input:
+ * x - floating point value
+ * acosine - indicates acos calculation
+ *
+ * Output:
+ * Arcsine of x.
+ *
+ * Description:
+ * This routine calculates arcsine / arccosine.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+static const double p[] = { -0.27368494524164255994e+2,
+ 0.57208227877891731407e+2,
+ -0.39688862997404877339e+2,
+ 0.10152522233806463645e+2,
+ -0.69674573447350646411 };
+static const double q[] = { -0.16421096714498560795e+3,
+ 0.41714430248260412556e+3,
+ -0.38186303361750149284e+3,
+ 0.15095270841030604719e+3,
+ -0.23823859153670238830e+2 };
+static const double a[] = { 0.0, 0.78539816339744830962 };
+static const double b[] = { 1.57079632679489661923, 0.78539816339744830962 };
+
+double
+_DEFUN (asine, (double, int),
+ double x _AND
+ int acosine)
+{
+ int flag, i;
+ int branch = 0;
+ double g, res, R, P, Q, y;
+
+ /* Check for special values. */
+ i = numtest (x);
+ if (i == NAN || i == INF)
+ {
+ errno = EDOM;
+ if (i == NAN)
+ return (x);
+ else
+ return (z_infinity.d);
+ }
+
+ y = fabs (x);
+ flag = acosine;
+
+ if (y > 0.5)
+ {
+ i = 1 - flag;
+
+ /* Check for range error. */
+ if (y > 1.0)
+ {
+ errno = ERANGE;
+ return (z_notanum.d);
+ }
+
+ g = (1 - y) / 2.0;
+ y = -2 * sqrt (g);
+ branch = 1;
+ }
+ else
+ {
+ i = flag;
+ if (y < z_rooteps)
+ res = y;
+ else
+ g = y * y;
+ }
+
+ if (y >= z_rooteps || branch == 1)
+ {
+ /* Calculate the Taylor series. */
+ P = ((((p[4] * g + p[3]) * g + p[2]) * g + p[1]) * g + p[0]) * g;
+ Q = ((((g + q[4]) * g + q[3]) * g + q[2]) * g + q[1]) * g + q[0];
+ R = P / Q;
+
+ res = y + y * R;
+ }
+
+ /* Calculate asine or acose. */
+ if (flag == 0)
+ {
+ res = (a[i] + res) + a[i];
+ if (x < 0.0)
+ res = -res;
+ }
+ else
+ {
+ if (x < 0.0)
+ res = (b[i] + res) + b[i];
+ else
+ res = (a[i] - res) + a[i];
+ }
+
+ return (res);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_asinh.c b/newlib/libm/mathfp/s_asinh.c
new file mode 100644
index 000000000..43b9d49fa
--- /dev/null
+++ b/newlib/libm/mathfp/s_asinh.c
@@ -0,0 +1,107 @@
+
+/* @(#)s_asinh.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+FUNCTION
+ <<asinh>>, <<asinhf>>---inverse hyperbolic sine
+
+INDEX
+ asinh
+INDEX
+ asinhf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double asinh(double <[x]>);
+ float asinhf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double asinh(<[x]>)
+ double <[x]>;
+
+ float asinhf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+<<asinh>> calculates the inverse hyperbolic sine of <[x]>.
+<<asinh>> is defined as
+@ifinfo
+. sgn(<[x]>) * log(abs(<[x]>) + sqrt(1+<[x]>*<[x]>))
+@end ifinfo
+@tex
+$$sign(x) \times ln\Bigl(|x| + \sqrt{1+x^2}\Bigr)$$
+@end tex
+
+<<asinhf>> is identical, other than taking and returning floats.
+
+RETURNS
+<<asinh>> and <<asinhf>> return the calculated value.
+
+PORTABILITY
+Neither <<asinh>> nor <<asinhf>> are ANSI C.
+
+*/
+
+/* asinh(x)
+ * Method :
+ * Based on
+ * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
+ * we have
+ * asinh(x) := x if 1+x*x=1,
+ * := sign(x)*(log(x)+ln2)) for large |x|, else
+ * := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else
+ * := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
+huge= 1.00000000000000000000e+300;
+
+#ifdef __STDC__
+ double asinh(double x)
+#else
+ double asinh(x)
+ double x;
+#endif
+{
+ double t,w;
+ __int32_t hx,ix;
+ GET_HIGH_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7ff00000) return x+x; /* x is inf or NaN */
+ if(ix< 0x3e300000) { /* |x|<2**-28 */
+ if(huge+x>one) return x; /* return x inexact except 0 */
+ }
+ if(ix>0x41b00000) { /* |x| > 2**28 */
+ w = log(fabs(x))+ln2;
+ } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */
+ t = fabs(x);
+ w = log(2.0*t+one/(sqrt(x*x+one)+t));
+ } else { /* 2.0 > |x| > 2**-28 */
+ t = x*x;
+ w =log1p(fabs(x)+t/(one+sqrt(one+t)));
+ }
+ if(hx>0) return w; else return -w;
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_atan.c b/newlib/libm/mathfp/s_atan.c
new file mode 100644
index 000000000..b8e633e3d
--- /dev/null
+++ b/newlib/libm/mathfp/s_atan.c
@@ -0,0 +1,83 @@
+
+/* @(#)z_atan.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+ <<atan>>, <<atanf>>---arc tangent
+
+INDEX
+ atan
+INDEX
+ atanf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double atan(double <[x]>);
+ float atanf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double atan(<[x]>);
+ double <[x]>;
+
+ float atanf(<[x]>);
+ float <[x]>;
+
+DESCRIPTION
+
+<<atan>> computes the inverse tangent (arc tangent) of the input value.
+
+<<atanf>> is identical to <<atan>>, save that it operates on <<floats>>.
+
+RETURNS
+@ifinfo
+<<atan>> returns a value in radians, in the range of -pi/2 to pi/2.
+@end ifinfo
+@tex
+<<atan>> returns a value in radians, in the range of $-\pi/2$ to $\pi/2$.
+@end tex
+
+PORTABILITY
+<<atan>> is ANSI C. <<atanf>> is an extension.
+
+*/
+
+/******************************************************************
+ * Arctangent
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * arctan of x
+ *
+ * Description:
+ * This routine returns the arctan of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (atan, (double),
+ double x)
+{
+ switch (numtest (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ /* this should check to see if neg NaN or pos NaN... */
+ return (__PI_OVER_TWO);
+ case 0:
+ return (0.0);
+ default:
+ return (atangent (x, 0, 0, 0));
+ }
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_atan2.c b/newlib/libm/mathfp/s_atan2.c
new file mode 100644
index 000000000..d73a6efc0
--- /dev/null
+++ b/newlib/libm/mathfp/s_atan2.c
@@ -0,0 +1,89 @@
+
+/* @(#)z_atan2.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+ <<atan2>>, <<atan2f>>---arc tangent of y/x
+
+INDEX
+ atan2
+INDEX
+ atan2f
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double atan2(double <[y]>,double <[x]>);
+ float atan2f(float <[y]>,float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double atan2(<[y]>,<[x]>);
+ double <[y]>;
+ double <[x]>;
+
+ float atan2f(<[y]>,<[x]>);
+ float <[y]>;
+ float <[x]>;
+
+DESCRIPTION
+
+<<atan2>> computes the inverse tangent (arc tangent) of <[y]>/<[x]>.
+<<atan2>> produces the correct result even for angles near
+@ifinfo
+pi/2 or -pi/2
+@end ifinfo
+@tex
+$\pi/2$ or $-\pi/2$
+@end tex
+(that is, when <[x]> is near 0).
+
+<<atan2f>> is identical to <<atan2>>, save that it takes and returns
+<<float>>.
+
+RETURNS
+<<atan2>> and <<atan2f>> return a value in radians, in the range of
+@ifinfo
+-pi to pi.
+@end ifinfo
+@tex
+$-\pi$ to $\pi$.
+@end tex
+
+If both <[x]> and <[y]> are 0.0, <<atan2>> causes a <<DOMAIN>> error.
+
+You can modify error handling for these functions using <<matherr>>.
+
+PORTABILITY
+<<atan2>> is ANSI C. <<atan2f>> is an extension.
+
+
+*/
+
+/******************************************************************
+ * Arctangent2
+ *
+ * Input:
+ * v, u - floating point values
+ *
+ * Output:
+ * arctan2 of v / u
+ *
+ * Description:
+ * This routine returns the arctan2 of v / u.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (atan2, (double, double),
+ double v _AND
+ double u)
+{
+ return (atangent (0.0, v, u, 1));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_atangent.c b/newlib/libm/mathfp/s_atangent.c
new file mode 100644
index 000000000..c6f3c9bd6
--- /dev/null
+++ b/newlib/libm/mathfp/s_atangent.c
@@ -0,0 +1,213 @@
+
+/* @(#)z_atangent.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+
+/*
+FUNCTION
+ <<atan>>, <<atanf>>, <<atan2>>, <<atan2f>>, <<atangent>>, <<atangentf>>---arc tangent
+
+INDEX
+ atan2
+INDEX
+ atan2f
+INDEX
+ atan
+INDEX
+ atanf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double atan(double <[x]>);
+ float atan(float <[x]>);
+ double atan2(double <[y]>,double <[x]>);
+ float atan2f(float <[y]>,float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double atan2(<[y]>,<[x]>);
+ double <[y]>;
+ double <[x]>;
+
+ float atan2f(<[y]>,<[x]>);
+ float <[y]>;
+ float <[x]>;
+
+ #include <math.h>
+ double atan(<[x]>);
+ double <[x]>;
+
+ float atanf(<[x]>);
+ float <[x]>;
+
+DESCRIPTION
+
+<<atan2>> computes the inverse tangent (arc tangent) of y / x.
+
+<<atan2f>> is identical to <<atan2>>, save that it operates on <<floats>>.
+
+<<atan>> computes the inverse tangent (arc tangent) of the input value.
+
+<<atanf>> is identical to <<atan>>, save that it operates on <<floats>>.
+
+RETURNS
+@ifinfo
+<<atan>> returns a value in radians, in the range of -pi/2 to pi/2.
+<<atan2>> returns a value in radians, in the range of -pi/2 to pi/2.
+@end ifinfo
+@tex
+<<atan>> returns a value in radians, in the range of $-\pi/2$ to $\pi/2$.
+<<atan2>> returns a value in radians, in the range of $-\pi/2$ to $\pi/2$.
+@end tex
+
+PORTABILITY
+<<atan>> is ANSI C. <<atanf>> is an extension.
+<<atan2>> is ANSI C. <<atan2f>> is an extension.
+
+*/
+
+/******************************************************************
+ * Arctangent
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * arctangent of x
+ *
+ * Description:
+ * This routine calculates arctangents.
+ *
+ *****************************************************************/
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+static const double ROOT3 = 1.73205080756887729353;
+static const double a[] = { 0.0, 0.52359877559829887308, 1.57079632679489661923,
+ 1.04719755119659774615 };
+static const double q[] = { 0.41066306682575781263e+2,
+ 0.86157349597130242515e+2,
+ 0.59578436142597344465e+2,
+ 0.15024001160028576121e+2 };
+static const double p[] = { -0.13688768894191926929e+2,
+ -0.20505855195861651981e+2,
+ -0.84946240351320683534e+1,
+ -0.83758299368150059274 };
+
+double
+_DEFUN (atangent, (double, double, double, int),
+ double x _AND
+ double v _AND
+ double u _AND
+ int arctan2)
+{
+ double f, g, R, P, Q, A, res;
+ int N;
+ int branch = 0;
+ int expv, expu;
+
+ /* Preparation for calculating arctan2. */
+ if (arctan2)
+ {
+ if (u == 0.0)
+ if (v == 0.0)
+ {
+ errno = ERANGE;
+ return (z_notanum.d);
+ }
+ else
+ {
+ branch = 1;
+ res = __PI_OVER_TWO;
+ }
+
+ if (!branch)
+ {
+ int e;
+ /* Get the exponent values of the inputs. */
+ g = frexp (v, &expv);
+ g = frexp (u, &expu);
+
+ /* See if a divide will overflow. */
+ e = expv - expu;
+ if (e > DBL_MAX_EXP)
+ {
+ branch = 1;
+ res = __PI_OVER_TWO;
+ }
+
+ /* Also check for underflow. */
+ else if (e < DBL_MIN_EXP)
+ {
+ branch = 2;
+ res = 0.0;
+ }
+ }
+ }
+
+ if (!branch)
+ {
+ if (arctan2)
+ f = fabs (v / u);
+ else
+ f = fabs (x);
+
+ if (f > 1.0)
+ {
+ f = 1.0 / f;
+ N = 2;
+ }
+ else
+ N = 0;
+
+ if (f > (2.0 - ROOT3))
+ {
+ A = ROOT3 - 1.0;
+ f = (((A * f - 0.5) - 0.5) + f) / (ROOT3 + f);
+ N++;
+ }
+
+ /* Check for values that are too small. */
+ if (-z_rooteps < f && f < z_rooteps)
+ res = f;
+
+ /* Calculate the Taylor series. */
+ else
+ {
+ g = f * f;
+ P = (((p[3] * g + p[2]) * g + p[1]) * g + p[0]) * g;
+ Q = (((g + q[3]) * g + q[2]) * g + q[1]) * g + q[0];
+ R = P / Q;
+
+ res = f + f * R;
+ }
+
+ if (N > 1)
+ res = -res;
+
+ res += a[N];
+ }
+
+ if (arctan2)
+ {
+ if (u < 0.0 || branch == 2)
+ res = __PI - res;
+ if (v < 0.0 || branch == 1)
+ res = -res;
+ }
+ else if (x < 0.0)
+ {
+ res = -res;
+ }
+
+ return (res);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_ceil.c b/newlib/libm/mathfp/s_ceil.c
new file mode 100644
index 000000000..c6ecbe323
--- /dev/null
+++ b/newlib/libm/mathfp/s_ceil.c
@@ -0,0 +1,38 @@
+
+/* @(#)z_ceil.c 1.0 98/08/13 */
+/*****************************************************************
+ * ceil
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * Smallest integer greater than x.
+ *
+ * Description:
+ * This routine returns the smallest integer greater than x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (ceil, (double),
+ double x)
+{
+ double f, y;
+
+ y = modf (x, &f);
+
+ if (y == 0.0)
+ return (x);
+ else if (x > -1.0 && x < 1.0)
+ return (x > 0 ? 1.0 : 0.0);
+ else
+ return (x > 0 ? f + 1.0 : f);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_cos.c b/newlib/libm/mathfp/s_cos.c
new file mode 100644
index 000000000..6f63a404e
--- /dev/null
+++ b/newlib/libm/mathfp/s_cos.c
@@ -0,0 +1,29 @@
+
+/* @(#)z_cos.c 1.0 98/08/13 */
+/******************************************************************
+ * Cosine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * cosine of x
+ *
+ * Description:
+ * This routine returns the cosine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (cos, (double),
+ double x)
+{
+ return (sine (x, 1));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_cosh.c b/newlib/libm/mathfp/s_cosh.c
new file mode 100644
index 000000000..6550e9ce7
--- /dev/null
+++ b/newlib/libm/mathfp/s_cosh.c
@@ -0,0 +1,80 @@
+
+/* @(#)z_cosh.c 1.0 98/08/13 */
+
+/*
+
+FUNCTION
+ <<cosh>>, <<coshf>>---hyperbolic cosine
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double cosh(double <[x]>);
+ float coshf(float <[x]>)
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double cosh(<[x]>)
+ double <[x]>;
+
+ float coshf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+
+ <<cosh>> computes the hyperbolic cosine of the argument <[x]>.
+ <<cosh(<[x]>)>> is defined as
+ @ifinfo
+ . (exp(x) + exp(-x))/2
+ @end ifinfo
+ @tex
+ $${(e^x + e^{-x})} \over 2$$
+ @end tex
+
+ Angles are specified in radians.
+
+ <<coshf>> is identical, save that it takes and returns <<float>>.
+
+RETURNS
+ The computed value is returned. When the correct value would create
+ an overflow, <<cosh>> returns the value <<HUGE_VAL>> with the
+ appropriate sign, and the global value <<errno>> is set to <<ERANGE>>.
+
+ You can modify error handling for these functions using the
+ function <<matherr>>.
+
+PORTABILITY
+ <<cosh>> is ANSI.
+ <<coshf>> is an extension.
+
+QUICKREF
+ cosh ansi pure
+ coshf - pure
+*/
+
+/******************************************************************
+ * Hyperbolic Cosine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * hyperbolic cosine of x
+ *
+ * Description:
+ * This routine returns the hyperbolic cosine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (cosh, (double),
+ double x)
+{
+ return (sineh (x, 1));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_erf.c b/newlib/libm/mathfp/s_erf.c
new file mode 100644
index 000000000..2d8faa3d8
--- /dev/null
+++ b/newlib/libm/mathfp/s_erf.c
@@ -0,0 +1,373 @@
+
+/* @(#)s_erf.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+FUNCTION
+ <<erf>>, <<erff>>, <<erfc>>, <<erfcf>>---error function
+INDEX
+ erf
+INDEX
+ erff
+INDEX
+ erfc
+INDEX
+ erfcf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double erf(double <[x]>);
+ float erff(float <[x]>);
+ double erfc(double <[x]>);
+ float erfcf(float <[x]>);
+TRAD_SYNOPSIS
+ #include <math.h>
+
+ double erf(<[x]>)
+ double <[x]>;
+
+ float erff(<[x]>)
+ float <[x]>;
+
+ double erfc(<[x]>)
+ double <[x]>;
+
+ float erfcf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+ <<erf>> calculates an approximation to the ``error function'',
+ which estimates the probability that an observation will fall within
+ <[x]> standard deviations of the mean (assuming a normal
+ distribution).
+ @tex
+ The error function is defined as
+ $${2\over\sqrt\pi}\times\int_0^x e^{-t^2}dt$$
+ @end tex
+
+ <<erfc>> calculates the complementary probability; that is,
+ <<erfc(<[x]>)>> is <<1 - erf(<[x]>)>>. <<erfc>> is computed directly,
+ so that you can use it to avoid the loss of precision that would
+ result from subtracting large probabilities (on large <[x]>) from 1.
+
+ <<erff>> and <<erfcf>> differ from <<erf>> and <<erfc>> only in the
+ argument and result types.
+
+RETURNS
+ For positive arguments, <<erf>> and all its variants return a
+ probability---a number between 0 and 1.
+
+PORTABILITY
+ None of the variants of <<erf>> are ANSI C.
+*/
+
+/* double erf(double x)
+ * double erfc(double x)
+ * x
+ * 2 |\
+ * erf(x) = --------- | exp(-t*t)dt
+ * sqrt(pi) \|
+ * 0
+ *
+ * erfc(x) = 1-erf(x)
+ * Note that
+ * erf(-x) = -erf(x)
+ * erfc(-x) = 2 - erfc(x)
+ *
+ * Method:
+ * 1. For |x| in [0, 0.84375]
+ * erf(x) = x + x*R(x^2)
+ * erfc(x) = 1 - erf(x) if x in [-.84375,0.25]
+ * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375]
+ * where R = P/Q where P is an odd poly of degree 8 and
+ * Q is an odd poly of degree 10.
+ * -57.90
+ * | R - (erf(x)-x)/x | <= 2
+ *
+ *
+ * Remark. The formula is derived by noting
+ * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
+ * and that
+ * 2/sqrt(pi) = 1.128379167095512573896158903121545171688
+ * is close to one. The interval is chosen because the fix
+ * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is
+ * near 0.6174), and by some experiment, 0.84375 is chosen to
+ * guarantee the error is less than one ulp for erf.
+ *
+ * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and
+ * c = 0.84506291151 rounded to single (24 bits)
+ * erf(x) = sign(x) * (c + P1(s)/Q1(s))
+ * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0
+ * 1+(c+P1(s)/Q1(s)) if x < 0
+ * |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06
+ * Remark: here we use the taylor series expansion at x=1.
+ * erf(1+s) = erf(1) + s*Poly(s)
+ * = 0.845.. + P1(s)/Q1(s)
+ * That is, we use rational approximation to approximate
+ * erf(1+s) - (c = (single)0.84506291151)
+ * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
+ * where
+ * P1(s) = degree 6 poly in s
+ * Q1(s) = degree 6 poly in s
+ *
+ * 3. For x in [1.25,1/0.35(~2.857143)],
+ * erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1)
+ * erf(x) = 1 - erfc(x)
+ * where
+ * R1(z) = degree 7 poly in z, (z=1/x^2)
+ * S1(z) = degree 8 poly in z
+ *
+ * 4. For x in [1/0.35,28]
+ * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0
+ * = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6<x<0
+ * = 2.0 - tiny (if x <= -6)
+ * erf(x) = sign(x)*(1.0 - erfc(x)) if x < 6, else
+ * erf(x) = sign(x)*(1.0 - tiny)
+ * where
+ * R2(z) = degree 6 poly in z, (z=1/x^2)
+ * S2(z) = degree 7 poly in z
+ *
+ * Note1:
+ * To compute exp(-x*x-0.5625+R/S), let s be a single
+ * precision number and s := x; then
+ * -x*x = -s*s + (s-x)*(s+x)
+ * exp(-x*x-0.5626+R/S) =
+ * exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S);
+ * Note2:
+ * Here 4 and 5 make use of the asymptotic series
+ * exp(-x*x)
+ * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) )
+ * x*sqrt(pi)
+ * We use rational approximation to approximate
+ * g(s)=f(1/x^2) = log(erfc(x)*x) - x*x + 0.5625
+ * Here is the error bound for R1/S1 and R2/S2
+ * |R1/S1 - f(x)| < 2**(-62.57)
+ * |R2/S2 - f(x)| < 2**(-61.52)
+ *
+ * 5. For inf > x >= 28
+ * erf(x) = sign(x) *(1 - tiny) (raise inexact)
+ * erfc(x) = tiny*tiny (raise underflow) if x > 0
+ * = 2 - tiny if x<0
+ *
+ * 7. Special case:
+ * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1,
+ * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
+ * erfc/erf(NaN) is NaN
+ */
+
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+tiny = 1e-300,
+half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
+one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
+ /* c = (float)0.84506291151 */
+erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */
+/*
+ * Coefficients for approximation to erf on [0,0.84375]
+ */
+efx = 1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */
+efx8= 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */
+pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */
+pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */
+pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */
+pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */
+pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */
+qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */
+qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */
+qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */
+qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */
+qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */
+/*
+ * Coefficients for approximation to erf in [0.84375,1.25]
+ */
+pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */
+pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */
+pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */
+pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */
+pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */
+pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */
+pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */
+qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */
+qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */
+qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */
+qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */
+qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */
+qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */
+/*
+ * Coefficients for approximation to erfc in [1.25,1/0.35]
+ */
+ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */
+ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */
+ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */
+ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */
+ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */
+ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */
+ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */
+ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */
+sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */
+sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */
+sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */
+sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */
+sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */
+sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */
+sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */
+sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */
+/*
+ * Coefficients for approximation to erfc in [1/.35,28]
+ */
+rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */
+rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */
+rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */
+rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */
+rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */
+rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */
+rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */
+sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */
+sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */
+sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */
+sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */
+sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */
+sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */
+sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */
+
+#ifdef __STDC__
+ double erf(double x)
+#else
+ double erf(x)
+ double x;
+#endif
+{
+ __int32_t hx,ix,i;
+ double R,S,P,Q,s,y,z,r;
+ GET_HIGH_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7ff00000) { /* erf(nan)=nan */
+ i = ((__uint32_t)hx>>31)<<1;
+ return (double)(1-i)+one/x; /* erf(+-inf)=+-1 */
+ }
+
+ if(ix < 0x3feb0000) { /* |x|<0.84375 */
+ if(ix < 0x3e300000) { /* |x|<2**-28 */
+ if (ix < 0x00800000)
+ return 0.125*(8.0*x+efx8*x); /*avoid underflow */
+ return x + efx*x;
+ }
+ z = x*x;
+ r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
+ s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+ y = r/s;
+ return x + x*y;
+ }
+ if(ix < 0x3ff40000) { /* 0.84375 <= |x| < 1.25 */
+ s = fabs(x)-one;
+ P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+ Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ if(hx>=0) return erx + P/Q; else return -erx - P/Q;
+ }
+ if (ix >= 0x40180000) { /* inf>|x|>=6 */
+ if(hx>=0) return one-tiny; else return tiny-one;
+ }
+ x = fabs(x);
+ s = one/(x*x);
+ if(ix< 0x4006DB6E) { /* |x| < 1/0.35 */
+ R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
+ ra5+s*(ra6+s*ra7))))));
+ S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
+ sa5+s*(sa6+s*(sa7+s*sa8)))))));
+ } else { /* |x| >= 1/0.35 */
+ R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
+ rb5+s*rb6)))));
+ S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
+ sb5+s*(sb6+s*sb7))))));
+ }
+ z = x;
+ SET_LOW_WORD(z,0);
+ r = exp(-z*z-0.5625)*exp((z-x)*(z+x)+R/S);
+ if(hx>=0) return one-r/x; else return r/x-one;
+}
+
+#ifdef __STDC__
+ double erfc(double x)
+#else
+ double erfc(x)
+ double x;
+#endif
+{
+ __int32_t hx,ix;
+ double R,S,P,Q,s,y,z,r;
+ GET_HIGH_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7ff00000) { /* erfc(nan)=nan */
+ /* erfc(+-inf)=0,2 */
+ return (double)(((__uint32_t)hx>>31)<<1)+one/x;
+ }
+
+ if(ix < 0x3feb0000) { /* |x|<0.84375 */
+ if(ix < 0x3c700000) /* |x|<2**-56 */
+ return one-x;
+ z = x*x;
+ r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
+ s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+ y = r/s;
+ if(hx < 0x3fd00000) { /* x<1/4 */
+ return one-(x+x*y);
+ } else {
+ r = x*y;
+ r += (x-half);
+ return half - r ;
+ }
+ }
+ if(ix < 0x3ff40000) { /* 0.84375 <= |x| < 1.25 */
+ s = fabs(x)-one;
+ P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+ Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ if(hx>=0) {
+ z = one-erx; return z - P/Q;
+ } else {
+ z = erx+P/Q; return one+z;
+ }
+ }
+ if (ix < 0x403c0000) { /* |x|<28 */
+ x = fabs(x);
+ s = one/(x*x);
+ if(ix< 0x4006DB6D) { /* |x| < 1/.35 ~ 2.857143*/
+ R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
+ ra5+s*(ra6+s*ra7))))));
+ S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
+ sa5+s*(sa6+s*(sa7+s*sa8)))))));
+ } else { /* |x| >= 1/.35 ~ 2.857143 */
+ if(hx<0&&ix>=0x40180000) return two-tiny;/* x < -6 */
+ R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
+ rb5+s*rb6)))));
+ S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
+ sb5+s*(sb6+s*sb7))))));
+ }
+ z = x;
+ SET_LOW_WORD(z,0);
+ r = exp(-z*z-0.5625)*
+ exp((z-x)*(z+x)+R/S);
+ if(hx>0) return r/x; else return two-r/x;
+ } else {
+ if(hx>0) return tiny*tiny; else return two-tiny;
+ }
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_exp.c b/newlib/libm/mathfp/s_exp.c
new file mode 100644
index 000000000..8c7f723fe
--- /dev/null
+++ b/newlib/libm/mathfp/s_exp.c
@@ -0,0 +1,133 @@
+
+/* @(#)z_exp.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+
+/*
+FUNCTION
+ <<exp>>, <<expf>>---exponential
+INDEX
+ exp
+INDEX
+ expf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double exp(double <[x]>);
+ float expf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double exp(<[x]>);
+ double <[x]>;
+
+ float expf(<[x]>);
+ float <[x]>;
+
+DESCRIPTION
+ <<exp>> and <<expf>> calculate the exponential of <[x]>, that is,
+ @ifinfo
+ e raised to the power <[x]> (where e
+ @end ifinfo
+ @tex
+ $e^x$ (where $e$
+ @end tex
+ is the base of the natural system of logarithms, approximately 2.71828).
+
+RETURNS
+ On success, <<exp>> and <<expf>> return the calculated value.
+ If the result underflows, the returned value is <<0>>. If the
+ result overflows, the returned value is <<HUGE_VAL>>. In
+ either case, <<errno>> is set to <<ERANGE>>.
+
+PORTABILITY
+ <<exp>> is ANSI C. <<expf>> is an extension.
+
+*/
+
+/*****************************************************************
+ * Exponential Function
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * e raised to x.
+ *
+ * Description:
+ * This routine returns e raised to the xth power.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+static const double INV_LN2 = 1.4426950408889634074;
+static const double LN2 = 0.6931471805599453094172321;
+static const double p[] = { 0.25, 0.75753180159422776666e-2,
+ 0.31555192765684646356e-4 };
+static const double q[] = { 0.5, 0.56817302698551221787e-1,
+ 0.63121894374398504557e-3,
+ 0.75104028399870046114e-6 };
+
+double
+_DEFUN (exp, (double),
+ double x)
+{
+ int N;
+ double g, z, R, P, Q;
+
+ switch (numtest (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = ERANGE;
+ if (ispos (x))
+ return (z_infinity.d);
+ else
+ return (0.0);
+ case 0:
+ return (1.0);
+ }
+
+ /* Check for out of bounds. */
+ if (x > BIGX || x < SMALLX)
+ {
+ errno = ERANGE;
+ return (x);
+ }
+
+ /* Check for a value too small to calculate. */
+ if (-z_rooteps < x && x < z_rooteps)
+ {
+ return (1.0);
+ }
+
+ /* Calculate the exponent. */
+ if (x < 0.0)
+ N = (int) (x * INV_LN2 - 0.5);
+ else
+ N = (int) (x * INV_LN2 + 0.5);
+
+ /* Construct the mantissa. */
+ g = x - N * LN2;
+ z = g * g;
+ P = g * ((p[2] * z + p[1]) * z + p[0]);
+ Q = ((q[3] * z + q[2]) * z + q[1]) * z + q[0];
+ R = 0.5 + P / (Q - P);
+
+ /* Return the floating point value. */
+ N++;
+ return (ldexp (R, N));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_fabs.c b/newlib/libm/mathfp/s_fabs.c
new file mode 100644
index 000000000..9e1d75eb3
--- /dev/null
+++ b/newlib/libm/mathfp/s_fabs.c
@@ -0,0 +1,80 @@
+
+/* @(#)z_fabs.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+ <<fabs>>, <<fabsf>>---absolute value (magnitude)
+INDEX
+ fabs
+INDEX
+ fabsf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double fabs(double <[x]>);
+ float fabsf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double fabs(<[x]>)
+ double <[x]>;
+
+ float fabsf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+<<fabs>> and <<fabsf>> calculate
+@tex
+$|x|$,
+@end tex
+the absolute value (magnitude) of the argument <[x]>, by direct
+manipulation of the bit representation of <[x]>.
+
+RETURNS
+The calculated value is returned.
+
+PORTABILITY
+<<fabs>> is ANSI.
+<<fabsf>> is an extension.
+
+*/
+
+/******************************************************************
+ * Floating-Point Absolute Value
+ *
+ * Input:
+ * x - floating-point number
+ *
+ * Output:
+ * absolute value of x
+ *
+ * Description:
+ * fabs computes the absolute value of a floating point number.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (fabs, (double),
+ double x)
+{
+ switch (numtest (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = ERANGE;
+ return (x);
+ case 0:
+ return (0.0);
+ default:
+ return (x < 0.0 ? -x : x);
+ }
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_floor.c b/newlib/libm/mathfp/s_floor.c
new file mode 100644
index 000000000..0dbc207f3
--- /dev/null
+++ b/newlib/libm/mathfp/s_floor.c
@@ -0,0 +1,92 @@
+
+/* @(#)z_floor.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+<<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling
+INDEX
+ floor
+INDEX
+ floorf
+INDEX
+ ceil
+INDEX
+ ceilf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double floor(double <[x]>);
+ float floorf(float <[x]>);
+ double ceil(double <[x]>);
+ float ceilf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double floor(<[x]>)
+ double <[x]>;
+ float floorf(<[x]>)
+ float <[x]>;
+ double ceil(<[x]>)
+ double <[x]>;
+ float ceilf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+<<floor>> and <<floorf>> find
+@tex
+$\lfloor x \rfloor$,
+@end tex
+the nearest integer less than or equal to <[x]>.
+<<ceil>> and <<ceilf>> find
+@tex
+$\lceil x\rceil$,
+@end tex
+the nearest integer greater than or equal to <[x]>.
+
+RETURNS
+<<floor>> and <<ceil>> return the integer result as a double.
+<<floorf>> and <<ceilf>> return the integer result as a float.
+
+PORTABILITY
+<<floor>> and <<ceil>> are ANSI.
+<<floorf>> and <<ceilf>> are extensions.
+
+*/
+
+/*****************************************************************
+ * floor
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * Smallest integer less than x.
+ *
+ * Description:
+ * This routine returns the smallest integer less than x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (floor, (double),
+ double x)
+{
+ double f, y;
+
+ if (x > -1.0 && x < 1.0)
+ return (x >= 0 ? 0 : -1.0);
+
+ y = modf (x, &f);
+
+ if (y == 0.0)
+ return (x);
+
+ return (x >= 0 ? f : f - 1.0);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_fmod.c b/newlib/libm/mathfp/s_fmod.c
new file mode 100644
index 000000000..3af7300da
--- /dev/null
+++ b/newlib/libm/mathfp/s_fmod.c
@@ -0,0 +1,187 @@
+
+/* @(#)z_fmod.c 1.0 98/08/13 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+FUNCTION
+<<fmod>>, <<fmodf>>---floating-point remainder (modulo)
+
+INDEX
+fmod
+INDEX
+fmodf
+
+ANSI_SYNOPSIS
+#include <math.h>
+double fmod(double <[x]>, double <[y]>)
+float fmodf(float <[x]>, float <[y]>)
+
+TRAD_SYNOPSIS
+#include <math.h>
+double fmod(<[x]>, <[y]>)
+double (<[x]>, <[y]>);
+
+float fmodf(<[x]>, <[y]>)
+float (<[x]>, <[y]>);
+
+DESCRIPTION
+The <<fmod>> and <<fmodf>> functions compute the floating-point
+remainder of <[x]>/<[y]> (<[x]> modulo <[y]>).
+
+RETURNS
+The <<fmod>> function returns the value
+@ifinfo
+<[x]>-<[i]>*<[y]>,
+@end ifinfo
+@tex
+$x-i\times y$,
+@end tex
+for the largest integer <[i]> such that, if <[y]> is nonzero, the
+result has the same sign as <[x]> and magnitude less than the
+magnitude of <[y]>.
+
+<<fmod(<[x]>,0)>> returns NaN, and sets <<errno>> to <<EDOM>>.
+
+You can modify error treatment for these functions using <<matherr>>.
+
+PORTABILITY
+<<fmod>> is ANSI C. <<fmodf>> is an extension.
+*/
+
+/*
+ * fmod(x,y)
+ * Return x mod y in exact arithmetic
+ * Method: shift and subtract
+ */
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+static const double one = 1.0, Zero[] = {0.0, -0.0,};
+#else
+static double one = 1.0, Zero[] = {0.0, -0.0,};
+#endif
+
+#ifdef __STDC__
+ double fmod(double x, double y)
+#else
+ double fmod(x,y)
+ double x,y ;
+#endif
+{
+ __int32_t n,hx,hy,hz,ix,iy,sx,i;
+ __uint32_t lx,ly,lz;
+
+ EXTRACT_WORDS(hx,lx,x);
+ EXTRACT_WORDS(hy,ly,y);
+ sx = hx&0x80000000; /* sign of x */
+ hx ^=sx; /* |x| */
+ hy &= 0x7fffffff; /* |y| */
+
+ /* purge off exception values */
+ if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */
+ ((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */
+ return (x*y)/(x*y);
+ if(hx<=hy) {
+ if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */
+ if(lx==ly)
+ return Zero[(__uint32_t)sx>>31]; /* |x|=|y| return x*0*/
+ }
+
+ /* determine ix = ilogb(x) */
+ if(hx<0x00100000) { /* subnormal x */
+ if(hx==0) {
+ for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
+ } else {
+ for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;
+ }
+ } else ix = (hx>>20)-1023;
+
+ /* determine iy = ilogb(y) */
+ if(hy<0x00100000) { /* subnormal y */
+ if(hy==0) {
+ for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
+ } else {
+ for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;
+ }
+ } else iy = (hy>>20)-1023;
+
+ /* set up {hx,lx}, {hy,ly} and align y to x */
+ if(ix >= -1022)
+ hx = 0x00100000|(0x000fffff&hx);
+ else { /* subnormal x, shift x to normal */
+ n = -1022-ix;
+ if(n<=31) {
+ hx = (hx<<n)|(lx>>(32-n));
+ lx <<= n;
+ } else {
+ hx = lx<<(n-32);
+ lx = 0;
+ }
+ }
+ if(iy >= -1022)
+ hy = 0x00100000|(0x000fffff&hy);
+ else { /* subnormal y, shift y to normal */
+ n = -1022-iy;
+ if(n<=31) {
+ hy = (hy<<n)|(ly>>(32-n));
+ ly <<= n;
+ } else {
+ hy = ly<<(n-32);
+ ly = 0;
+ }
+ }
+
+ /* fix point fmod */
+ n = ix - iy;
+ while(n--) {
+ hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+ if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
+ else {
+ if((hz|lz)==0) /* return sign(x)*0 */
+ return Zero[(__uint32_t)sx>>31];
+ hx = hz+hz+(lz>>31); lx = lz+lz;
+ }
+ }
+ hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
+ if(hz>=0) {hx=hz;lx=lz;}
+
+ /* convert back to floating value and restore the sign */
+ if((hx|lx)==0) /* return sign(x)*0 */
+ return Zero[(__uint32_t)sx>>31];
+ while(hx<0x00100000) { /* normalize x */
+ hx = hx+hx+(lx>>31); lx = lx+lx;
+ iy -= 1;
+ }
+ if(iy>= -1022) { /* normalize output */
+ hx = ((hx-0x00100000)|((iy+1023)<<20));
+ INSERT_WORDS(x,hx|sx,lx);
+ } else { /* subnormal output */
+ n = -1022 - iy;
+ if(n<=20) {
+ lx = (lx>>n)|((__uint32_t)hx<<(32-n));
+ hx >>= n;
+ } else if (n<=31) {
+ lx = (hx<<(32-n))|(lx>>n); hx = sx;
+ } else {
+ lx = hx>>(n-32); hx = sx;
+ }
+ INSERT_WORDS(x,hx|sx,lx);
+ x *= one; /* create necessary signal */
+ }
+ return x; /* exact output */
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/s_frexp.c b/newlib/libm/mathfp/s_frexp.c
new file mode 100644
index 000000000..6145c472f
--- /dev/null
+++ b/newlib/libm/mathfp/s_frexp.c
@@ -0,0 +1,110 @@
+
+/* @(#)z_frexp.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+ <<frexp>>, <<frexpf>>---split floating-point number
+INDEX
+ frexp
+INDEX
+ frexpf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double frexp(double <[val]>, int *<[exp]>);
+ float frexpf(float <[val]>, int *<[exp]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double frexp(<[val]>, <[exp]>)
+ double <[val]>;
+ int *<[exp]>;
+
+ float frexpf(<[val]>, <[exp]>)
+ float <[val]>;
+ int *<[exp]>;
+
+
+DESCRIPTION
+ All non zero, normal numbers can be described as <[m]> * 2**<[p]>.
+ <<frexp>> represents the double <[val]> as a mantissa <[m]>
+ and a power of two <[p]>. The resulting mantissa will always
+ be greater than or equal to <<0.5>>, and less than <<1.0>> (as
+ long as <[val]> is nonzero). The power of two will be stored
+ in <<*>><[exp]>.
+
+@ifinfo
+<[m]> and <[p]> are calculated so that
+<[val]> is <[m]> times <<2>> to the power <[p]>.
+@end ifinfo
+@tex
+<[m]> and <[p]> are calculated so that
+$ val = m \times 2^p $.
+@end tex
+
+<<frexpf>> is identical, other than taking and returning
+floats rather than doubles.
+
+RETURNS
+<<frexp>> returns the mantissa <[m]>. If <[val]> is <<0>>, infinity,
+or Nan, <<frexp>> will set <<*>><[exp]> to <<0>> and return <[val]>.
+
+PORTABILITY
+<<frexp>> is ANSI.
+<<frexpf>> is an extension.
+
+
+*/
+
+/*****************************************************************
+ * frexp
+ *
+ * Input:
+ * d - floating point value
+ * exp - exponent value
+ *
+ * Output:
+ * A floating point value in the range [0.5, 1).
+ *
+ * Description:
+ * This routine breaks a floating point value into a number f and
+ * an exponent exp such that d = f * 2 ^ exp.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double frexp (double d, int *exp)
+{
+ double f;
+ __uint32_t hd, ld, hf, lf;
+
+ EXTRACT_WORDS (hd, ld, d);
+
+ /* Get the exponent. */
+ *exp = ((hd & 0x7ff00000) >> 20) - 1022;
+
+ /* Get the mantissa. */
+ lf = ld;
+ hf = hd & 0x800fffff;
+ hf |= 0x3fe00000;
+
+ INSERT_WORDS (f, hf, lf);
+
+ /* Check for special values. */
+ switch (numtest (f))
+ {
+ case NAN:
+ case INF:
+ errno = EDOM;
+ *exp = 0;
+ return (f);
+ }
+
+ return (f);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_infconst.c b/newlib/libm/mathfp/s_infconst.c
new file mode 100644
index 000000000..85b3b689c
--- /dev/null
+++ b/newlib/libm/mathfp/s_infconst.c
@@ -0,0 +1,15 @@
+/* Infinity as a constant value. This is used for HUGE_VAL.
+ * Added by Cygnus Support.
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+#ifdef __IEEE_BIG_ENDIAN
+const union __dmath __infinity = { 0x7ff00000, 0 };
+#else
+const union __dmath __infinity = { 0, 0x7ff00000 };
+#endif
+#else /* defined (_DOUBLE_IS_32BITS) */
+const union __dmath __infinity = { 0x7f800000, 0 };
+#endif /* defined (_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/s_isinf.c b/newlib/libm/mathfp/s_isinf.c
new file mode 100644
index 000000000..fe9f54799
--- /dev/null
+++ b/newlib/libm/mathfp/s_isinf.c
@@ -0,0 +1,37 @@
+
+/* @(#)z_isinf.c 1.0 98/08/13 */
+/******************************************************************
+ * isinf
+ *
+ * Input:
+ * x - pointer to a floating point value
+ *
+ * Output:
+ * An integer that indicates if the number is infinite.
+ *
+ * Description:
+ * This routine returns an integer that indicates if the number
+ * passed in is infinite (1) or is finite (0).
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+int isinf (double x)
+{
+ __uint32_t lx, hx;
+ int exp;
+
+ EXTRACT_WORDS (hx, lx, x);
+ exp = (hx & 0x7ff00000) >> 20;
+
+ if ((exp == 0x7ff) && ((hx & 0xf0000 || lx) == 0))
+ return (1);
+ else
+ return (0);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_isnan.c b/newlib/libm/mathfp/s_isnan.c
new file mode 100644
index 000000000..776baa239
--- /dev/null
+++ b/newlib/libm/mathfp/s_isnan.c
@@ -0,0 +1,125 @@
+
+/* @(#)z_isnan.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+ <<isnan>>,<<isnanf>>,<<isinf>>,<<isinff>>,<<finite>>,<<finitef>>---test
+for exceptional numbers
+
+INDEX
+ isnan
+INDEX
+ isinf
+INDEX
+ finite
+
+INDEX
+ isnanf
+INDEX
+ isinff
+INDEX
+ finitef
+
+ANSI_SYNOPSIS
+ #include <ieeefp.h>
+ int isnan(double <[arg]>);
+ int isinf(double <[arg]>);
+ int finite(double <[arg]>);
+ int isnanf(float <[arg]>);
+ int isinff(float <[arg]>);
+ int finitef(float <[arg]>);
+
+TRAD_SYNOPSIS
+ #include <ieeefp.h>
+ int isnan(<[arg]>)
+ double <[arg]>;
+ int isinf(<[arg]>)
+ double <[arg]>;
+ int finite(<[arg]>);
+ double <[arg]>;
+ int isnanf(<[arg]>);
+ float <[arg]>;
+ int isinff(<[arg]>);
+ float <[arg]>;
+ int finitef(<[arg]>);
+ float <[arg]>;
+
+
+DESCRIPTION
+ These functions provide information on the floating point
+ argument supplied.
+
+ There are five major number formats -
+ o+
+ o zero
+ a number which contains all zero bits.
+ o subnormal
+ Is used to represent number with a zero exponent, but a non zero fract
+ion.
+ o normal
+ A number with an exponent, and a fraction
+ o infinity
+ A number with an all 1's exponent and a zero fraction.
+ o NAN
+ A number with an all 1's exponent and a non zero fraction.
+
+ o-
+
+ <<isnan>> returns 1 if the argument is a nan. <<isinf>>
+ returns 1 if the argument is infinity. <<finite>> returns 1 if the
+ argument is zero, subnormal or normal.
+
+ The <<isnanf>>, <<isinff>> and <<finitef>> perform the same
+ operations as their <<isnan>>, <<isinf>> and <<finite>>
+ counterparts, but on single precision floating point numbers.
+
+QUICKREF
+ isnan - pure
+QUICKREF
+ isinf - pure
+QUICKREF
+ finite - pure
+QUICKREF
+ isnan - pure
+QUICKREF
+ isinf - pure
+QUICKREF
+ finite - pure
+*/
+
+
+/******************************************************************
+ * isnan
+ *
+ * Input:
+ * x - pointer to a floating point value
+ *
+ * Output:
+ * An integer that indicates if the number is NaN.
+ *
+ * Description:
+ * This routine returns an integer that indicates if the number
+ * passed in is NaN (1) or is finite (0).
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+int isnan (double x)
+{
+ __uint32_t lx, hx;
+ int exp;
+
+ EXTRACT_WORDS (hx, lx, x);
+ exp = (hx & 0x7ff00000) >> 20;
+
+ if ((exp == 0x7ff) && (hx & 0xf0000 || lx))
+ return (1);
+ else
+ return (0);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_ispos.c b/newlib/libm/mathfp/s_ispos.c
new file mode 100644
index 000000000..2077999c3
--- /dev/null
+++ b/newlib/libm/mathfp/s_ispos.c
@@ -0,0 +1,35 @@
+
+/* @(#)z_ispos.c 1.0 98/08/13 */
+/******************************************************************
+ * Numtest
+ *
+ * Input:
+ * x - pointer to a floating point value
+ *
+ * Output:
+ * An integer that indicates if the number is positive.
+ *
+ * Description:
+ * This routine returns an integer that indicates if the number
+ * passed in is positive (1) or negative (0).
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+int ispos (double x)
+{
+ __uint32_t hx;
+
+ GET_HIGH_WORD (hx, x);
+
+ if (hx & 0x80000000)
+ return (0);
+ else
+ return (1);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_ldexp.c b/newlib/libm/mathfp/s_ldexp.c
new file mode 100644
index 000000000..97d8a3ba5
--- /dev/null
+++ b/newlib/libm/mathfp/s_ldexp.c
@@ -0,0 +1,125 @@
+
+/* @(#)z_ldexp.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+ <<ldexp>>, <<ldexpf>>---load exponent
+
+INDEX
+ ldexp
+INDEX
+ ldexpf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double ldexp(double <[val]>, int <[exp]>);
+ float ldexpf(float <[val]>, int <[exp]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+
+ double ldexp(<[val]>, <[exp]>)
+ double <[val]>;
+ int <[exp]>;
+
+ float ldexpf(<[val]>, <[exp]>)
+ float <[val]>;
+ int <[exp]>;
+
+DESCRIPTION
+<<ldexp>> calculates the value
+@ifinfo
+<[val]> times 2 to the power <[exp]>.
+@end ifinfo
+@tex
+$val\times 2^{exp}$.
+@end tex
+<<ldexpf>> is identical, save that it takes and returns <<float>>
+rather than <<double>> values.
+
+RETURNS
+<<ldexp>> returns the calculated value.
+
+Underflow and overflow both set <<errno>> to <<ERANGE>>.
+On underflow, <<ldexp>> and <<ldexpf>> return 0.0.
+On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>.
+
+PORTABILITY
+<<ldexp>> is ANSI, <<ldexpf>> is an extension.
+
+*/
+
+/******************************************************************
+ * ldexp
+ *
+ * Input:
+ * d - a floating point value
+ * e - an exponent value
+ *
+ * Output:
+ * A floating point value f such that f = d * 2 ^ e.
+ *
+ * Description:
+ * This function creates a floating point number f such that
+ * f = d * 2 ^ e.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#define DOUBLE_EXP_OFFS 1023
+
+double
+_DEFUN (ldexp, (double, int),
+ double d _AND
+ int e)
+{
+ int exp;
+ __uint32_t hd;
+
+ GET_HIGH_WORD (hd, d);
+
+ /* Check for special values and then scale d by e. */
+ switch (numtest (d))
+ {
+ case NAN:
+ errno = EDOM;
+ break;
+
+ case INF:
+ errno = ERANGE;
+ break;
+
+ case 0:
+ break;
+
+ default:
+ exp = (hd & 0x7ff00000) >> 20;
+ exp += e;
+
+ if (exp > DBL_MAX_EXP + DOUBLE_EXP_OFFS)
+ {
+ errno = ERANGE;
+ d = z_infinity.d;
+ }
+ else if (exp < DBL_MIN_EXP + DOUBLE_EXP_OFFS)
+ {
+ errno = ERANGE;
+ d = -z_infinity.d;
+ }
+ else
+ {
+ hd &= 0x800fffff;
+ hd |= exp << 20;
+ SET_HIGH_WORD (d, hd);
+ }
+ }
+
+ return (d);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_log.c b/newlib/libm/mathfp/s_log.c
new file mode 100644
index 000000000..27b959831
--- /dev/null
+++ b/newlib/libm/mathfp/s_log.c
@@ -0,0 +1,29 @@
+
+/* @(#)z_log.c 1.0 98/08/13 */
+/******************************************************************
+ * Logarithm
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * natural logarithm of x
+ *
+ * Description:
+ * This routine returns the natural logarithm of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (log, (double),
+ double x)
+{
+ return (logarithm (x, 0));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_log10.c b/newlib/libm/mathfp/s_log10.c
new file mode 100644
index 000000000..080cecd81
--- /dev/null
+++ b/newlib/libm/mathfp/s_log10.c
@@ -0,0 +1,68 @@
+
+/* @(#)z_log10.c 1.0 98/08/13 */
+/******************************************************************
+ * Logarithm
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * logarithm of x
+ *
+ * Description:
+ * This routine returns the logarithm of x (base 10).
+ *
+ *****************************************************************/
+
+/*
+FUNCTION
+ <<log10>>, <<log10f>>---base 10 logarithms
+
+INDEX
+log10
+INDEX
+log10f
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double log10(double <[x]>);
+ float log10f(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double log10(<[x]>)
+ double <[x]>;
+
+ float log10f(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+<<log10>> returns the base 10 logarithm of <[x]>.
+It is implemented as <<log(<[x]>) / log(10)>>.
+
+<<log10f>> is identical, save that it takes and returns <<float>> values.
+
+RETURNS
+<<log10>> and <<log10f>> return the calculated value.
+
+See the description of <<log>> for information on errors.
+
+PORTABILITY
+<<log10>> is ANSI C. <<log10f>> is an extension.
+
+*/
+
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (log10, (double),
+ double x)
+{
+ return (logarithm (x, 1));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_logarithm.c b/newlib/libm/mathfp/s_logarithm.c
new file mode 100644
index 000000000..ee7c7069e
--- /dev/null
+++ b/newlib/libm/mathfp/s_logarithm.c
@@ -0,0 +1,135 @@
+
+/* @(#)z_logarithm.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+
+/*
+FUNCTION
+ <<log>>, <<logf>>, <<log10>>, <<log10f>>, <<logarithm>>, <<logarithmf>>---natural or base 10 logarithms
+
+INDEX
+ log
+INDEX
+ logf
+INDEX
+ log10
+INDEX
+ log10f
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double log(double <[x]>);
+ float logf(float <[x]>);
+ double log10(double <[x]>);
+ float log10f(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double log(<[x]>);
+ double <[x]>;
+
+ float logf(<[x]>);
+ float <[x]>;
+
+ double log10(<[x]>);
+ double <[x]>;
+
+ float log10f(<[x]>);
+ float <[x]>;
+
+DESCRIPTION
+Return the natural or base 10 logarithm of <[x]>, that is, its logarithm base e
+(where e is the base of the natural system of logarithms, 2.71828@dots{}) or
+base 10.
+<<log>> and <<logf>> are identical save for the return and argument types.
+<<log10>> and <<log10f>> are identical save for the return and argument types.
+
+RETURNS
+Normally, returns the calculated value. When <[x]> is zero, the
+returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>.
+When <[x]> is negative, the returned value is <<-HUGE_VAL>> and
+<<errno>> is set to <<EDOM>>. You can control the error behavior via
+<<matherr>>.
+
+PORTABILITY
+<<log>> is ANSI, <<logf>> is an extension.
+<<log10>> is ANSI, <<log10f>> is an extension.
+*/
+
+
+/******************************************************************
+ * Logarithm
+ *
+ * Input:
+ * x - floating point value
+ * ten - indicates base ten numbers
+ *
+ * Output:
+ * logarithm of x
+ *
+ * Description:
+ * This routine calculates logarithms.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+static const double a[] = { -0.64124943423745581147e+02,
+ 0.16383943563021534222e+02,
+ -0.78956112887481257267 };
+static const double b[] = { -0.76949932108494879777e+03,
+ 0.31203222091924532844e+03,
+ -0.35667977739034646171e+02 };
+static const double C1 = 22713.0 / 32768.0;
+static const double C2 = 1.428606820309417232e-06;
+static const double C3 = 0.43429448190325182765;
+
+double
+_DEFUN (logarithm, (double, int),
+ double x _AND
+ int ten)
+{
+ int N;
+ double f, w, z;
+
+ /* Check for domain error here. */
+ if (x <= 0.0)
+ {
+ errno = ERANGE;
+ return (z_notanum.d);
+ }
+
+ /* Get the exponent and mantissa where x = f * 2^N. */
+ f = frexp (x, &N);
+
+ z = f - 0.5;
+
+ if (f > __SQRT_HALF)
+ z = (z - 0.5) / (f * 0.5 + 0.5);
+ else
+ {
+ N--;
+ z /= (z * 0.5 + 0.5);
+ }
+ w = z * z;
+
+ /* Use Newton's method with 4 terms. */
+ z += z * w * ((a[2] * w + a[1]) * w + a[0]) / (((w + b[2]) * w + b[1]) * w + b[0]);
+
+ if (N != 0)
+ z = (N * C2 + z) + N * C1;
+
+ if (ten)
+ z *= C3;
+
+ return (z);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_mathcnst.c b/newlib/libm/mathfp/s_mathcnst.c
new file mode 100644
index 000000000..7865c7f78
--- /dev/null
+++ b/newlib/libm/mathfp/s_mathcnst.c
@@ -0,0 +1,24 @@
+/* @(#)z_mathcnst.c 1.0 98/08/13 */
+
+#include "zmath.h"
+#include "fdlibm.h"
+
+double BIGX = 7.09782712893383973096e+02;
+double SMALLX = -7.45133219101941108420e+02;
+double z_rooteps = 7.4505859692e-9;
+float z_rooteps_f = 1.7263349182589107e-4;
+
+ufloat z_hugeval_f = { 0x7f800000 };
+ufloat z_infinity_f = { 0x7f800000 };
+ufloat z_notanum_f = { 0xffd00000 };
+
+#ifdef ___IEEE_LITTLE_ENDIAN
+udouble z_hugeval = { 0x7ff00000, 0 };
+udouble z_infinity = { 0x7ff00000, 0 };
+udouble z_notanum = { 0xfff80000, 0 };
+#else
+udouble z_hugeval = { 0, 0x7ff00000 };
+udouble z_infinity = { 0, 0x7ff00000 };
+udouble z_notanum = { 0, 0xfff80000 };
+#endif /* ___IEEE_LITTLE_ENDIAN */
+
diff --git a/newlib/libm/mathfp/s_numtest.c b/newlib/libm/mathfp/s_numtest.c
new file mode 100644
index 000000000..b41bb87f4
--- /dev/null
+++ b/newlib/libm/mathfp/s_numtest.c
@@ -0,0 +1,58 @@
+
+/* @(#)z_numtest.c 1.0 98/08/13 */
+/******************************************************************
+ * Numtest
+ *
+ * Input:
+ * x - pointer to a floating point value
+ *
+ * Output:
+ * An integer that indicates what kind of number was passed in:
+ * NUM = 3 - a finite value
+ * NAN = 2 - not a number
+ * INF = 1 - an infinite value
+ * 0 - zero
+ *
+ * Description:
+ * This routine returns an integer that indicates the character-
+ * istics of the number that was passed in.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+int
+_DEFUN (numtest, (double),
+ double x)
+{
+ __uint32_t hx, lx;
+ int exp;
+
+ EXTRACT_WORDS (hx, lx, x);
+
+ exp = (hx & 0x7ff00000) >> 20;
+
+ /* Check for a zero input. */
+ if (x == 0.0)
+ {
+ return (0);
+ }
+
+ /* Check for not a number or infinity. */
+ if (exp == 0x7ff)
+ {
+ if(hx & 0xf0000 || lx)
+ return (NAN);
+ else
+ return (INF);
+ }
+
+ /* Otherwise it's a finite value. */
+ else
+ return (NUM);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_pow.c b/newlib/libm/mathfp/s_pow.c
new file mode 100644
index 000000000..7c0a38a20
--- /dev/null
+++ b/newlib/libm/mathfp/s_pow.c
@@ -0,0 +1,146 @@
+
+/* @(#)z_pow.c 1.0 98/08/13 */
+
+/*
+FUNCTION
+ <<pow>>, <<powf>>---x to the power y
+INDEX
+ pow
+INDEX
+ powf
+
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double pow(double <[x]>, double <[y]>);
+ float pow(float <[x]>, float <[y]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double pow(<[x]>, <[y]>);
+ double <[x]>, <[y]>;
+
+ float pow(<[x]>, <[y]>);
+ float <[x]>, <[y]>;
+
+DESCRIPTION
+ <<pow>> and <<powf>> calculate <[x]> raised to the exp1.0nt <[y]>.
+ @tex
+ (That is, $x^y$.)
+ @end tex
+
+RETURNS
+ On success, <<pow>> and <<powf>> return the value calculated.
+
+ When the argument values would produce overflow, <<pow>>
+ returns <<HUGE_VAL>> and set <<errno>> to <<ERANGE>>. If the
+ argument <[x]> passed to <<pow>> or <<powf>> is a negative
+ noninteger, and <[y]> is also not an integer, then <<errno>>
+ is set to <<EDOM>>. If <[x]> and <[y]> are both 0, then
+ <<pow>> and <<powf>> return <<1>>.
+
+ You can modify error handling for these functions using <<matherr>>.
+
+PORTABILITY
+ <<pow>> is ANSI C. <<powf>> is an extension. */
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double pow (double x, double y)
+{
+ double d, t, r = 1.0;
+ int n, k, sign = 0;
+ __uint32_t px;
+
+ GET_HIGH_WORD (px, x);
+
+ k = modf (y, &d);
+ if (k == 0.0)
+ {
+ if (modf (ldexp (y, -1), &t))
+ sign = 0;
+ else
+ sign = 1;
+ }
+
+ if (x == 0.0 && y <= 0.0)
+ errno = EDOM;
+
+ else if ((t = y * log (fabs (x))) >= BIGX)
+ {
+ errno = ERANGE;
+ if (px & 0x80000000)
+ {
+ if (!k)
+ {
+ errno = EDOM;
+ x = 0.0;
+ }
+ else if (sign)
+ x = -z_infinity.d;
+ else
+ x = z_infinity.d;
+ }
+
+ else
+ x = z_infinity.d;
+ }
+
+ else if (t < SMALLX)
+ {
+ errno = ERANGE;
+ x = 0.0;
+ }
+
+ else
+ {
+ if ( k && fabs(d) <= 32767 )
+ {
+ n = (int) d;
+
+ if (sign = (n < 0))
+ n = -n;
+
+ while ( n > 0 )
+ {
+ if ((unsigned int) n % 2)
+ r *= x;
+ x *= x;
+ n = (unsigned int) n / 2;
+ }
+
+ if (sign)
+ r = 1.0 / r;
+
+ return r;
+ }
+
+ else
+ {
+ if ( px & 0x80000000 )
+ {
+ if ( !k )
+ {
+ errno = EDOM;
+ return 0.0;
+ }
+ }
+
+ x = exp (t);
+
+ if ( sign )
+ {
+ px ^= 0x80000000;
+ SET_HIGH_WORD (x, px);
+ }
+ }
+ }
+
+ return x;
+}
+
+#endif _DOUBLE_IS_32BITS
diff --git a/newlib/libm/mathfp/s_signif.c b/newlib/libm/mathfp/s_signif.c
new file mode 100644
index 000000000..76b5f7cb6
--- /dev/null
+++ b/newlib/libm/mathfp/s_signif.c
@@ -0,0 +1,34 @@
+
+/* @(#)s_signif.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * significand(x) computes just
+ * scalb(x, (double) -ilogb(x)),
+ * for exercising the fraction-part(F) IEEE 754-1985 test vector.
+ */
+
+#include "fdlibm.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+ double significand(double x)
+#else
+ double significand(x)
+ double x;
+#endif
+{
+ return scalb(x,(double) -ilogb(x));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_sin.c b/newlib/libm/mathfp/s_sin.c
new file mode 100644
index 000000000..2051304e0
--- /dev/null
+++ b/newlib/libm/mathfp/s_sin.c
@@ -0,0 +1,29 @@
+
+/* @(#)z_sin.c 1.0 98/08/13 */
+/******************************************************************
+ * Sine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * sine of x
+ *
+ * Description:
+ * This routine returns the sine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (sin, (double),
+ double x)
+{
+ return (sine (x, 0));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_sine.c b/newlib/libm/mathfp/s_sine.c
new file mode 100644
index 000000000..9642f4a56
--- /dev/null
+++ b/newlib/libm/mathfp/s_sine.c
@@ -0,0 +1,166 @@
+
+/* @(#)z_sine.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+
+/*
+FUNCTION
+ <<sin>>, <<cos>>, <<sine>>, <<sinf>>, <<cosf>>, <<sinef>>---sine or cosine
+INDEX
+sin
+INDEX
+sinf
+INDEX
+cos
+INDEX
+cosf
+ANSI_SYNOPSIS
+ #include <math.h>
+ double sin(double <[x]>);
+ float sinf(float <[x]>);
+ double cos(double <[x]>);
+ float cosf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double sin(<[x]>)
+ double <[x]>;
+ float sinf(<[x]>)
+ float <[x]>;
+
+ double cos(<[x]>)
+ double <[x]>;
+ float cosf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+ <<sin>> and <<cos>> compute (respectively) the sine and cosine
+ of the argument <[x]>. Angles are specified in radians.
+RETURNS
+ The sine or cosine of <[x]> is returned.
+
+PORTABILITY
+ <<sin>> and <<cos>> are ANSI C.
+ <<sinf>> and <<cosf>> are extensions.
+
+QUICKREF
+ sin ansi pure
+ sinf - pure
+*/
+
+/******************************************************************
+ * sine
+ *
+ * Input:
+ * x - floating point value
+ * cosine - indicates cosine value
+ *
+ * Output:
+ * Sine of x.
+ *
+ * Description:
+ * This routine calculates sines and cosines.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+static const double HALF_PI = 1.57079632679489661923;
+static const double ONE_OVER_PI = 0.31830988618379067154;
+static const double r[] = { -0.16666666666666665052,
+ 0.83333333333331650314e-02,
+ -0.19841269841201840457e-03,
+ 0.27557319210152756119e-05,
+ -0.25052106798274584544e-07,
+ 0.16058936490371589114e-09,
+ -0.76429178068910467734e-12,
+ 0.27204790957888846175e-14 };
+
+double
+_DEFUN (sine, (double, int),
+ double x _AND
+ int cosine)
+{
+ int sgn, N;
+ double y, XN, g, R, res;
+ double YMAX = 210828714.0;
+
+ switch (numtest (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = EDOM;
+ return (z_notanum.d);
+ }
+
+ /* Use sin and cos properties to ease computations. */
+ if (cosine)
+ {
+ sgn = 1;
+ y = fabs (x) + HALF_PI;
+ }
+ else
+ {
+ if (x < 0.0)
+ {
+ sgn = -1;
+ y = -x;
+ }
+ else
+ {
+ sgn = 1;
+ y = x;
+ }
+ }
+
+ /* Check for values of y that will overflow here. */
+ if (y > YMAX)
+ {
+ errno = ERANGE;
+ return (x);
+ }
+
+ /* Calculate the exponent. */
+ if (y < 0.0)
+ N = (int) (y * ONE_OVER_PI - 0.5);
+ else
+ N = (int) (y * ONE_OVER_PI + 0.5);
+ XN = (double) N;
+
+ if (N & 1)
+ sgn = -sgn;
+
+ if (cosine)
+ XN -= 0.5;
+
+ y = fabs (x) - XN * __PI;
+
+ if (-z_rooteps < y && y < z_rooteps)
+ res = y;
+
+ else
+ {
+ g = y * y;
+
+ /* Calculate the Taylor series. */
+ R = (((((((r[6] * g + r[5]) * g + r[4]) * g + r[3]) * g + r[2]) * g + r[1]) * g + r[0]) * g);
+
+ /* Finally, compute the result. */
+ res = y + y * R;
+ }
+
+ res *= sgn;
+
+ return (res);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_sineh.c b/newlib/libm/mathfp/s_sineh.c
new file mode 100644
index 000000000..6b3480d73
--- /dev/null
+++ b/newlib/libm/mathfp/s_sineh.c
@@ -0,0 +1,185 @@
+
+/* @(#)z_sineh.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+
+/*
+FUNCTION
+ <<sinh>>, <<sinhf>>, <<cosh>>, <<coshf>>, <<sineh>>---hyperbolic sine or cosine
+
+INDEX
+ sinh
+INDEX
+ sinhf
+INDEX
+ cosh
+INDEX
+ coshf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double sinh(double <[x]>);
+ float sinhf(float <[x]>);
+ double cosh(double <[x]>);
+ float coshf(float <[x]>);
+TRAD_SYNOPSIS
+ #include <math.h>
+ double sinh(<[x]>)
+ double <[x]>;
+
+ float sinhf(<[x]>)
+ float <[x]>;
+
+ double cosh(<[x]>)
+ double <[x]>;
+
+ float coshf(<[x]>)
+ float <[x]>;
+
+DESCRIPTION
+ <<sinh>> and <<cosh>> compute the hyperbolic sine or cosine
+ of the argument <[x]>.
+ Angles are specified in radians. <<sinh>>(<[x]>) is defined as
+ @ifinfo
+ . (exp(<[x]>) - exp(-<[x]>))/2
+ @end ifinfo
+ @tex
+ $${e^x - e^{-x}}\over 2$$
+ @end tex
+ <<cosh>> is defined as
+ @ifinfo
+ . (exp(<[x]>) - exp(-<[x]>))/2
+ @end ifinfo
+ @tex
+ $${e^x + e^{-x}}\over 2$$
+ @end tex
+
+ <<sinhf>> and <<coshf>> are identical, save that they take
+ and returns <<float>> values.
+
+RETURNS
+ The hyperbolic sine or cosine of <[x]> is returned.
+
+ When the correct result is too large to be representable (an
+ overflow), the functions return <<HUGE_VAL>> with the
+ appropriate sign, and sets the global value <<errno>> to
+ <<ERANGE>>.
+
+PORTABILITY
+ <<sinh>> is ANSI C.
+ <<sinhf>> is an extension.
+ <<cosh>> is ANSI C.
+ <<coshf>> is an extension.
+
+*/
+
+/******************************************************************
+ * Hyperbolic Sine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * hyperbolic sine of x
+ *
+ * Description:
+ * This routine calculates hyperbolic sines.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const double q[] = { -0.21108770058106271242e+7,
+ 0.36162723109421836460e+5,
+ -0.27773523119650701667e+3 };
+static const double p[] = { -0.35181283430177117881e+6,
+ -0.11563521196851768270e+5,
+ -0.16375798202630751372e+3,
+ -0.78966127417357099479 };
+static const double LNV = 0.6931610107421875000;
+static const double INV_V2 = 0.24999308500451499336;
+static const double V_OVER2_MINUS1 = 0.13830277879601902638e-4;
+
+double
+_DEFUN (sineh, (double, int),
+ double x _AND
+ int cosineh)
+{
+ double y, f, P, Q, R, res, z, w;
+ int sgn = 1;
+ double WBAR = 18.55;
+
+ /* Check for special values. */
+ switch (numtest (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = ERANGE;
+ return (ispos (x) ? z_infinity.d : -z_infinity.d);
+ }
+
+ y = fabs (x);
+
+ if (!cosineh && x < 0.0)
+ sgn = -1;
+
+ if ((y > 1.0 && !cosineh) || cosineh)
+ {
+ if (y > BIGX)
+ {
+ w = y - LNV;
+
+ /* Check for w > maximum here. */
+ if (w > BIGX)
+ {
+ errno = ERANGE;
+ return (x);
+ }
+
+ z = exp (w);
+
+ if (w > WBAR)
+ res = z * (V_OVER2_MINUS1 + 1.0);
+ }
+
+ else
+ {
+ z = exp (y);
+ if (cosineh)
+ res = (z + 1 / z) / 2.0;
+ else
+ res = (z - 1 / z) / 2.0;
+ }
+
+ if (sgn < 0)
+ res = -res;
+ }
+ else
+ {
+ /* Check for y being too small. */
+ if (y < z_rooteps)
+ {
+ res = x;
+ }
+ /* Calculate the Taylor series. */
+ else
+ {
+ f = x * x;
+ Q = ((f + q[2]) * f + q[1]) * f + q[0];
+ P = ((p[3] * f + p[2]) * f + p[1]) * f + p[0];
+ R = f * (P / Q);
+
+ res = x + x * R;
+ }
+ }
+
+ return (res);
+}
diff --git a/newlib/libm/mathfp/s_sinf.c b/newlib/libm/mathfp/s_sinf.c
new file mode 100644
index 000000000..b738a49b9
--- /dev/null
+++ b/newlib/libm/mathfp/s_sinf.c
@@ -0,0 +1,34 @@
+
+/* @(#)z_sinf.c 1.0 98/08/13 */
+/******************************************************************
+ * Sine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * sine of x
+ *
+ * Description:
+ * This routine returns the sine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (sinf, (float),
+ float x)
+{
+ return (sinef (x, 0));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double sin (double x)
+{
+ return (double) sinf ((float) x);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_sinh.c b/newlib/libm/mathfp/s_sinh.c
new file mode 100644
index 000000000..c600ee0da
--- /dev/null
+++ b/newlib/libm/mathfp/s_sinh.c
@@ -0,0 +1,29 @@
+
+/* @(#)z_sinh.c 1.0 98/08/13 */
+/******************************************************************
+ * Hyperbolic Sine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * hyperbolic sine of x
+ *
+ * Description:
+ * This routine returns the hyperbolic sine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (sinh, (double),
+ double x)
+{
+ return (sineh (x, 0));
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_sqrt.c b/newlib/libm/mathfp/s_sqrt.c
new file mode 100644
index 000000000..bafbb38b1
--- /dev/null
+++ b/newlib/libm/mathfp/s_sqrt.c
@@ -0,0 +1,129 @@
+
+/* @(#)z_sqrt.c 1.0 98/08/13 */
+/*****************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ *****************************************************************/
+
+/*
+FUNCTION
+ <<sqrt>>, <<sqrtf>>---positive square root
+
+INDEX
+ sqrt
+INDEX
+ sqrtf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double sqrt(double <[x]>);
+ float sqrtf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double sqrt(<[x]>);
+ float sqrtf(<[x]>);
+
+DESCRIPTION
+ <<sqrt>> computes the positive square root of the argument.
+
+RETURNS
+ On success, the square root is returned. If <[x]> is real and
+ positive, then the result is positive. If <[x]> is real and
+ negative, the global value <<errno>> is set to <<EDOM>> (domain error).
+
+
+PORTABILITY
+ <<sqrt>> is ANSI C. <<sqrtf>> is an extension.
+*/
+
+/******************************************************************
+ * Square Root
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * square-root of x
+ *
+ * Description:
+ * This routine performs floating point square root.
+ *
+ * The initial approximation is computed as
+ * y0 = 0.41731 + 0.59016 * f
+ * where f is a fraction such that x = f * 2^exp.
+ *
+ * Three Newton iterations in the form of Heron's formula
+ * are then performed to obtain the final value:
+ * y[i] = (y[i-1] + f / y[i-1]) / 2, i = 1, 2, 3.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+double
+_DEFUN (sqrt, (double),
+ double x)
+{
+ double f, y;
+ int exp, i, odd;
+
+ /* Check for special values. */
+ switch (numtest (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ if (ispos (x))
+ {
+ errno = EDOM;
+ return (z_notanum.d);
+ }
+ else
+ {
+ errno = ERANGE;
+ return (z_infinity.d);
+ }
+ }
+
+ /* Initial checks are performed here. */
+ if (x == 0.0)
+ return (0.0);
+ if (x < 0)
+ {
+ errno = EDOM;
+ return (z_notanum.d);
+ }
+
+ /* Find the exponent and mantissa for the form x = f * 2^exp. */
+ f = frexp (x, &exp);
+
+ odd = exp & 1;
+
+ /* Get the initial approximation. */
+ y = 0.41731 + 0.59016 * f;
+
+ f /= 2.0;
+ /* Calculate the remaining iterations. */
+ for (i = 0; i < 3; ++i)
+ y = y / 2.0 + f / y;
+
+ /* Calculate the final value. */
+ if (odd)
+ {
+ y *= __SQRT_HALF;
+ exp++;
+ }
+ exp >>= 1;
+ y = ldexp (y, exp);
+
+ return (y);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_tan.c b/newlib/libm/mathfp/s_tan.c
new file mode 100644
index 000000000..725aeec26
--- /dev/null
+++ b/newlib/libm/mathfp/s_tan.c
@@ -0,0 +1,139 @@
+
+/* @(#)z_tan.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+
+/*
+FUNCTION
+ <<tan>>, <<tanf>>---tangent
+
+INDEX
+tan
+INDEX
+tanf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double tan(double <[x]>);
+ float tanf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double tan(<[x]>)
+ double <[x]>;
+
+ float tanf(<[x]>)
+ float <[x]>;
+
+
+DESCRIPTION
+<<tan>> computes the tangent of the argument <[x]>.
+Angles are specified in radians.
+
+<<tanf>> is identical, save that it takes and returns <<float>> values.
+
+RETURNS
+The tangent of <[x]> is returned.
+
+PORTABILITY
+<<tan>> is ANSI. <<tanf>> is an extension.
+*/
+
+/******************************************************************
+ * Tangent
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * tangent of x
+ *
+ * Description:
+ * This routine calculates the tangent of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+static const double TWO_OVER_PI = 0.63661977236758134308;
+static const double p[] = { -0.13338350006421960681,
+ 0.34248878235890589960e-2,
+ -0.17861707342254426711e-4 };
+static const double q[] = { -0.46671683339755294240,
+ 0.25663832289440112864e-1,
+ -0.31181531907010027307e-3,
+ 0.49819433993786512270e-6 };
+
+double
+_DEFUN (tan, (double),
+ double x)
+{
+ double y, f, g, XN, xnum, xden, res;
+ int N;
+
+ /* Check for special values. */
+ switch (numtest (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = EDOM;
+ return (z_notanum.d);
+ }
+
+ y = fabs (x);
+
+ /* Check for values that are out of our range. */
+ if (y > 105414357.0)
+ {
+ errno = ERANGE;
+ return (y);
+ }
+
+ if (x < 0.0)
+ N = (int) (x * TWO_OVER_PI - 0.5);
+ else
+ N = (int) (x * TWO_OVER_PI + 0.5);
+
+ XN = (double) N;
+
+ f = x - N * __PI_OVER_TWO;
+
+ /* Check for values that are too small. */
+ if (-z_rooteps < f && f < z_rooteps)
+ {
+ xnum = f;
+ xden = 1.0;
+ }
+
+ /* Calculate the polynomial. */
+ else
+ {
+ g = f * f;
+
+ xnum = f * ((p[2] * g + p[1]) * g + p[0]) * g + f;
+ xden = (((q[3] * g + q[2]) * g + q[1]) * g + q[0]) * g + 1.0;
+ }
+
+ if (N & 1)
+ {
+ xnum = -xnum;
+ res = xden / xnum;
+ }
+ else
+ {
+ res = xnum / xden;
+ }
+
+ return (res);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/s_tanh.c b/newlib/libm/mathfp/s_tanh.c
new file mode 100644
index 000000000..a19855e0b
--- /dev/null
+++ b/newlib/libm/mathfp/s_tanh.c
@@ -0,0 +1,117 @@
+
+/* @(#)z_tanh.c 1.0 98/08/13 */
+/*****************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ *****************************************************************/
+
+/*
+
+FUNCTION
+ <<tanh>>, <<tanhf>>---hyperbolic tangent
+
+INDEX
+tanh
+INDEX
+tanhf
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double tanh(double <[x]>);
+ float tanhf(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double tanh(<[x]>)
+ double <[x]>;
+
+ float tanhf(<[x]>)
+ float <[x]>;
+
+
+DESCRIPTION
+
+<<tanh>> computes the hyperbolic tangent of
+the argument <[x]>. Angles are specified in radians.
+
+<<tanh(<[x]>)>> is defined as
+. sinh(<[x]>)/cosh(<[x]>)
+
+<<tanhf>> is identical, save that it takes and returns <<float>> values.
+
+RETURNS
+The hyperbolic tangent of <[x]> is returned.
+
+PORTABILITY
+<<tanh>> is ANSI C. <<tanhf>> is an extension.
+
+*/
+
+/******************************************************************
+ * Hyperbolic Tangent
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * hyperbolic tangent of x
+ *
+ * Description:
+ * This routine calculates hyperbolic tangent.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+#ifndef _DOUBLE_IS_32BITS
+
+static const double LN3_OVER2 = 0.54930614433405484570;
+static const double p[] = { -0.16134119023996228053e+4,
+ -0.99225929672236083313e+2,
+ -0.96437492777225469787 };
+static const double q[] = { 0.48402357071988688686e+4,
+ 0.22337720718962312926e+4,
+ 0.11274474380534949335e+3 };
+
+double
+_DEFUN (tanh, (double),
+ double x)
+{
+ double f, res, g, P, Q, R;
+
+ f = fabs (x);
+
+ /* Check if the input is too big. */
+ if (f > BIGX)
+ res = 1.0;
+
+ else if (f > LN3_OVER2)
+ res = 1.0 - 2.0 / (exp (2 * f) + 1.0);
+
+ /* Check if the input is too small. */
+ else if (f < z_rooteps)
+ res = f;
+
+ /* Calculate the Taylor series. */
+ else
+ {
+ g = f * f;
+
+ P = (p[2] * g + p[1]) * g + p[0];
+ Q = ((g + q[2]) * g + q[1]) * g + q[0];
+ R = g * (P / Q);
+
+ res = f + f * R;
+ }
+
+ if (x < 0.0)
+ res = -res;
+
+ return (res);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/sf_acos.c b/newlib/libm/mathfp/sf_acos.c
new file mode 100644
index 000000000..6bef98041
--- /dev/null
+++ b/newlib/libm/mathfp/sf_acos.c
@@ -0,0 +1,33 @@
+
+/* @(#)z_acosf.c 1.0 98/08/13 */
+/******************************************************************
+ * Arccosine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * arccosine of x
+ *
+ * Description:
+ * This routine returns the arccosine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (acosf, (float),
+ float x)
+{
+ return (asinef (x, 1));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+double acos (double x)
+{
+ return (double) asinef ((float) x, 1);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_asin.c b/newlib/libm/mathfp/sf_asin.c
new file mode 100644
index 000000000..92c33fda3
--- /dev/null
+++ b/newlib/libm/mathfp/sf_asin.c
@@ -0,0 +1,34 @@
+
+/* @(#)z_asinf.c 1.0 98/08/13 */
+/******************************************************************
+ * Arcsine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * arcsine of x
+ *
+ * Description:
+ * This routine returns the arcsine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (asinf, (float),
+ float x)
+{
+ return (asinef (x, 0));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double asin (double x)
+{
+ return (double) asinef ((float) x, 0);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_asine.c b/newlib/libm/mathfp/sf_asine.c
new file mode 100644
index 000000000..12ba28927
--- /dev/null
+++ b/newlib/libm/mathfp/sf_asine.c
@@ -0,0 +1,105 @@
+
+/* @(#)z_asinef.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+/******************************************************************
+ * Arcsine
+ *
+ * Input:
+ * x - floating point value
+ * acosine - indicates acos calculation
+ *
+ * Output:
+ * Arcsine of x.
+ *
+ * Description:
+ * This routine calculates arcsine / arccosine.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float p[] = { 0.933935835, -0.504400557 };
+static const float q[] = { 0.560363004e+1, -0.554846723e+1 };
+static const float a[] = { 0.0, 0.785398163 };
+static const float b[] = { 1.570796326, 0.785398163 };
+
+float
+_DEFUN (asinef, (float, int),
+ float x _AND
+ int acosine)
+{
+ int flag, i;
+ int branch = 0;
+ float g, res, R, P, Q, y;
+
+ /* Check for special values. */
+ i = numtestf (x);
+ if (i == NAN || i == INF)
+ {
+ errno = EDOM;
+ if (i == NAN)
+ return (x);
+ else
+ return (z_infinity_f.f);
+ }
+
+ y = fabsf (x);
+ flag = acosine;
+
+ if (y > 0.5)
+ {
+ i = 1 - flag;
+
+ /* Check for range error. */
+ if (y > 1.0)
+ {
+ errno = ERANGE;
+ return (z_notanum_f.f);
+ }
+
+ g = (1 - y) / 2.0;
+ y = -2 * sqrt (g);
+ branch = 1;
+ }
+ else
+ {
+ i = flag;
+ if (y < z_rooteps_f)
+ res = y;
+ else
+ g = y * y;
+ }
+
+ if (y >= z_rooteps_f || branch == 1)
+ {
+ /* Calculate the Taylor series. */
+ P = (p[1] * g + p[0]) * g;
+ Q = (g + q[1]) * g + q[0];
+ R = P / Q;
+
+ res = y + y * R;
+ }
+
+ /* Calculate asine or acose. */
+ if (flag == 0)
+ {
+ res = (a[i] + res) + a[i];
+ if (x < 0.0)
+ res = -res;
+ }
+ else
+ {
+ if (x < 0.0)
+ res = (b[i] + res) + b[i];
+ else
+ res = (a[i] - res) + a[i];
+ }
+
+ return (res);
+}
diff --git a/newlib/libm/mathfp/sf_asinh.c b/newlib/libm/mathfp/sf_asinh.c
new file mode 100644
index 000000000..ee07e39f0
--- /dev/null
+++ b/newlib/libm/mathfp/sf_asinh.c
@@ -0,0 +1,66 @@
+/* sf_asinh.c -- float version of s_asinh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const float
+#else
+static float
+#endif
+one = 1.0000000000e+00, /* 0x3F800000 */
+ln2 = 6.9314718246e-01, /* 0x3f317218 */
+huge= 1.0000000000e+30;
+
+#ifdef __STDC__
+ float asinhf(float x)
+#else
+ float asinhf(x)
+ float x;
+#endif
+{
+ float t,w;
+ __int32_t hx,ix;
+ GET_FLOAT_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7f800000) return x+x; /* x is inf or NaN */
+ if(ix< 0x31800000) { /* |x|<2**-28 */
+ if(huge+x>one) return x; /* return x inexact except 0 */
+ }
+ if(ix>0x4d800000) { /* |x| > 2**28 */
+ w = logf(fabsf(x))+ln2;
+ } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */
+ t = fabsf(x);
+ w = logf((float)2.0*t+one/(sqrtf(x*x+one)+t));
+ } else { /* 2.0 > |x| > 2**-28 */
+ t = x*x;
+ w =log1pf(fabsf(x)+t/(one+sqrtf(one+t)));
+ }
+ if(hx>0) return w; else return -w;
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+ double asinh(double x)
+#else
+ double asinh(x)
+ double x;
+#endif
+{
+ return (double) asinhf((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_atan.c b/newlib/libm/mathfp/sf_atan.c
new file mode 100644
index 000000000..26be2fafa
--- /dev/null
+++ b/newlib/libm/mathfp/sf_atan.c
@@ -0,0 +1,45 @@
+
+/* @(#)z_atanf.c 1.0 98/08/13 */
+/******************************************************************
+ * Arctangent
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * arctan of x
+ *
+ * Description:
+ * This routine returns the arctan of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (atanf, (float),
+ float x)
+{
+ switch (numtestf (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ /* this should check to see if neg NaN or pos NaN... */
+ return (__PI_OVER_TWO);
+ case 0:
+ return (0.0);
+ default:
+ return (atangentf (x, 0, 0, 0));
+ }
+}
+
+#ifdef _DOUBLE_IS_32BITS
+double atan (double x)
+{
+ return (double) atangentf ((float) x, 0);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_atan2.c b/newlib/libm/mathfp/sf_atan2.c
new file mode 100644
index 000000000..f3237a5e6
--- /dev/null
+++ b/newlib/libm/mathfp/sf_atan2.c
@@ -0,0 +1,34 @@
+
+/* @(#)z_atan2f.c 1.0 98/08/13 */
+/******************************************************************
+ * Arctangent2
+ *
+ * Input:
+ * v, u - floating point values
+ *
+ * Output:
+ * arctan2 of v / u
+ *
+ * Description:
+ * This routine returns the arctan2 of v / u.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (atan2f, (float, float),
+ float v _AND
+ float u)
+{
+ return (atangentf (0.0, v, u, 1));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+double atan2f (double v, double u)
+{
+ return (double) atangentf (0.0, (float) v, (float) u, 1);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_atangent.c b/newlib/libm/mathfp/sf_atangent.c
new file mode 100644
index 000000000..55a90063c
--- /dev/null
+++ b/newlib/libm/mathfp/sf_atangent.c
@@ -0,0 +1,140 @@
+
+/* @(#)z_atangentf.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+/******************************************************************
+ * Arctangent
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * arctangent of x
+ *
+ * Description:
+ * This routine calculates arctangents.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float ROOT3 = 1.732050807;
+static const float a[] = { 0.0, 0.523598775, 1.570796326,
+ 1.047197551 };
+static const float q[] = { 0.1412500740e+1 };
+static const float p[] = { -0.4708325141, -0.5090958253e-1 };
+
+float
+_DEFUN (atangentf, (float, float, float, int),
+ float x _AND
+ float v _AND
+ float u _AND
+ int arctan2)
+{
+ float f, g, R, P, Q, A, res;
+ int N;
+ int branch = 0;
+ int expv, expu;
+
+ /* Preparation for calculating arctan2. */
+ if (arctan2)
+ {
+ if (u == 0.0)
+ if (v == 0.0)
+ {
+ errno = ERANGE;
+ return (z_notanum_f.f);
+ }
+ else
+ {
+ branch = 1;
+ res = __PI_OVER_TWO;
+ }
+
+ if (!branch)
+ {
+ int e;
+ /* Get the exponent values of the inputs. */
+ g = frexpf (v, &expv);
+ g = frexpf (u, &expu);
+
+ /* See if a divide will overflow. */
+ e = expv - expu;
+ if (e > FLT_MAX_EXP)
+ {
+ branch = 1;
+ res = __PI_OVER_TWO;
+ }
+
+ /* Also check for underflow. */
+ else if (e < FLT_MIN_EXP)
+ {
+ branch = 2;
+ res = 0.0;
+ }
+ }
+ }
+
+ if (!branch)
+ {
+ if (arctan2)
+ f = fabsf (v / u);
+ else
+ f = fabsf (x);
+
+ if (f > 1.0)
+ {
+ f = 1.0 / f;
+ N = 2;
+ }
+ else
+ N = 0;
+
+ if (f > (2.0 - ROOT3))
+ {
+ A = ROOT3 - 1.0;
+ f = (((A * f - 0.5) - 0.5) + f) / (ROOT3 + f);
+ N++;
+ }
+
+ /* Check for values that are too small. */
+ if (-z_rooteps_f < f && f < z_rooteps_f)
+ res = f;
+
+ /* Calculate the Taylor series. */
+ else
+ {
+ g = f * f;
+ P = (p[1] * g + p[0]) * g;
+ Q = g + q[0];
+ R = P / Q;
+
+ res = f + f * R;
+ }
+
+ if (N > 1)
+ res = -res;
+
+ res += a[N];
+ }
+
+ if (arctan2)
+ {
+ if (u < 0.0 || branch == 2)
+ res = __PI - res;
+ if (v < 0.0 || branch == 1)
+ res = -res;
+ }
+ else if (x < 0.0)
+ {
+ res = -res;
+ }
+
+ return (res);
+}
diff --git a/newlib/libm/mathfp/sf_ceil.c b/newlib/libm/mathfp/sf_ceil.c
new file mode 100644
index 000000000..bc8e1403b
--- /dev/null
+++ b/newlib/libm/mathfp/sf_ceil.c
@@ -0,0 +1,42 @@
+
+/* @(#)z_ceilf.c 1.0 98/08/13 */
+/*****************************************************************
+ * ceil
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * Smallest integer greater than x.
+ *
+ * Description:
+ * This routine returns the smallest integer greater than x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (ceilf, (float),
+ float x)
+{
+ float f, y;
+
+ y = modff (x, &f);
+
+ if (y == 0.0)
+ return (x);
+ else if (x > -1.0 && x < 1.0)
+ return (x > 0 ? 1.0 : 0.0);
+ else
+ return (x > 0 ? f + 1.0 : f);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+double ceil (double x)
+{
+ return (double) ceilf ((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_cos.c b/newlib/libm/mathfp/sf_cos.c
new file mode 100644
index 000000000..057663e69
--- /dev/null
+++ b/newlib/libm/mathfp/sf_cos.c
@@ -0,0 +1,34 @@
+
+/* @(#)z_cosf.c 1.0 98/08/13 */
+/******************************************************************
+ * Cosine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * cosine of x
+ *
+ * Description:
+ * This routine returns the cosine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (cosf, (float),
+ float x)
+{
+ return (sinef (x, 1));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double cos (double x)
+{
+ return (double) sinef ((float) x, 1);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_cosh.c b/newlib/libm/mathfp/sf_cosh.c
new file mode 100644
index 000000000..4635b7144
--- /dev/null
+++ b/newlib/libm/mathfp/sf_cosh.c
@@ -0,0 +1,33 @@
+
+/* @(#)z_coshf.c 1.0 98/08/13 */
+/******************************************************************
+ * Hyperbolic Cosine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * hyperbolic cosine of x
+ *
+ * Description:
+ * This routine returns the hyperbolic cosine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (coshf, (float),
+ float x)
+{
+ return (sinehf (x, 1));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+double cosh (double x)
+{
+ return (double) sinehf ((float) x, 1);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_erf.c b/newlib/libm/mathfp/sf_erf.c
new file mode 100644
index 000000000..aa209f65a
--- /dev/null
+++ b/newlib/libm/mathfp/sf_erf.c
@@ -0,0 +1,246 @@
+/* sf_erf.c -- float version of s_erf.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+
+#ifdef __v810__
+#define const
+#endif
+
+#ifdef __STDC__
+static const float
+#else
+static float
+#endif
+tiny = 1e-30,
+half= 5.0000000000e-01, /* 0x3F000000 */
+one = 1.0000000000e+00, /* 0x3F800000 */
+two = 2.0000000000e+00, /* 0x40000000 */
+ /* c = (subfloat)0.84506291151 */
+erx = 8.4506291151e-01, /* 0x3f58560b */
+/*
+ * Coefficients for approximation to erf on [0,0.84375]
+ */
+efx = 1.2837916613e-01, /* 0x3e0375d4 */
+efx8= 1.0270333290e+00, /* 0x3f8375d4 */
+pp0 = 1.2837916613e-01, /* 0x3e0375d4 */
+pp1 = -3.2504209876e-01, /* 0xbea66beb */
+pp2 = -2.8481749818e-02, /* 0xbce9528f */
+pp3 = -5.7702702470e-03, /* 0xbbbd1489 */
+pp4 = -2.3763017452e-05, /* 0xb7c756b1 */
+qq1 = 3.9791721106e-01, /* 0x3ecbbbce */
+qq2 = 6.5022252500e-02, /* 0x3d852a63 */
+qq3 = 5.0813062117e-03, /* 0x3ba68116 */
+qq4 = 1.3249473704e-04, /* 0x390aee49 */
+qq5 = -3.9602282413e-06, /* 0xb684e21a */
+/*
+ * Coefficients for approximation to erf in [0.84375,1.25]
+ */
+pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */
+pa1 = 4.1485610604e-01, /* 0x3ed46805 */
+pa2 = -3.7220788002e-01, /* 0xbebe9208 */
+pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */
+pa4 = -1.1089469492e-01, /* 0xbde31cc2 */
+pa5 = 3.5478305072e-02, /* 0x3d1151b3 */
+pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */
+qa1 = 1.0642088205e-01, /* 0x3dd9f331 */
+qa2 = 5.4039794207e-01, /* 0x3f0a5785 */
+qa3 = 7.1828655899e-02, /* 0x3d931ae7 */
+qa4 = 1.2617121637e-01, /* 0x3e013307 */
+qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */
+qa6 = 1.1984500103e-02, /* 0x3c445aa3 */
+/*
+ * Coefficients for approximation to erfc in [1.25,1/0.35]
+ */
+ra0 = -9.8649440333e-03, /* 0xbc21a093 */
+ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */
+ra2 = -1.0558626175e+01, /* 0xc128f022 */
+ra3 = -6.2375331879e+01, /* 0xc2798057 */
+ra4 = -1.6239666748e+02, /* 0xc322658c */
+ra5 = -1.8460508728e+02, /* 0xc3389ae7 */
+ra6 = -8.1287437439e+01, /* 0xc2a2932b */
+ra7 = -9.8143291473e+00, /* 0xc11d077e */
+sa1 = 1.9651271820e+01, /* 0x419d35ce */
+sa2 = 1.3765776062e+02, /* 0x4309a863 */
+sa3 = 4.3456588745e+02, /* 0x43d9486f */
+sa4 = 6.4538726807e+02, /* 0x442158c9 */
+sa5 = 4.2900814819e+02, /* 0x43d6810b */
+sa6 = 1.0863500214e+02, /* 0x42d9451f */
+sa7 = 6.5702495575e+00, /* 0x40d23f7c */
+sa8 = -6.0424413532e-02, /* 0xbd777f97 */
+/*
+ * Coefficients for approximation to erfc in [1/.35,28]
+ */
+rb0 = -9.8649431020e-03, /* 0xbc21a092 */
+rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */
+rb2 = -1.7757955551e+01, /* 0xc18e104b */
+rb3 = -1.6063638306e+02, /* 0xc320a2ea */
+rb4 = -6.3756646729e+02, /* 0xc41f6441 */
+rb5 = -1.0250950928e+03, /* 0xc480230b */
+rb6 = -4.8351919556e+02, /* 0xc3f1c275 */
+sb1 = 3.0338060379e+01, /* 0x41f2b459 */
+sb2 = 3.2579251099e+02, /* 0x43a2e571 */
+sb3 = 1.5367296143e+03, /* 0x44c01759 */
+sb4 = 3.1998581543e+03, /* 0x4547fdbb */
+sb5 = 2.5530502930e+03, /* 0x451f90ce */
+sb6 = 4.7452853394e+02, /* 0x43ed43a7 */
+sb7 = -2.2440952301e+01; /* 0xc1b38712 */
+
+#ifdef __STDC__
+ float erff(float x)
+#else
+ float erff(x)
+ float x;
+#endif
+{
+ __int32_t hx,ix,i;
+ float R,S,P,Q,s,y,z,r;
+ GET_FLOAT_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7f800000) { /* erf(nan)=nan */
+ i = ((__uint32_t)hx>>31)<<1;
+ return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */
+ }
+
+ if(ix < 0x3f580000) { /* |x|<0.84375 */
+ if(ix < 0x31800000) { /* |x|<2**-28 */
+ if (ix < 0x04000000)
+ /*avoid underflow */
+ return (float)0.125*((float)8.0*x+efx8*x);
+ return x + efx*x;
+ }
+ z = x*x;
+ r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
+ s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+ y = r/s;
+ return x + x*y;
+ }
+ if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */
+ s = fabsf(x)-one;
+ P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+ Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ if(hx>=0) return erx + P/Q; else return -erx - P/Q;
+ }
+ if (ix >= 0x40c00000) { /* inf>|x|>=6 */
+ if(hx>=0) return one-tiny; else return tiny-one;
+ }
+ x = fabsf(x);
+ s = one/(x*x);
+ if(ix< 0x4036DB6E) { /* |x| < 1/0.35 */
+ R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
+ ra5+s*(ra6+s*ra7))))));
+ S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
+ sa5+s*(sa6+s*(sa7+s*sa8)))))));
+ } else { /* |x| >= 1/0.35 */
+ R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
+ rb5+s*rb6)))));
+ S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
+ sb5+s*(sb6+s*sb7))))));
+ }
+ GET_FLOAT_WORD(ix,x);
+ SET_FLOAT_WORD(z,ix&0xfffff000);
+ r = expf(-z*z-(float)0.5625)*expf((z-x)*(z+x)+R/S);
+ if(hx>=0) return one-r/x; else return r/x-one;
+}
+
+#ifdef __STDC__
+ float erfcf(float x)
+#else
+ float erfcf(x)
+ float x;
+#endif
+{
+ __int32_t hx,ix;
+ float R,S,P,Q,s,y,z,r;
+ GET_FLOAT_WORD(hx,x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7f800000) { /* erfc(nan)=nan */
+ /* erfc(+-inf)=0,2 */
+ return (float)(((__uint32_t)hx>>31)<<1)+one/x;
+ }
+
+ if(ix < 0x3f580000) { /* |x|<0.84375 */
+ if(ix < 0x23800000) /* |x|<2**-56 */
+ return one-x;
+ z = x*x;
+ r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
+ s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
+ y = r/s;
+ if(hx < 0x3e800000) { /* x<1/4 */
+ return one-(x+x*y);
+ } else {
+ r = x*y;
+ r += (x-half);
+ return half - r ;
+ }
+ }
+ if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */
+ s = fabsf(x)-one;
+ P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+ Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ if(hx>=0) {
+ z = one-erx; return z - P/Q;
+ } else {
+ z = erx+P/Q; return one+z;
+ }
+ }
+ if (ix < 0x41e00000) { /* |x|<28 */
+ x = fabsf(x);
+ s = one/(x*x);
+ if(ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/
+ R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
+ ra5+s*(ra6+s*ra7))))));
+ S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
+ sa5+s*(sa6+s*(sa7+s*sa8)))))));
+ } else { /* |x| >= 1/.35 ~ 2.857143 */
+ if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */
+ R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
+ rb5+s*rb6)))));
+ S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
+ sb5+s*(sb6+s*sb7))))));
+ }
+ GET_FLOAT_WORD(ix,x);
+ SET_FLOAT_WORD(z,ix&0xfffff000);
+ r = expf(-z*z-(float)0.5625)*
+ expf((z-x)*(z+x)+R/S);
+ if(hx>0) return r/x; else return two-r/x;
+ } else {
+ if(hx>0) return tiny*tiny; else return two-tiny;
+ }
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+ double erf(double x)
+#else
+ double erf(x)
+ double x;
+#endif
+{
+ return (double) erff((float) x);
+}
+
+#ifdef __STDC__
+ double erfc(double x)
+#else
+ double erfc(x)
+ double x;
+#endif
+{
+ return (double) erfcf((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_exp.c b/newlib/libm/mathfp/sf_exp.c
new file mode 100644
index 000000000..45d9c31fc
--- /dev/null
+++ b/newlib/libm/mathfp/sf_exp.c
@@ -0,0 +1,92 @@
+
+/* @(#)z_expf.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+/******************************************************************
+ * Exponential Function
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * e raised to x.
+ *
+ * Description:
+ * This routine returns e raised to the xth power.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float INV_LN2 = 1.442695040;
+static const float LN2 = 0.693147180;
+static const float p[] = { 0.249999999950, 0.00416028863 };
+static const float q[] = { 0.5, 0.04998717878 };
+
+float
+_DEFUN (expf, (float),
+ float x)
+{
+ int N;
+ float g, z, R, P, Q;
+
+ switch (numtestf (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = ERANGE;
+ if (isposf (x))
+ return (z_infinity_f.f);
+ else
+ return (0.0);
+ case 0:
+ return (1.0);
+ }
+
+ /* Check for out of bounds. */
+ if (x > BIGX || x < SMALLX)
+ {
+ errno = ERANGE;
+ return (x);
+ }
+
+ /* Check for a value too small to calculate. */
+ if (-z_rooteps_f < x && x < z_rooteps_f)
+ {
+ return (1.0);
+ }
+
+ /* Calculate the exponent. */
+ if (x < 0.0)
+ N = (int) (x * INV_LN2 - 0.5);
+ else
+ N = (int) (x * INV_LN2 + 0.5);
+
+ /* Construct the mantissa. */
+ g = x - N * LN2;
+ z = g * g;
+ P = g * (p[1] * z + p[0]);
+ Q = q[1] * z + q[0];
+ R = 0.5 + P / (Q - P);
+
+ /* Return the floating point value. */
+ N++;
+ return (ldexpf (R, N));
+}
+
+#ifdef _DOUBLE_IS_32_BITS
+
+double exp (double x)
+{
+ return (double) expf ((float) x);
+}
+
+#endif /* _DOUBLE_IS_32_BITS */
diff --git a/newlib/libm/mathfp/sf_fabs.c b/newlib/libm/mathfp/sf_fabs.c
new file mode 100644
index 000000000..2661eabc0
--- /dev/null
+++ b/newlib/libm/mathfp/sf_fabs.c
@@ -0,0 +1,45 @@
+
+/* @(#)z_fabsf.c 1.0 98/08/13 */
+/******************************************************************
+ * Floating-Point Absolute Value
+ *
+ * Input:
+ * x - floating-point number
+ *
+ * Output:
+ * absolute value of x
+ *
+ * Description:
+ * fabs computes the absolute value of a floating point number.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (fabsf, (float),
+ float x)
+{
+ switch (numtestf (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = ERANGE;
+ return (x);
+ case 0:
+ return (0.0);
+ default:
+ return (x < 0.0 ? -x : x);
+ }
+}
+
+#ifdef _DOUBLE_IS_32BITS
+double fabs (double x)
+{
+ return (double) fabsf ((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_floor.c b/newlib/libm/mathfp/sf_floor.c
new file mode 100644
index 000000000..1e0fb9e44
--- /dev/null
+++ b/newlib/libm/mathfp/sf_floor.c
@@ -0,0 +1,43 @@
+
+/* @(#)z_floorf.c 1.0 98/08/13 */
+/*****************************************************************
+ * floor
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * Smallest integer less than x.
+ *
+ * Description:
+ * This routine returns the smallest integer less than x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (floorf, (float),
+ float x)
+{
+ float f, y;
+
+ if (x > -1.0 && x < 1.0)
+ return (x >= 0 ? 0 : -1.0);
+
+ y = modff (x, &f);
+
+ if (y == 0.0)
+ return (x);
+
+ return (x >= 0 ? f : f - 1.0);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+double floor (double x)
+{
+ return (double) floorf ((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_fmod.c b/newlib/libm/mathfp/sf_fmod.c
new file mode 100644
index 000000000..0ac86bbef
--- /dev/null
+++ b/newlib/libm/mathfp/sf_fmod.c
@@ -0,0 +1,103 @@
+/* ef_fmod.c -- float version of e_fmod.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * fmodf(x,y)
+ * Return x mod y in exact arithmetic
+ * Method: shift and subtract
+ */
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float one = 1.0, Zero[] = {0.0, -0.0,};
+
+float
+_DEFUN (fmodf, (float, float),
+ float x _AND
+ float y)
+{
+ __int32_t n,hx,hy,hz,ix,iy,sx,i;
+
+ GET_FLOAT_WORD(hx,x);
+ GET_FLOAT_WORD(hy,y);
+ sx = hx&0x80000000; /* sign of x */
+ hx ^=sx; /* |x| */
+ hy &= 0x7fffffff; /* |y| */
+
+ /* purge off exception values */
+ if(hy==0||(hx>=0x7f800000)|| /* y=0,or x not finite */
+ (hy>0x7f800000)) /* or y is NaN */
+ return (x*y)/(x*y);
+ if(hx<hy) return x; /* |x|<|y| return x */
+ if(hx==hy)
+ return Zero[(__uint32_t)sx>>31]; /* |x|=|y| return x*0*/
+
+ /* determine ix = ilogb(x) */
+ if(hx<0x00800000) { /* subnormal x */
+ for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1;
+ } else ix = (hx>>23)-127;
+
+ /* determine iy = ilogb(y) */
+ if(hy<0x00800000) { /* subnormal y */
+ for (iy = -126,i=(hy<<8); i>=0; i<<=1) iy -=1;
+ } else iy = (hy>>23)-127;
+
+ /* set up {hx,lx}, {hy,ly} and align y to x */
+ if(ix >= -126)
+ hx = 0x00800000|(0x007fffff&hx);
+ else { /* subnormal x, shift x to normal */
+ n = -126-ix;
+ hx = hx<<n;
+ }
+ if(iy >= -126)
+ hy = 0x00800000|(0x007fffff&hy);
+ else { /* subnormal y, shift y to normal */
+ n = -126-iy;
+ hy = hy<<n;
+ }
+
+ /* fix point fmod */
+ n = ix - iy;
+ while(n--) {
+ hz=hx-hy;
+ if(hz<0){hx = hx+hx;}
+ else {
+ if(hz==0) /* return sign(x)*0 */
+ return Zero[(__uint32_t)sx>>31];
+ hx = hz+hz;
+ }
+ }
+ hz=hx-hy;
+ if(hz>=0) {hx=hz;}
+
+ /* convert back to floating value and restore the sign */
+ if(hx==0) /* return sign(x)*0 */
+ return Zero[(__uint32_t)sx>>31];
+ while(hx<0x00800000) { /* normalize x */
+ hx = hx+hx;
+ iy -= 1;
+ }
+ if(iy>= -126) { /* normalize output */
+ hx = ((hx-0x00800000)|((iy+127)<<23));
+ SET_FLOAT_WORD(x,hx|sx);
+ } else { /* subnormal output */
+ n = -126 - iy;
+ hx >>= n;
+ SET_FLOAT_WORD(x,hx|sx);
+ x *= one; /* create necessary signal */
+ }
+ return x; /* exact output */
+}
diff --git a/newlib/libm/mathfp/sf_frexp.c b/newlib/libm/mathfp/sf_frexp.c
new file mode 100644
index 000000000..c2751f65c
--- /dev/null
+++ b/newlib/libm/mathfp/sf_frexp.c
@@ -0,0 +1,58 @@
+
+/* @(#)z_frexpf.c 1.0 98/08/13 */
+/******************************************************************
+ * frexp
+ *
+ * Input:
+ * d - floating point value
+ * exp - exponent value
+ *
+ * Output:
+ * A floating point value in the range [0.5, 1).
+ *
+ * Description:
+ * This routine breaks a floating point value into a number f and
+ * an exponent exp such that d = f * 2 ^ exp.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float frexpf (float d, int *exp)
+{
+ float f;
+ __int32_t wf, wd;
+
+ GET_FLOAT_WORD (wd, d);
+
+ /* Get the exponent. */
+ *exp = ((wd & 0x7f800000) >> 23) - 126;
+
+ /* Get the mantissa. */
+ wf = wd & 0x7fffff;
+ wf |= 0x3f000000;
+
+ SET_FLOAT_WORD (f, wf);
+
+ /* Check for special values. */
+ switch (numtestf (f))
+ {
+ case NAN:
+ case INF:
+ errno = EDOM;
+ *exp = 0;
+ return (f);
+ }
+
+ return (f);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double frexp (double x, int *exp)
+{
+ return (double) frexpf ((float) x, exp);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_isinf.c b/newlib/libm/mathfp/sf_isinf.c
new file mode 100644
index 000000000..5d537607a
--- /dev/null
+++ b/newlib/libm/mathfp/sf_isinf.c
@@ -0,0 +1,33 @@
+
+/* @(#)z_isinff.c 1.0 98/08/13 */
+/******************************************************************
+ * isinff
+ *
+ * Input:
+ * x - pointer to a floating point value
+ *
+ * Output:
+ * An integer that indicates if the number is infinite.
+ *
+ * Description:
+ * This routine returns an integer that indicates if the number
+ * passed in is infinite (1) or is finite (0).
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+int isinff (float x)
+{
+ __uint32_t wx;
+ int exp;
+
+ GET_FLOAT_WORD (wx, x);
+ exp = (wx & 0x7f800000) >> 23;
+
+ if ((exp == 0x7f8) && !(wx & 0xf0000))
+ return (1);
+ else
+ return (0);
+}
diff --git a/newlib/libm/mathfp/sf_isnan.c b/newlib/libm/mathfp/sf_isnan.c
new file mode 100644
index 000000000..3dcdbf452
--- /dev/null
+++ b/newlib/libm/mathfp/sf_isnan.c
@@ -0,0 +1,33 @@
+
+/* @(#)z_isnanf.c 1.0 98/08/13 */
+/******************************************************************
+ * isnanf
+ *
+ * Input:
+ * x - pointer to a floating point value
+ *
+ * Output:
+ * An integer that indicates if the number is NaN.
+ *
+ * Description:
+ * This routine returns an integer that indicates if the number
+ * passed in is NaN (1) or is finite (0).
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+int isnanf (float x)
+{
+ __int32_t wx;
+ int exp;
+
+ GET_FLOAT_WORD (wx, x);
+ exp = (wx & 0x7f800000) >> 23;
+
+ if ((exp == 0x7f8) && (wx & 0x7fffff))
+ return (1);
+ else
+ return (0);
+}
diff --git a/newlib/libm/mathfp/sf_ispos.c b/newlib/libm/mathfp/sf_ispos.c
new file mode 100644
index 000000000..1b91f399f
--- /dev/null
+++ b/newlib/libm/mathfp/sf_ispos.c
@@ -0,0 +1,40 @@
+
+/* @(#)z_isposf.c 1.0 98/08/13 */
+/******************************************************************
+ * Positive value test
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * An integer that indicates if the number is positive.
+ *
+ * Description:
+ * This routine returns an integer that indicates if the number
+ * passed in is positive (1) or negative (0).
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+int isposf (float x)
+{
+ __int32_t wx;
+
+ GET_FLOAT_WORD (wx, x);
+
+ if (wx & 0x80000000)
+ return (0);
+ else
+ return (1);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+int ispos (double x)
+{
+ return isposf ((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_ldexp.c b/newlib/libm/mathfp/sf_ldexp.c
new file mode 100644
index 000000000..6b6c2c00b
--- /dev/null
+++ b/newlib/libm/mathfp/sf_ldexp.c
@@ -0,0 +1,81 @@
+
+/* @(#)z_ldexpf.c 1.0 98/08/13 */
+/******************************************************************
+ * ldexp
+ *
+ * Input:
+ * d - a floating point value
+ * e - an exponent value
+ *
+ * Output:
+ * A floating point value f such that f = d * 2 ^ e.
+ *
+ * Description:
+ * This function creates a floating point number f such that
+ * f = d * 2 ^ e.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+#define FLOAT_EXP_OFFS 127
+
+float
+_DEFUN (ldexpf, (float, int),
+ float d _AND
+ int e)
+{
+ int exp;
+ __int32_t wd;
+
+ GET_FLOAT_WORD (wd, d);
+
+ /* Check for special values and then scale d by e. */
+ switch (numtestf (wd))
+ {
+ case NAN:
+ errno = EDOM;
+ break;
+
+ case INF:
+ errno = ERANGE;
+ break;
+
+ case 0:
+ break;
+
+ default:
+ exp = (wd & 0x7f800000) >> 23;
+ exp += e;
+
+ if (exp > FLT_MAX_EXP + FLOAT_EXP_OFFS)
+ {
+ errno = ERANGE;
+ d = z_infinity_f.f;
+ }
+ else if (exp < FLT_MIN_EXP + FLOAT_EXP_OFFS)
+ {
+ errno = ERANGE;
+ d = -z_infinity_f.f;
+ }
+ else
+ {
+ wd &= 0x807fffff;
+ wd |= exp << 23;
+ SET_FLOAT_WORD (d, wd);
+ }
+ }
+
+ return (d);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double ldexp (double x, int e)
+{
+ return (double) ldexpf ((float) x, e);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_log.c b/newlib/libm/mathfp/sf_log.c
new file mode 100644
index 000000000..b746d444f
--- /dev/null
+++ b/newlib/libm/mathfp/sf_log.c
@@ -0,0 +1,34 @@
+
+/* @(#)z_logf.c 1.0 98/08/13 */
+/******************************************************************
+ * Logarithm
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * natural logarithm of x
+ *
+ * Description:
+ * This routine returns the natural logarithm of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (logf, (float),
+ float x)
+{
+ return (logarithmf (x, 0));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double log (double x)
+{
+ return (double) logf ((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_log10.c b/newlib/libm/mathfp/sf_log10.c
new file mode 100644
index 000000000..444e535e0
--- /dev/null
+++ b/newlib/libm/mathfp/sf_log10.c
@@ -0,0 +1,34 @@
+
+/* @(#)z_log10f.c 1.0 98/08/13 */
+/******************************************************************
+ * Logarithm
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * logarithm of x
+ *
+ * Description:
+ * This routine returns the logarithm of x (base 10).
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (log10f, (float),
+ float x)
+{
+ return (logarithmf (x, 1));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double log10 (double x)
+{
+ return (double) log10f ((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_logarithm.c b/newlib/libm/mathfp/sf_logarithm.c
new file mode 100644
index 000000000..224482f13
--- /dev/null
+++ b/newlib/libm/mathfp/sf_logarithm.c
@@ -0,0 +1,72 @@
+
+/* @(#)z_logarithmf.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+/******************************************************************
+ * Logarithm
+ *
+ * Input:
+ * x - floating point value
+ * ten - indicates base ten numbers
+ *
+ * Output:
+ * logarithm of x
+ *
+ * Description:
+ * This routine calculates logarithms.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float a[] = { -0.5527074855 };
+static const float b[] = { -0.6632718214e+1 };
+static const float C1 = 0.693145752;
+static const float C2 = 1.428606820e-06;
+static const float C3 = 0.4342944819;
+
+float
+_DEFUN (logarithmf, (float, int),
+ float x _AND
+ int ten)
+{
+ int N;
+ float f, w, z;
+
+ /* Check for domain error here. */
+ if (x <= 0.0)
+ {
+ errno = ERANGE;
+ return (z_notanum_f.f);
+ }
+
+ /* Get the exponent and mantissa where x = f * 2^N. */
+ f = frexpf (x, &N);
+
+ z = f - 0.5;
+
+ if (f > __SQRT_HALF)
+ z = (z - 0.5) / (f * 0.5 + 0.5);
+ else
+ {
+ N--;
+ z /= (z * 0.5 + 0.5);
+ }
+ w = z * z;
+
+ /* Use Newton's method with 4 terms. */
+ z += z * w * (a[0]) / ((w + 1.0) * w + b[0]);
+
+ if (N != 0)
+ z = (N * C2 + z) + N * C1;
+
+ if (ten)
+ z *= C3;
+
+ return (z);
+}
diff --git a/newlib/libm/mathfp/sf_numtest.c b/newlib/libm/mathfp/sf_numtest.c
new file mode 100644
index 000000000..675086c41
--- /dev/null
+++ b/newlib/libm/mathfp/sf_numtest.c
@@ -0,0 +1,63 @@
+
+/* @(#)z_numtestf.c 1.0 98/08/13 */
+/******************************************************************
+ * Numtest
+ *
+ * Input:
+ * x - pointer to a floating point value
+ *
+ * Output:
+ * An integer that indicates what kind of number was passed in:
+ * NUM = 3 - a finite value
+ * NAN = 2 - not a number
+ * INF = 1 - an infinite value
+ * 0 - zero
+ *
+ * Description:
+ * This routine returns an integer that indicates the character-
+ * istics of the number that was passed in.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+int
+_DEFUN (numtestf, (float),
+ float x)
+{
+ __int32_t wx;
+ int exp;
+
+ GET_FLOAT_WORD (wx, x);
+
+ exp = (wx & 0x7f800000) >> 23;
+
+ /* Check for a zero input. */
+ if (x == 0.0)
+ {
+ return (0);
+ }
+
+ /* Check for not a number or infinity. */
+ if (exp == 0x7f8)
+ {
+ if(wx & 0x7fffff)
+ return (NAN);
+ else
+ return (INF);
+ }
+
+ /* Otherwise it's a finite value. */
+ else
+ return (NUM);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+int numtest (double x)
+{
+ return numtestf ((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_pow.c b/newlib/libm/mathfp/sf_pow.c
new file mode 100644
index 000000000..2b3bed3c7
--- /dev/null
+++ b/newlib/libm/mathfp/sf_pow.c
@@ -0,0 +1,107 @@
+
+/* @(#)z_powf.c 1.0 98/08/13 */
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+float powf (float x, float y)
+{
+ float d, t, r = 1.0;
+ int n, k, sign = 0;
+ __int32_t px;
+
+ GET_FLOAT_WORD (px, x);
+
+ k = modff (y, &d);
+ if (k == 0.0)
+ {
+ if (modff (ldexpf (y, -1), &t))
+ sign = 0;
+ else
+ sign = 1;
+ }
+
+ if (x == 0.0 && y <= 0.0)
+ errno = EDOM;
+
+ else if ((t = y * log (fabsf (x))) >= BIGX)
+ {
+ errno = ERANGE;
+ if (px & 0x80000000)
+ {
+ if (!k)
+ {
+ errno = EDOM;
+ x = 0.0;
+ }
+ else if (sign)
+ x = -z_infinity_f.f;
+ else
+ x = z_infinity_f.f;
+ }
+
+ else
+ x = z_infinity_f.f;
+ }
+
+ else if (t < SMALLX)
+ {
+ errno = ERANGE;
+ x = 0.0;
+ }
+
+ else
+ {
+ if ( k && fabsf (d) <= 32767 )
+ {
+ n = (int) d;
+
+ if (sign = (n < 0))
+ n = -n;
+
+ while ( n > 0 )
+ {
+ if ((unsigned int) n % 2)
+ r *= x;
+ x *= x;
+ n = (unsigned int) n / 2;
+ }
+
+ if (sign)
+ r = 1.0 / r;
+
+ return r;
+ }
+
+ else
+ {
+ if ( px & 0x80000000 )
+ {
+ if ( !k )
+ {
+ errno = EDOM;
+ return 0.0;
+ }
+ }
+
+ x = exp (t);
+
+ if ( sign )
+ {
+ px ^= 0x80000000;
+ SET_FLOAT_WORD (x, px);
+ }
+ }
+ }
+
+ return x;
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double pow (double x, double y)
+{
+ return (double) powf ((float) x, (float) y);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_signif.c b/newlib/libm/mathfp/sf_signif.c
new file mode 100644
index 000000000..35427f947
--- /dev/null
+++ b/newlib/libm/mathfp/sf_signif.c
@@ -0,0 +1,40 @@
+/* sf_signif.c -- float version of s_signif.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ float significandf(float x)
+#else
+ float significandf(x)
+ float x;
+#endif
+{
+ return scalbf(x,(float) -ilogbf(x));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+ double significand(double x)
+#else
+ double significand(x)
+ double x;
+#endif
+{
+ return (double) significandf((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_sin.c b/newlib/libm/mathfp/sf_sin.c
new file mode 100644
index 000000000..c68e18e50
--- /dev/null
+++ b/newlib/libm/mathfp/sf_sin.c
@@ -0,0 +1,34 @@
+
+/* @(#)z_sinf.c 1.0 98/08/13 */
+/******************************************************************
+ * Sine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * sine of x
+ *
+ * Description:
+ * This routine returns the sine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (sinf, (float),
+ float x)
+{
+ return (sinef (x, 0));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double sin (double x)
+{
+ return (double) sinef ((float) x, 0);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/sf_sine.c b/newlib/libm/mathfp/sf_sine.c
new file mode 100644
index 000000000..6932de26c
--- /dev/null
+++ b/newlib/libm/mathfp/sf_sine.c
@@ -0,0 +1,112 @@
+
+/* @(#)z_sinef.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+/******************************************************************
+ * sine generator
+ *
+ * Input:
+ * x - floating point value
+ * cosine - indicates cosine value
+ *
+ * Output:
+ * Sine of x.
+ *
+ * Description:
+ * This routine calculates sines and cosines.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float HALF_PI = 1.570796326;
+static const float ONE_OVER_PI = 0.318309886;
+static const float r[] = { -0.1666665668,
+ 0.8333025139e-02,
+ -0.1980741872e-03,
+ 0.2601903036e-5 };
+
+float
+_DEFUN (sinef, (float, int),
+ float x _AND
+ int cosine)
+{
+ int sgn, N;
+ float y, XN, g, R, res;
+ float YMAX = 210828714.0;
+
+ switch (numtestf (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = EDOM;
+ return (z_notanum_f.f);
+ }
+
+ /* Use sin and cos properties to ease computations. */
+ if (cosine)
+ {
+ sgn = 1;
+ y = fabsf (x) + HALF_PI;
+ }
+ else
+ {
+ if (x < 0.0)
+ {
+ sgn = -1;
+ y = -x;
+ }
+ else
+ {
+ sgn = 1;
+ y = x;
+ }
+ }
+
+ /* Check for values of y that will overflow here. */
+ if (y > YMAX)
+ {
+ errno = ERANGE;
+ return (x);
+ }
+
+ /* Calculate the exponent. */
+ if (y < 0.0)
+ N = (int) (y * ONE_OVER_PI - 0.5);
+ else
+ N = (int) (y * ONE_OVER_PI + 0.5);
+ XN = (float) N;
+
+ if (N & 1)
+ sgn = -sgn;
+
+ if (cosine)
+ XN -= 0.5;
+
+ y = fabsf (x) - XN * __PI;
+
+ if (-z_rooteps_f < y && y < z_rooteps_f)
+ res = y;
+
+ else
+ {
+ g = y * y;
+
+ /* Calculate the Taylor series. */
+ R = (((r[3] * g + r[2]) * g + r[1]) * g + r[0]) * g;
+
+ /* Finally, compute the result. */
+ res = y + y * R;
+ }
+
+ res *= sgn;
+
+ return (res);
+}
diff --git a/newlib/libm/mathfp/sf_sineh.c b/newlib/libm/mathfp/sf_sineh.c
new file mode 100644
index 000000000..4eee2c927
--- /dev/null
+++ b/newlib/libm/mathfp/sf_sineh.c
@@ -0,0 +1,110 @@
+
+/* @(#)z_sinehf.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+/******************************************************************
+ * Hyperbolic Sine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * hyperbolic sine of x
+ *
+ * Description:
+ * This routine calculates hyperbolic sines.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float q[] = { -0.428277109e+2 };
+static const float p[] = { -0.713793159e+1,
+ -0.190333399 };
+static const float LNV = 0.6931610107;
+static const float INV_V2 = 0.2499930850;
+static const float V_OVER2_MINUS1 = 0.1383027787e-4;
+
+float
+_DEFUN (sinehf, (float, int),
+ float x _AND
+ int cosineh)
+{
+ float y, f, P, Q, R, res, z, w;
+ int sgn = 1;
+ float WBAR = 18.55;
+
+ /* Check for special values. */
+ switch (numtestf (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = ERANGE;
+ return (ispos (x) ? z_infinity_f.f : -z_infinity_f.f);
+ }
+
+ y = fabs (x);
+
+ if (!cosineh && x < 0.0)
+ sgn = -1;
+
+ if ((y > 1.0 && !cosineh) || cosineh)
+ {
+ if (y > BIGX)
+ {
+ w = y - LNV;
+
+ /* Check for w > maximum here. */
+ if (w > BIGX)
+ {
+ errno = ERANGE;
+ return (x);
+ }
+
+ z = exp (w);
+
+ if (w > WBAR)
+ res = z * (V_OVER2_MINUS1 + 1.0);
+ }
+
+ else
+ {
+ z = exp (y);
+ if (cosineh)
+ res = (z + 1 / z) / 2.0;
+ else
+ res = (z - 1 / z) / 2.0;
+ }
+
+ if (sgn < 0)
+ res = -res;
+ }
+ else
+ {
+ /* Check for y being too small. */
+ if (y < z_rooteps_f)
+ {
+ res = x;
+ }
+ /* Calculate the Taylor series. */
+ else
+ {
+ f = x * x;
+ Q = f + q[0];
+ P = p[1] * f + p[0];
+ R = f * (P / Q);
+
+ res = x + x * R;
+ }
+ }
+
+ return (res);
+}
diff --git a/newlib/libm/mathfp/sf_sinh.c b/newlib/libm/mathfp/sf_sinh.c
new file mode 100644
index 000000000..a50e56606
--- /dev/null
+++ b/newlib/libm/mathfp/sf_sinh.c
@@ -0,0 +1,34 @@
+
+/* @(#)z_sinhf.c 1.0 98/08/13 */
+/******************************************************************
+ * Hyperbolic Sine
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * hyperbolic sine of x
+ *
+ * Description:
+ * This routine returns the hyperbolic sine of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (sinhf, (float),
+ float x)
+{
+ return (sinehf (x, 0));
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double sinh (double x)
+{
+ return (double) sinhf ((float) x);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/sf_sqrt.c b/newlib/libm/mathfp/sf_sqrt.c
new file mode 100644
index 000000000..04fa07f6a
--- /dev/null
+++ b/newlib/libm/mathfp/sf_sqrt.c
@@ -0,0 +1,100 @@
+
+/* @(#)z_sqrtf.c 1.0 98/08/13 */
+/*****************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ *****************************************************************/
+/******************************************************************
+ * Square Root
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * square-root of x
+ *
+ * Description:
+ * This routine performs floating point square root.
+ *
+ * The initial approximation is computed as
+ * y0 = 0.41731 + 0.59016 * f
+ * where f is a fraction such that x = f * 2^exp.
+ *
+ * Three Newton iterations in the form of Heron's formula
+ * are then performed to obtain the final value:
+ * y[i] = (y[i-1] + f / y[i-1]) / 2, i = 1, 2, 3.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+float
+_DEFUN (sqrtf, (float),
+ float x)
+{
+ float f, y;
+ int exp, i, odd;
+
+ /* Check for special values. */
+ switch (numtestf (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ if (isposf (x))
+ {
+ errno = EDOM;
+ return (z_notanum_f.f);
+ }
+ else
+ {
+ errno = ERANGE;
+ return (z_infinity_f.f);
+ }
+ }
+
+ /* Initial checks are performed here. */
+ if (x == 0.0)
+ return (0.0);
+ if (x < 0)
+ {
+ errno = EDOM;
+ return (z_notanum_f.f);
+ }
+
+ /* Find the exponent and mantissa for the form x = f * 2^exp. */
+ f = frexpf (x, &exp);
+ odd = exp & 1;
+
+ /* Get the initial approximation. */
+ y = 0.41731 + 0.59016 * f;
+
+ f *= 0.5;
+ /* Calculate the remaining iterations. */
+ for (i = 0; i < 2; ++i)
+ y = y * 0.5 + f / y;
+
+ /* Calculate the final value. */
+ if (odd)
+ {
+ y *= __SQRT_HALF;
+ exp++;
+ }
+ exp >>= 1;
+ y = ldexpf (y, exp);
+
+ return (y);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double sqrt (double x)
+{
+ return (double) sqrt ((float) x);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/sf_tan.c b/newlib/libm/mathfp/sf_tan.c
new file mode 100644
index 000000000..fcde19ab3
--- /dev/null
+++ b/newlib/libm/mathfp/sf_tan.c
@@ -0,0 +1,104 @@
+
+/* @(#)z_tanf.c 1.0 98/08/13 */
+/******************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ ******************************************************************/
+/******************************************************************
+ * Tangent
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * tangent of x
+ *
+ * Description:
+ * This routine calculates the tangent of x.
+ *
+ *****************************************************************/
+
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float TWO_OVER_PI = 0.6366197723;
+static const float p[] = { -0.958017723e-1 };
+static const float q[] = { -0.429135777,
+ 0.971685835e-2 };
+
+float
+_DEFUN (tanf, (float),
+ float x)
+{
+ float y, f, g, XN, xnum, xden, res;
+ int N;
+
+ /* Check for special values. */
+ switch (numtestf (x))
+ {
+ case NAN:
+ errno = EDOM;
+ return (x);
+ case INF:
+ errno = EDOM;
+ return (z_notanum_f.f);
+ }
+
+ y = fabsf (x);
+
+ /* Check for values that are out of our range. */
+ if (y > 105414357.0)
+ {
+ errno = ERANGE;
+ return (y);
+ }
+
+ if (x < 0.0)
+ N = (int) (x * TWO_OVER_PI - 0.5);
+ else
+ N = (int) (x * TWO_OVER_PI + 0.5);
+
+ XN = (float) N;
+
+ f = x - N * __PI_OVER_TWO;
+
+ /* Check for values that are too small. */
+ if (-z_rooteps_f < f && f < z_rooteps_f)
+ {
+ xnum = f;
+ xden = 1.0;
+ }
+
+ /* Calculate the polynomial. */
+ else
+ {
+ g = f * f;
+
+ xnum = f * (p[0] * g) + f;
+ xden = (q[1] * g + q[0]) * g + 1.0;
+ }
+
+ /* Check for odd or even values. */
+ if (N & 1)
+ {
+ xnum = -xnum;
+ res = xden / xnum;
+ }
+ else
+ {
+ res = xnum / xden;
+ }
+
+ return (res);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double tan (double x)
+{
+ return (double) tanf ((float) x);
+}
+
+#endif /* _DOUBLE_IS_32BITS */
diff --git a/newlib/libm/mathfp/sf_tanh.c b/newlib/libm/mathfp/sf_tanh.c
new file mode 100644
index 000000000..51806af45
--- /dev/null
+++ b/newlib/libm/mathfp/sf_tanh.c
@@ -0,0 +1,77 @@
+
+/* @(#)z_tanhf.c 1.0 98/08/13 */
+/*****************************************************************
+ * The following routines are coded directly from the algorithms
+ * and coefficients given in "Software Manual for the Elementary
+ * Functions" by William J. Cody, Jr. and William Waite, Prentice
+ * Hall, 1980.
+ *****************************************************************/
+/******************************************************************
+ * Hyperbolic Tangent
+ *
+ * Input:
+ * x - floating point value
+ *
+ * Output:
+ * hyperbolic tangent of x
+ *
+ * Description:
+ * This routine calculates hyperbolic tangent.
+ *
+ *****************************************************************/
+
+#include <float.h>
+#include "fdlibm.h"
+#include "zmath.h"
+
+static const float LN3_OVER2 = 0.5493061443;
+static const float p[] = { -0.2059432032,
+ -0.0009577527 };
+static const float q[] = { 0.6178299136,
+ 0.25 };
+
+float
+_DEFUN (tanhf, (float),
+ float x)
+{
+ float f, res, g, P, Q, R;
+
+ f = fabsf (x);
+
+ /* Check if the input is too big. */
+ if (f > BIGX)
+ res = 1.0;
+
+ else if (f > LN3_OVER2)
+ res = 1.0 - 2.0 / (exp (2 * f) + 1.0);
+
+ /* Check if the input is too small. */
+ else if (f < z_rooteps_f)
+ res = f;
+
+ /* Calculate the Taylor series. */
+ else
+ {
+ g = f * f;
+
+ P = p[1] * g + p[0];
+ Q = (g + q[1]) * g + q[0];
+ R = g * (P / Q);
+
+ res = f + f * R;
+ }
+
+ if (x < 0.0)
+ res = -res;
+
+ return (res);
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+double tanh (double x)
+{
+ return (double) tanhf ((float) x);
+}
+
+#endif _DOUBLE_IS_32BITS
diff --git a/newlib/libm/mathfp/w_cabs.c b/newlib/libm/mathfp/w_cabs.c
new file mode 100644
index 000000000..bef76680c
--- /dev/null
+++ b/newlib/libm/mathfp/w_cabs.c
@@ -0,0 +1,20 @@
+/*
+ * cabs() wrapper for hypot().
+ *
+ * Written by J.T. Conklin, <jtc@wimsey.com>
+ * Placed into the Public Domain, 1994.
+ */
+
+#include "fdlibm.h"
+
+struct complex {
+ double x;
+ double y;
+};
+
+double
+cabs(z)
+ struct complex z;
+{
+ return hypot(z.x, z.y);
+}
diff --git a/newlib/libm/mathfp/w_drem.c b/newlib/libm/mathfp/w_drem.c
new file mode 100644
index 000000000..d289bdaac
--- /dev/null
+++ b/newlib/libm/mathfp/w_drem.c
@@ -0,0 +1,15 @@
+/*
+ * drem() wrapper for remainder().
+ *
+ * Written by J.T. Conklin, <jtc@wimsey.com>
+ * Placed into the Public Domain, 1994.
+ */
+
+#include "fdlibm.h"
+
+double
+drem(x, y)
+ double x, y;
+{
+ return remainder(x, y);
+}
diff --git a/newlib/libm/mathfp/w_jn.c b/newlib/libm/mathfp/w_jn.c
new file mode 100644
index 000000000..6806f01d9
--- /dev/null
+++ b/newlib/libm/mathfp/w_jn.c
@@ -0,0 +1,248 @@
+
+/* @(#)w_jn.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+FUNCTION
+<<jN>>,<<jNf>>,<<yN>>,<<yNf>>---Bessel functions
+
+INDEX
+j0
+INDEX
+j0f
+INDEX
+j1
+INDEX
+j1f
+INDEX
+jn
+INDEX
+jnf
+INDEX
+y0
+INDEX
+y0f
+INDEX
+y1
+INDEX
+y1f
+INDEX
+yn
+INDEX
+ynf
+
+ANSI_SYNOPSIS
+#include <math.h>
+double j0(double <[x]>);
+float j0f(float <[x]>);
+double j1(double <[x]>);
+float j1f(float <[x]>);
+double jn(int <[n]>, double <[x]>);
+float jnf(int <[n]>, float <[x]>);
+double y0(double <[x]>);
+float y0f(float <[x]>);
+double y1(double <[x]>);
+float y1f(float <[x]>);
+double yn(int <[n]>, double <[x]>);
+float ynf(int <[n]>, float <[x]>);
+
+TRAD_SYNOPSIS
+#include <math.h>
+
+double j0(<[x]>)
+double <[x]>;
+float j0f(<[x]>)
+float <[x]>;
+double j1(<[x]>)
+double <[x]>;
+float j1f(<[x]>)
+float <[x]>;
+double jn(<[n]>, <[x]>)
+int <[n]>;
+double <[x]>;
+float jnf(<[n]>, <[x]>)
+int <[n]>;
+float <[x]>;
+
+double y0(<[x]>)
+double <[x]>;
+float y0f(<[x]>)
+float <[x]>;
+double y1(<[x]>)
+double <[x]>;
+float y1f(<[x]>)
+float <[x]>;
+double yn(<[n]>, <[x]>)
+int <[n]>;
+double <[x]>;
+float ynf(<[n]>, <[x]>)
+int <[n]>;
+float <[x]>;
+
+DESCRIPTION
+The Bessel functions are a family of functions that solve the
+differential equation
+@ifinfo
+. 2 2 2
+. x y'' + xy' + (x - p )y = 0
+@end ifinfo
+@tex
+$$x^2{d^2y\over dx^2} + x{dy\over dx} + (x^2-p^2)y = 0$$
+@end tex
+These functions have many applications in engineering and physics.
+
+<<jn>> calculates the Bessel function of the first kind of order
+<[n]>. <<j0>> and <<j1>> are special cases for order 0 and order
+1 respectively.
+
+Similarly, <<yn>> calculates the Bessel function of the second kind of
+order <[n]>, and <<y0>> and <<y1>> are special cases for order 0 and
+1.
+
+<<jnf>>, <<j0f>>, <<j1f>>, <<ynf>>, <<y0f>>, and <<y1f>> perform the
+same calculations, but on <<float>> rather than <<double>> values.
+
+RETURNS
+The value of each Bessel function at <[x]> is returned.
+
+PORTABILITY
+None of the Bessel functions are in ANSI C.
+*/
+
+/*
+ * wrapper jn(int n, double x), yn(int n, double x)
+ * floating point Bessel's function of the 1st and 2nd kind
+ * of order n
+ *
+ * Special cases:
+ * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
+ * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
+ * Note 2. About jn(n,x), yn(n,x)
+ * For n=0, j0(x) is called,
+ * for n=1, j1(x) is called,
+ * for n<x, forward recursion us used starting
+ * from values of j0(x) and j1(x).
+ * for n>x, a continued fraction approximation to
+ * j(n,x)/j(n-1,x) is evaluated and then backward
+ * recursion is used starting from a supposed value
+ * for j(n,x). The resulting value of j(0,x) is
+ * compared with the actual value to correct the
+ * supposed value of j(n,x).
+ *
+ * yn(n,x) is similar in all respects, except
+ * that forward recursion is used for all
+ * values of n>1.
+ *
+ */
+
+#include "fdlibm.h"
+#include <errno.h>
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+ double jn(int n, double x) /* wrapper jn */
+#else
+ double jn(n,x) /* wrapper jn */
+ double x; int n;
+#endif
+{
+#ifdef _IEEE_LIBM
+ return jn(n,x);
+#else
+ double z;
+ struct exception exc;
+ z = jn(n,x);
+ if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
+ if(fabs(x)>X_TLOSS) {
+ /* jn(|x|>X_TLOSS) */
+ exc.type = TLOSS;
+ exc.name = "jn";
+ exc.err = 0;
+ exc.arg1 = n;
+ exc.arg2 = x;
+ exc.retval = 0.0;
+ if (_LIB_VERSION == _POSIX_)
+ errno = ERANGE;
+ else if (!matherr(&exc)) {
+ errno = ERANGE;
+ }
+ if (exc.err != 0)
+ errno = exc.err;
+ return exc.retval;
+ } else
+ return z;
+#endif
+}
+
+#ifdef __STDC__
+ double yn(int n, double x) /* wrapper yn */
+#else
+ double yn(n,x) /* wrapper yn */
+ double x; int n;
+#endif
+{
+#ifdef _IEEE_LIBM
+ return yn(n,x);
+#else
+ double z;
+ struct exception exc;
+ z = yn(n,x);
+ if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
+ if(x <= 0.0){
+ /* yn(n,0) = -inf or yn(x<0) = NaN */
+#ifndef HUGE_VAL
+#define HUGE_VAL inf
+ double inf = 0.0;
+
+ SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
+#endif
+ exc.type = DOMAIN; /* should be SING for IEEE */
+ exc.name = "yn";
+ exc.err = 0;
+ exc.arg1 = n;
+ exc.arg2 = x;
+ if (_LIB_VERSION == _SVID_)
+ exc.retval = -HUGE;
+ else
+ exc.retval = -HUGE_VAL;
+ if (_LIB_VERSION == _POSIX_)
+ errno = EDOM;
+ else if (!matherr(&exc)) {
+ errno = EDOM;
+ }
+ if (exc.err != 0)
+ errno = exc.err;
+ return exc.retval;
+ }
+ if(x>X_TLOSS) {
+ /* yn(x>X_TLOSS) */
+ exc.type = TLOSS;
+ exc.name = "yn";
+ exc.err = 0;
+ exc.arg1 = n;
+ exc.arg2 = x;
+ exc.retval = 0.0;
+ if (_LIB_VERSION == _POSIX_)
+ errno = ERANGE;
+ else if (!matherr(&exc)) {
+ errno = ERANGE;
+ }
+ if (exc.err != 0)
+ errno = exc.err;
+ return exc.retval;
+ } else
+ return z;
+#endif
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/wf_cabs.c b/newlib/libm/mathfp/wf_cabs.c
new file mode 100644
index 000000000..c3ed0caa2
--- /dev/null
+++ b/newlib/libm/mathfp/wf_cabs.c
@@ -0,0 +1,20 @@
+/*
+ * cabsf() wrapper for hypotf().
+ *
+ * Written by J.T. Conklin, <jtc@wimsey.com>
+ * Placed into the Public Domain, 1994.
+ */
+
+#include "fdlibm.h"
+
+struct complex {
+ float x;
+ float y;
+};
+
+float
+cabsf(z)
+ struct complex z;
+{
+ return hypotf(z.x, z.y);
+}
diff --git a/newlib/libm/mathfp/wf_drem.c b/newlib/libm/mathfp/wf_drem.c
new file mode 100644
index 000000000..7c3f7c58e
--- /dev/null
+++ b/newlib/libm/mathfp/wf_drem.c
@@ -0,0 +1,19 @@
+/*
+ * dremf() wrapper for remainderf().
+ *
+ * Written by J.T. Conklin, <jtc@wimsey.com>
+ * Placed into the Public Domain, 1994.
+ */
+
+#include "fdlibm.h"
+
+float
+#ifdef __STDC__
+dremf(float x, float y)
+#else
+dremf(x, y)
+ float x, y;
+#endif
+{
+ return remainderf(x, y);
+}
diff --git a/newlib/libm/mathfp/wf_jn.c b/newlib/libm/mathfp/wf_jn.c
new file mode 100644
index 000000000..ebc886de9
--- /dev/null
+++ b/newlib/libm/mathfp/wf_jn.c
@@ -0,0 +1,138 @@
+/* wf_jn.c -- float version of w_jn.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#include "fdlibm.h"
+#include <errno.h>
+
+
+#ifdef __STDC__
+ float jnf(int n, float x) /* wrapper jnf */
+#else
+ float jnf(n,x) /* wrapper jnf */
+ float x; int n;
+#endif
+{
+#ifdef _IEEE_LIBM
+ return jnf(n,x);
+#else
+ float z;
+ struct exception exc;
+ z = jnf(n,x);
+ if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z;
+ if(fabsf(x)>(float)X_TLOSS) {
+ /* jnf(|x|>X_TLOSS) */
+ exc.type = TLOSS;
+ exc.name = "jnf";
+ exc.err = 0;
+ exc.arg1 = (double)n;
+ exc.arg2 = (double)x;
+ exc.retval = 0.0;
+ if (_LIB_VERSION == _POSIX_)
+ errno = ERANGE;
+ else if (!matherr(&exc)) {
+ errno = ERANGE;
+ }
+ if (exc.err != 0)
+ errno = exc.err;
+ return exc.retval;
+ } else
+ return z;
+#endif
+}
+
+#ifdef __STDC__
+ float ynf(int n, float x) /* wrapper ynf */
+#else
+ float ynf(n,x) /* wrapper ynf */
+ float x; int n;
+#endif
+{
+#ifdef _IEEE_LIBM
+ return ynf(n,x);
+#else
+ float z;
+ struct exception exc;
+ z = ynf(n,x);
+ if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z;
+ if(x <= (float)0.0){
+ /* ynf(n,0) = -inf or ynf(x<0) = NaN */
+#ifndef HUGE_VAL
+#define HUGE_VAL inf
+ double inf = 0.0;
+
+ SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
+#endif
+ exc.type = DOMAIN; /* should be SING for IEEE */
+ exc.name = "ynf";
+ exc.err = 0;
+ exc.arg1 = (double)n;
+ exc.arg2 = (double)x;
+ if (_LIB_VERSION == _SVID_)
+ exc.retval = -HUGE;
+ else
+ exc.retval = -HUGE_VAL;
+ if (_LIB_VERSION == _POSIX_)
+ errno = EDOM;
+ else if (!matherr(&exc)) {
+ errno = EDOM;
+ }
+ if (exc.err != 0)
+ errno = exc.err;
+ return (float)exc.retval;
+ }
+ if(x>(float)X_TLOSS) {
+ /* ynf(x>X_TLOSS) */
+ exc.type = TLOSS;
+ exc.name = "ynf";
+ exc.err = 0;
+ exc.arg1 = (double)n;
+ exc.arg2 = (double)x;
+ exc.retval = 0.0;
+ if (_LIB_VERSION == _POSIX_)
+ errno = ERANGE;
+ else if (!matherr(&exc)) {
+ errno = ERANGE;
+ }
+ if (exc.err != 0)
+ errno = exc.err;
+ return (float)exc.retval;
+ } else
+ return z;
+#endif
+}
+
+#ifdef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+ double jn(int n, double x)
+#else
+ double jn(n,x)
+ double x; int n;
+#endif
+{
+ return (double) jnf(n, (float) x);
+}
+
+#ifdef __STDC__
+ double yn(int n, double x)
+#else
+ double yn(n,x)
+ double x; int n;
+#endif
+{
+ return (double) ynf(n, (float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/mathfp/zmath.h b/newlib/libm/mathfp/zmath.h
new file mode 100644
index 000000000..369bfec49
--- /dev/null
+++ b/newlib/libm/mathfp/zmath.h
@@ -0,0 +1,55 @@
+#ifndef __ZMATH_H
+#define __ZMATH_H
+
+#include <errno.h>
+
+#define NUM 3
+#define NAN 2
+#define INF 1
+
+#define __PI 3.14159265358979323846
+#define __SQRT_HALF 0.70710678118654752440
+#define __PI_OVER_TWO 1.57079632679489661923132
+
+extern double BIGX;
+extern double SMALLX;
+
+typedef const union
+{
+ long l[2];
+ double d;
+} udouble;
+
+typedef const union
+{
+ long l;
+ float f;
+} ufloat;
+
+extern double BIGX;
+extern double SMALLX;
+
+extern udouble z_infinity;
+extern udouble z_notanum;
+extern double z_rooteps;
+
+extern ufloat z_infinity_f;
+extern ufloat z_notanum_f;
+extern float z_rooteps_f;
+
+/* Core math routines. */
+
+int _EXFUN (numtest, (double));
+int _EXFUN (numtestf, (float));
+double _EXFUN (logarithm, (double, int));
+float _EXFUN (logarithmf, (float, int));
+double _EXFUN (sine, (double, int));
+float _EXFUN (sinef, (float, int));
+double _EXFUN (asine, (double, int));
+float _EXFUN (asinef, (float, int));
+double _EXFUN (atangent, (double, double, double, int));
+float _EXFUN (atangentf, (float, float, float, int));
+double _EXFUN (sineh, (double, int));
+float _EXFUN (sinehf, (float, int));
+
+#endif /* no __ZMATH_H */