From d3bd3632ac06bdb7f76b13494873b3567edabcbf Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Fri, 16 Aug 2002 21:29:45 +0000 Subject: * libc/sys/linux/cmath: New directory. * libc/sys/linux/include/cmathcalls.h: New file. * libc/sys/linux/include/complex.h: New file. * libc/sys/linux/machine/i386/huge_val.h: New file * libm/math/w_sincos.c: New file * libm/math/wf_sincos.c: New file * libm/mathfp/s_sincos.c: New file * libm/mathfp/sf_sincos.c: New file * Makefile.am (LIBC_OBJECTLISTS): Add cmath/objectlist.awk.in. * libc/include/math.h: Add sincos and sincosf declarations. * libc/sys/linux/Makefile.am (SUBDIRS): Add cmath. (SUBLIBS): Likewise. * libc/sys/linux/configure.in (AC_OUTPUT): Add cmath. * libm/math/Makefile.am (src): Add w_sincos.c. (fsrc): Add wf_sincos.c. * libm/mathfp/Makefile.am (src): Add s_sincos.c (fsrc): Add sf_sincos.c. --- newlib/libc/sys/linux/Makefile.am | 2 + newlib/libc/sys/linux/Makefile.in | 2 + newlib/libc/sys/linux/cmath/Makefile.am | 28 ++ newlib/libc/sys/linux/cmath/Makefile.in | 390 ++++++++++++++++++++++++++ newlib/libc/sys/linux/cmath/math_private.h | 354 +++++++++++++++++++++++ newlib/libc/sys/linux/cmath/s_cacos.c | 42 +++ newlib/libc/sys/linux/cmath/s_cacosf.c | 38 +++ newlib/libc/sys/linux/cmath/s_cacosh.c | 88 ++++++ newlib/libc/sys/linux/cmath/s_cacoshf.c | 98 +++++++ newlib/libc/sys/linux/cmath/s_cacoshl.c | 84 ++++++ newlib/libc/sys/linux/cmath/s_cacosl.c | 38 +++ newlib/libc/sys/linux/cmath/s_casin.c | 66 +++++ newlib/libc/sys/linux/cmath/s_casinf.c | 63 +++++ newlib/libc/sys/linux/cmath/s_casinh.c | 84 ++++++ newlib/libc/sys/linux/cmath/s_casinhf.c | 80 ++++++ newlib/libc/sys/linux/cmath/s_casinhl.c | 80 ++++++ newlib/libc/sys/linux/cmath/s_casinl.c | 62 ++++ newlib/libc/sys/linux/cmath/s_catan.c | 89 ++++++ newlib/libc/sys/linux/cmath/s_catanf.c | 85 ++++++ newlib/libc/sys/linux/cmath/s_catanh.c | 84 ++++++ newlib/libc/sys/linux/cmath/s_catanhf.c | 80 ++++++ newlib/libc/sys/linux/cmath/s_catanhl.c | 80 ++++++ newlib/libc/sys/linux/cmath/s_catanl.c | 85 ++++++ newlib/libc/sys/linux/cmath/s_cbrtl.c | 15 + newlib/libc/sys/linux/cmath/s_ccos.c | 80 ++++++ newlib/libc/sys/linux/cmath/s_ccosf.c | 76 +++++ newlib/libc/sys/linux/cmath/s_ccosh.c | 105 +++++++ newlib/libc/sys/linux/cmath/s_ccoshf.c | 101 +++++++ newlib/libc/sys/linux/cmath/s_ccoshl.c | 101 +++++++ newlib/libc/sys/linux/cmath/s_ccosl.c | 76 +++++ newlib/libc/sys/linux/cmath/s_cexp.c | 127 +++++++++ newlib/libc/sys/linux/cmath/s_cexpf.c | 123 ++++++++ newlib/libc/sys/linux/cmath/s_cexpl.c | 123 ++++++++ newlib/libc/sys/linux/cmath/s_clog.c | 65 +++++ newlib/libc/sys/linux/cmath/s_clog10.c | 65 +++++ newlib/libc/sys/linux/cmath/s_clog10f.c | 61 ++++ newlib/libc/sys/linux/cmath/s_clog10l.c | 61 ++++ newlib/libc/sys/linux/cmath/s_clogf.c | 61 ++++ newlib/libc/sys/linux/cmath/s_clogl.c | 61 ++++ newlib/libc/sys/linux/cmath/s_cpow.c | 34 +++ newlib/libc/sys/linux/cmath/s_cpowf.c | 30 ++ newlib/libc/sys/linux/cmath/s_cpowl.c | 30 ++ newlib/libc/sys/linux/cmath/s_cproj.c | 51 ++++ newlib/libc/sys/linux/cmath/s_cprojf.c | 47 ++++ newlib/libc/sys/linux/cmath/s_cprojl.c | 48 ++++ newlib/libc/sys/linux/cmath/s_csin.c | 131 +++++++++ newlib/libc/sys/linux/cmath/s_csinf.c | 127 +++++++++ newlib/libc/sys/linux/cmath/s_csinh.c | 126 +++++++++ newlib/libc/sys/linux/cmath/s_csinhf.c | 122 ++++++++ newlib/libc/sys/linux/cmath/s_csinhl.c | 122 ++++++++ newlib/libc/sys/linux/cmath/s_csinl.c | 127 +++++++++ newlib/libc/sys/linux/cmath/s_csqrt.c | 114 ++++++++ newlib/libc/sys/linux/cmath/s_csqrtf.c | 110 ++++++++ newlib/libc/sys/linux/cmath/s_csqrtl.c | 110 ++++++++ newlib/libc/sys/linux/cmath/s_ctan.c | 74 +++++ newlib/libc/sys/linux/cmath/s_ctanf.c | 70 +++++ newlib/libc/sys/linux/cmath/s_ctanh.c | 74 +++++ newlib/libc/sys/linux/cmath/s_ctanhf.c | 70 +++++ newlib/libc/sys/linux/cmath/s_ctanhl.c | 70 +++++ newlib/libc/sys/linux/cmath/s_ctanl.c | 70 +++++ newlib/libc/sys/linux/configure | 4 +- newlib/libc/sys/linux/configure.in | 2 +- newlib/libc/sys/linux/include/cmathcalls.h | 158 +++++++++++ newlib/libc/sys/linux/include/complex.h | 108 +++++++ newlib/libc/sys/linux/machine/i386/huge_val.h | 56 ++++ 65 files changed, 5485 insertions(+), 3 deletions(-) create mode 100644 newlib/libc/sys/linux/cmath/Makefile.am create mode 100644 newlib/libc/sys/linux/cmath/Makefile.in create mode 100644 newlib/libc/sys/linux/cmath/math_private.h create mode 100644 newlib/libc/sys/linux/cmath/s_cacos.c create mode 100644 newlib/libc/sys/linux/cmath/s_cacosf.c create mode 100644 newlib/libc/sys/linux/cmath/s_cacosh.c create mode 100644 newlib/libc/sys/linux/cmath/s_cacoshf.c create mode 100644 newlib/libc/sys/linux/cmath/s_cacoshl.c create mode 100644 newlib/libc/sys/linux/cmath/s_cacosl.c create mode 100644 newlib/libc/sys/linux/cmath/s_casin.c create mode 100644 newlib/libc/sys/linux/cmath/s_casinf.c create mode 100644 newlib/libc/sys/linux/cmath/s_casinh.c create mode 100644 newlib/libc/sys/linux/cmath/s_casinhf.c create mode 100644 newlib/libc/sys/linux/cmath/s_casinhl.c create mode 100644 newlib/libc/sys/linux/cmath/s_casinl.c create mode 100644 newlib/libc/sys/linux/cmath/s_catan.c create mode 100644 newlib/libc/sys/linux/cmath/s_catanf.c create mode 100644 newlib/libc/sys/linux/cmath/s_catanh.c create mode 100644 newlib/libc/sys/linux/cmath/s_catanhf.c create mode 100644 newlib/libc/sys/linux/cmath/s_catanhl.c create mode 100644 newlib/libc/sys/linux/cmath/s_catanl.c create mode 100644 newlib/libc/sys/linux/cmath/s_cbrtl.c create mode 100644 newlib/libc/sys/linux/cmath/s_ccos.c create mode 100644 newlib/libc/sys/linux/cmath/s_ccosf.c create mode 100644 newlib/libc/sys/linux/cmath/s_ccosh.c create mode 100644 newlib/libc/sys/linux/cmath/s_ccoshf.c create mode 100644 newlib/libc/sys/linux/cmath/s_ccoshl.c create mode 100644 newlib/libc/sys/linux/cmath/s_ccosl.c create mode 100644 newlib/libc/sys/linux/cmath/s_cexp.c create mode 100644 newlib/libc/sys/linux/cmath/s_cexpf.c create mode 100644 newlib/libc/sys/linux/cmath/s_cexpl.c create mode 100644 newlib/libc/sys/linux/cmath/s_clog.c create mode 100644 newlib/libc/sys/linux/cmath/s_clog10.c create mode 100644 newlib/libc/sys/linux/cmath/s_clog10f.c create mode 100644 newlib/libc/sys/linux/cmath/s_clog10l.c create mode 100644 newlib/libc/sys/linux/cmath/s_clogf.c create mode 100644 newlib/libc/sys/linux/cmath/s_clogl.c create mode 100644 newlib/libc/sys/linux/cmath/s_cpow.c create mode 100644 newlib/libc/sys/linux/cmath/s_cpowf.c create mode 100644 newlib/libc/sys/linux/cmath/s_cpowl.c create mode 100644 newlib/libc/sys/linux/cmath/s_cproj.c create mode 100644 newlib/libc/sys/linux/cmath/s_cprojf.c create mode 100644 newlib/libc/sys/linux/cmath/s_cprojl.c create mode 100644 newlib/libc/sys/linux/cmath/s_csin.c create mode 100644 newlib/libc/sys/linux/cmath/s_csinf.c create mode 100644 newlib/libc/sys/linux/cmath/s_csinh.c create mode 100644 newlib/libc/sys/linux/cmath/s_csinhf.c create mode 100644 newlib/libc/sys/linux/cmath/s_csinhl.c create mode 100644 newlib/libc/sys/linux/cmath/s_csinl.c create mode 100644 newlib/libc/sys/linux/cmath/s_csqrt.c create mode 100644 newlib/libc/sys/linux/cmath/s_csqrtf.c create mode 100644 newlib/libc/sys/linux/cmath/s_csqrtl.c create mode 100644 newlib/libc/sys/linux/cmath/s_ctan.c create mode 100644 newlib/libc/sys/linux/cmath/s_ctanf.c create mode 100644 newlib/libc/sys/linux/cmath/s_ctanh.c create mode 100644 newlib/libc/sys/linux/cmath/s_ctanhf.c create mode 100644 newlib/libc/sys/linux/cmath/s_ctanhl.c create mode 100644 newlib/libc/sys/linux/cmath/s_ctanl.c create mode 100644 newlib/libc/sys/linux/include/cmathcalls.h create mode 100644 newlib/libc/sys/linux/include/complex.h create mode 100644 newlib/libc/sys/linux/machine/i386/huge_val.h (limited to 'newlib/libc/sys/linux') diff --git a/newlib/libc/sys/linux/Makefile.am b/newlib/libc/sys/linux/Makefile.am index 69787cf8d..7e967f0c4 100644 --- a/newlib/libc/sys/linux/Makefile.am +++ b/newlib/libc/sys/linux/Makefile.am @@ -5,8 +5,10 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = -I$(srcdir)/include $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) SUBDIRS = machine \ + cmath \ . SUBLIBS = \ + cmath/libcmath.la \ $(LINUX_MACH_LIB) LIB_SOURCES = \ diff --git a/newlib/libc/sys/linux/Makefile.in b/newlib/libc/sys/linux/Makefile.in index 1f49a477b..701cf27ac 100644 --- a/newlib/libc/sys/linux/Makefile.in +++ b/newlib/libc/sys/linux/Makefile.in @@ -100,9 +100,11 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = -I$(srcdir)/include $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) SUBDIRS = machine \ + cmath \ . SUBLIBS = \ + cmath/libcmath.la \ $(LINUX_MACH_LIB) diff --git a/newlib/libc/sys/linux/cmath/Makefile.am b/newlib/libc/sys/linux/cmath/Makefile.am new file mode 100644 index 000000000..6c47f2149 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/Makefile.am @@ -0,0 +1,28 @@ +## Process this file with automake to generate Makefile.in + +AUTOMAKE_OPTIONS = cygnus + +INCLUDES = -I$(srcdir)/../include $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) + +LIB_SOURCES = \ + s_cacos.c s_casinf.c s_catanh.c s_ccosh.c s_clog.c s_cpowf.c s_csinh.c s_ctan.c \ + s_cacosf.c s_casinh.c s_catanhf.c s_ccoshf.c s_clog10.c s_csinhf.c s_ctanf.c \ + s_cacosh.c s_casinhf.c s_clog10f.c s_cproj.c s_ctanh.c \ + s_cacoshf.c s_cprojf.c s_ctanhf.c \ + s_cexp.c s_clogf.c s_csqrt.c \ + s_catan.c s_ccos.c s_cexpf.c s_csin.c s_csqrtf.c \ + s_casin.c s_catanf.c s_ccosf.c s_cpow.c s_csinf.c + +libcmath_la_LDFLAGS = -Xcompiler -nostdlib + +if USE_LIBTOOL +noinst_LTLIBRARIES = libcmath.la +libcmath_la_SOURCES = $(LIB_SOURCES) +noinst_DATA = objectlist.awk.in +else +noinst_LIBRARIES = lib.a +lib_a_SOURCES = $(LIB_SOURCES) +noinst_DATA = +endif # USE_LIBTOOL + +include $(srcdir)/../../../../Makefile.shared diff --git a/newlib/libc/sys/linux/cmath/Makefile.in b/newlib/libc/sys/linux/cmath/Makefile.in new file mode 100644 index 000000000..fee3d914d --- /dev/null +++ b/newlib/libc/sys/linux/cmath/Makefile.in @@ -0,0 +1,390 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 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@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CPP = @CPP@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +GCJ = @GCJ@ +GCJFLAGS = @GCJFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LINUX_MACH_LIB = @LINUX_MACH_LIB@ +LN_S = @LN_S@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NEWLIB_CFLAGS = @NEWLIB_CFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ +aext = @aext@ +libm_machine_dir = @libm_machine_dir@ +machine_dir = @machine_dir@ +newlib_basedir = @newlib_basedir@ +oext = @oext@ +sys_dir = @sys_dir@ + +AUTOMAKE_OPTIONS = cygnus + +INCLUDES = -I$(srcdir)/../include $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) + +LIB_SOURCES = \ + s_cacos.c s_casinf.c s_catanh.c s_ccosh.c s_clog.c s_cpowf.c s_csinh.c s_ctan.c \ + s_cacosf.c s_casinh.c s_catanhf.c s_ccoshf.c s_clog10.c s_csinhf.c s_ctanf.c \ + s_cacosh.c s_casinhf.c s_clog10f.c s_cproj.c s_ctanh.c \ + s_cacoshf.c s_cprojf.c s_ctanhf.c \ + s_cexp.c s_clogf.c s_csqrt.c \ + s_catan.c s_ccos.c s_cexpf.c s_csin.c s_csqrtf.c \ + s_casin.c s_catanf.c s_ccosf.c s_cpow.c s_csinf.c + + +libcmath_la_LDFLAGS = -Xcompiler -nostdlib + +@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = @USE_LIBTOOL_TRUE@libcmath.la +@USE_LIBTOOL_TRUE@libcmath_la_SOURCES = @USE_LIBTOOL_TRUE@$(LIB_SOURCES) +@USE_LIBTOOL_TRUE@noinst_DATA = @USE_LIBTOOL_TRUE@objectlist.awk.in +@USE_LIBTOOL_FALSE@noinst_DATA = +@USE_LIBTOOL_FALSE@noinst_LIBRARIES = @USE_LIBTOOL_FALSE@lib.a +@USE_LIBTOOL_FALSE@lib_a_SOURCES = @USE_LIBTOOL_FALSE@$(LIB_SOURCES) +mkinstalldirs = $(SHELL) $(top_srcdir)/../../../../mkinstalldirs +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) +CPPFLAGS = @CPPFLAGS@ +LIBS = @LIBS@ +lib_a_LIBADD = +@USE_LIBTOOL_FALSE@lib_a_OBJECTS = s_cacos.$(OBJEXT) s_casinf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_catanh.$(OBJEXT) s_ccosh.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_clog.$(OBJEXT) s_cpowf.$(OBJEXT) s_csinh.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_ctan.$(OBJEXT) s_cacosf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_casinh.$(OBJEXT) s_catanhf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_ccoshf.$(OBJEXT) s_clog10.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_csinhf.$(OBJEXT) s_ctanf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_cacosh.$(OBJEXT) s_casinhf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_clog10f.$(OBJEXT) s_cproj.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_ctanh.$(OBJEXT) s_cacoshf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_cprojf.$(OBJEXT) s_ctanhf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_cexp.$(OBJEXT) s_clogf.$(OBJEXT) s_csqrt.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_catan.$(OBJEXT) s_ccos.$(OBJEXT) s_cexpf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_csin.$(OBJEXT) s_csqrtf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_casin.$(OBJEXT) s_catanf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_ccosf.$(OBJEXT) s_cpow.$(OBJEXT) s_csinf.$(OBJEXT) +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libcmath_la_LIBADD = +@USE_LIBTOOL_TRUE@libcmath_la_OBJECTS = s_cacos.lo s_casinf.lo \ +@USE_LIBTOOL_TRUE@s_catanh.lo s_ccosh.lo s_clog.lo s_cpowf.lo \ +@USE_LIBTOOL_TRUE@s_csinh.lo s_ctan.lo s_cacosf.lo s_casinh.lo \ +@USE_LIBTOOL_TRUE@s_catanhf.lo s_ccoshf.lo s_clog10.lo s_csinhf.lo \ +@USE_LIBTOOL_TRUE@s_ctanf.lo s_cacosh.lo s_casinhf.lo s_clog10f.lo \ +@USE_LIBTOOL_TRUE@s_cproj.lo s_ctanh.lo s_cacoshf.lo s_cprojf.lo \ +@USE_LIBTOOL_TRUE@s_ctanhf.lo s_cexp.lo s_clogf.lo s_csqrt.lo \ +@USE_LIBTOOL_TRUE@s_catan.lo s_ccos.lo s_cexpf.lo s_csin.lo s_csqrtf.lo \ +@USE_LIBTOOL_TRUE@s_casin.lo s_catanf.lo s_ccosf.lo s_cpow.lo \ +@USE_LIBTOOL_TRUE@s_csinf.lo +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DATA = $(noinst_DATA) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +SOURCES = $(lib_a_SOURCES) $(libcmath_la_SOURCES) +OBJECTS = $(lib_a_OBJECTS) $(libcmath_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj .s +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/../../../../Makefile.shared + cd $(top_srcdir) && $(AUTOMAKE) --cygnus cmath/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 $< + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.c.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +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 + +mostlyclean-noinstLTLIBRARIES: + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + +distclean-noinstLTLIBRARIES: + +maintainer-clean-noinstLTLIBRARIES: + +libcmath.la: $(libcmath_la_OBJECTS) $(libcmath_la_DEPENDENCIES) + $(LINK) $(libcmath_la_LDFLAGS) $(libcmath_la_OBJECTS) $(libcmath_la_LIBADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(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 = cmath + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: +check: check-am +installcheck-am: +installcheck: installcheck-am +install-info-am: +install-info: install-info-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-noinstLTLIBRARIES \ + mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstLIBRARIES clean-compile clean-libtool \ + clean-noinstLTLIBRARIES clean-tags clean-generic \ + mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstLIBRARIES distclean-compile \ + distclean-libtool distclean-noinstLTLIBRARIES \ + distclean-tags distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-noinstLTLIBRARIES \ + maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ +clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool mostlyclean-noinstLTLIBRARIES \ +distclean-noinstLTLIBRARIES clean-noinstLTLIBRARIES \ +maintainer-clean-noinstLTLIBRARIES tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-info-am install-info \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +objectlist.awk.in: $(noinst_LTLIBRARIES) + -rm -f objectlist.awk.in + for i in `ls *.lo` ; \ + do \ + echo $$i `pwd`/$$i >> objectlist.awk.in ; \ + done + +# 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/libc/sys/linux/cmath/math_private.h b/newlib/libc/sys/linux/cmath/math_private.h new file mode 100644 index 000000000..48258ec47 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/math_private.h @@ -0,0 +1,354 @@ +/* + * ==================================================== + * 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. + * ==================================================== + */ + +/* + * from: @(#)fdlibm.h 5.1 93/09/24 + * $Id$ + */ + +#ifndef _MATH_PRIVATE_H_ +#define _MATH_PRIVATE_H_ + +#include +#include +#include +#include + +#define INFINITY HUGE_VALF + +#define __nan(x) nan() +#define __isnan isnan +#define __isinf isinf +#define __copysignf copysignf +#define __copysign copysign +#define __isnanf isnanf +#define __isinff isinff +#define __nanf(x) nanf() +#define feraiseexcept(x) /* nothing */ +#define __sincos sincos +#define __sincosf sincosf + +int __signbitd (double x); +int __signbitf (float x); + +/* The original fdlibm code used statements like: + n0 = ((*(int*)&one)>>29)^1; * index of high word * + ix0 = *(n0+(int*)&x); * high word of x * + ix1 = *((1-n0)+(int*)&x); * low word of x * + to dig two 32 bit words out of the 64 bit IEEE floating point + value. That is non-ANSI, and, moreover, the gcc instruction + scheduler gets it wrong. We instead use the following macros. + Unlike the original code, we determine the endianness at compile + time, not at run time; I don't see much benefit to selecting + endianness at run time. */ + +/* A union which permits us to convert between a double and two 32 bit + ints. */ + +#if __FLOAT_WORD_ORDER == BIG_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t msw; + u_int32_t lsw; + } parts; +} ieee_double_shape_type; + +#endif + +#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t lsw; + u_int32_t msw; + } parts; +} ieee_double_shape_type; + +#endif + +/* Get two 32 bit ints from a double. */ + +#define EXTRACT_WORDS(ix0,ix1,d) \ +do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ +} while (0) + +/* Get the more significant 32 bit int from a double. */ + +#define GET_HIGH_WORD(i,d) \ +do { \ + ieee_double_shape_type gh_u; \ + gh_u.value = (d); \ + (i) = gh_u.parts.msw; \ +} while (0) + +/* Get the less significant 32 bit int from a double. */ + +#define GET_LOW_WORD(i,d) \ +do { \ + ieee_double_shape_type gl_u; \ + gl_u.value = (d); \ + (i) = gl_u.parts.lsw; \ +} while (0) + +/* Set a double from two 32 bit ints. */ + +#define INSERT_WORDS(d,ix0,ix1) \ +do { \ + ieee_double_shape_type iw_u; \ + iw_u.parts.msw = (ix0); \ + iw_u.parts.lsw = (ix1); \ + (d) = iw_u.value; \ +} while (0) + +/* Set the more significant 32 bits of a double from an int. */ + +#define SET_HIGH_WORD(d,v) \ +do { \ + ieee_double_shape_type sh_u; \ + sh_u.value = (d); \ + sh_u.parts.msw = (v); \ + (d) = sh_u.value; \ +} while (0) + +/* Set the less significant 32 bits of a double from an int. */ + +#define SET_LOW_WORD(d,v) \ +do { \ + ieee_double_shape_type sl_u; \ + sl_u.value = (d); \ + sl_u.parts.lsw = (v); \ + (d) = sl_u.value; \ +} while (0) + +/* A union which permits us to convert between a float and a 32 bit + int. */ + +typedef union +{ + float value; + u_int32_t word; +} ieee_float_shape_type; + +/* Get a 32 bit int from a float. */ + +#define GET_FLOAT_WORD(i,d) \ +do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define SET_FLOAT_WORD(d,i) \ +do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) + +#if 0 +/* ieee style elementary functions */ +extern double __ieee754_sqrt (double); +extern double __ieee754_acos (double); +extern double __ieee754_acosh (double); +extern double __ieee754_log (double); +extern double __ieee754_atanh (double); +extern double __ieee754_asin (double); +extern double __ieee754_atan2 (double,double); +extern double __ieee754_exp (double); +extern double __ieee754_exp2 (double); +extern double __ieee754_exp10 (double); +extern double __ieee754_cosh (double); +extern double __ieee754_fmod (double,double); +extern double __ieee754_pow (double,double); +extern double __ieee754_lgamma_r (double,int *); +extern double __ieee754_gamma_r (double,int *); +extern double __ieee754_lgamma (double); +extern double __ieee754_gamma (double); +extern double __ieee754_log10 (double); +extern double __ieee754_log2 (double); +extern double __ieee754_sinh (double); +extern double __ieee754_hypot (double,double); +extern double __ieee754_j0 (double); +extern double __ieee754_j1 (double); +extern double __ieee754_y0 (double); +extern double __ieee754_y1 (double); +extern double __ieee754_jn (int,double); +extern double __ieee754_yn (int,double); +extern double __ieee754_remainder (double,double); +extern int32_t __ieee754_rem_pio2 (double,double*); +extern double __ieee754_scalb (double,double); +#endif + +#define __ieee754_sinh sinh +#define __ieee754_hypot hypot +#define __ieee754_hypotf hypotf +#define __ieee754_logf logf +#define __ieee754_log10 log10 +#define __ieee754_exp exp +#define __ieee754_cosh cosh +#define __ieee754_expf expf +#define __ieee754_log10f log10f +#define __ieee754_atan2 atan2 +#define __ieee754_sqrtf sqrtf +#define __ieee754_sinhf sinhf +#define __ieee754_log log +#define __ieee754_sqrt sqrt +#define __ieee754_coshf coshf +#define __ieee754_atan2f atan2f + +/* fdlibm kernel function */ +extern double __kernel_standard (double,double,int); +extern double __kernel_sin (double,double,int); +extern double __kernel_cos (double,double); +extern double __kernel_tan (double,double,int); +extern int __kernel_rem_pio2 (double*,double*,int,int,int, const int32_t*); + +/* internal functions. */ +extern double __copysign (double x, double __y); + + +/* ieee style elementary float functions */ +extern float __ieee754_sqrtf (float); +extern float __ieee754_acosf (float); +extern float __ieee754_acoshf (float); +extern float __ieee754_logf (float); +extern float __ieee754_atanhf (float); +extern float __ieee754_asinf (float); +extern float __ieee754_atan2f (float,float); +extern float __ieee754_expf (float); +extern float __ieee754_exp2f (float); +extern float __ieee754_exp10f (float); +extern float __ieee754_coshf (float); +extern float __ieee754_fmodf (float,float); +extern float __ieee754_powf (float,float); +extern float __ieee754_lgammaf_r (float,int *); +extern float __ieee754_gammaf_r (float,int *); +extern float __ieee754_lgammaf (float); +extern float __ieee754_gammaf (float); +extern float __ieee754_log10f (float); +extern float __ieee754_log2f (float); +extern float __ieee754_sinhf (float); +extern float __ieee754_hypotf (float,float); +extern float __ieee754_j0f (float); +extern float __ieee754_j1f (float); +extern float __ieee754_y0f (float); +extern float __ieee754_y1f (float); +extern float __ieee754_jnf (int,float); +extern float __ieee754_ynf (int,float); +extern float __ieee754_remainderf (float,float); +extern int32_t __ieee754_rem_pio2f (float,float*); +extern float __ieee754_scalbf (float,float); + + +/* float versions of fdlibm kernel functions */ +extern float __kernel_sinf (float,float,int); +extern float __kernel_cosf (float,float); +extern float __kernel_tanf (float,float,int); +extern int __kernel_rem_pio2f (float*,float*,int,int,int, const int32_t*); + + +/* ieee style elementary long double functions */ +extern long double __ieee754_sqrtl (long double); +extern long double __ieee754_acosl (long double); +extern long double __ieee754_acoshl (long double); +extern long double __ieee754_logl (long double); +extern long double __ieee754_atanhl (long double); +extern long double __ieee754_asinl (long double); +extern long double __ieee754_atan2l (long double,long double); +extern long double __ieee754_expl (long double); +extern long double __ieee754_exp2l (long double); +extern long double __ieee754_exp10l (long double); +extern long double __ieee754_coshl (long double); +extern long double __ieee754_fmodl (long double,long double); +extern long double __ieee754_powl (long double,long double); +extern long double __ieee754_lgammal_r (long double,int *); +extern long double __ieee754_gammal_r (long double,int *); +extern long double __ieee754_lgammal (long double); +extern long double __ieee754_gammal (long double); +extern long double __ieee754_log10l (long double); +extern long double __ieee754_log2l (long double); +extern long double __ieee754_sinhl (long double); +extern long double __ieee754_hypotl (long double,long double); +extern long double __ieee754_j0l (long double); +extern long double __ieee754_j1l (long double); +extern long double __ieee754_y0l (long double); +extern long double __ieee754_y1l (long double); +extern long double __ieee754_jnl (int,long double); +extern long double __ieee754_ynl (int,long double); +extern long double __ieee754_remainderl (long double,long double); +extern int __ieee754_rem_pio2l (long double,long double*); +extern long double __ieee754_scalbl (long double,long double); + +/* long double versions of fdlibm kernel functions */ +extern long double __kernel_sinl (long double,long double,int); +extern long double __kernel_cosl (long double,long double); +extern long double __kernel_tanl (long double,long double,int); +extern void __kernel_sincosl (long double,long double, + long double *,long double *, int); +extern int __kernel_rem_pio2l (long double*,long double*,int,int, + int,const int*); + +#ifndef NO_LONG_DOUBLE +/* prototypes required to compile the ldbl-96 support without warnings */ +extern int __finitel (long double); +extern int __ilogbl (long double); +extern int __isinfl (long double); +extern int __isnanl (long double); +extern long double __atanl (long double); +extern long double __copysignl (long double, long double); +extern long double __expm1l (long double); +extern long double __floorl (long double); +extern long double __frexpl (long double, int *); +extern long double __ldexpl (long double, int); +extern long double __log1pl (long double); +extern long double __nanl (const char *); +extern long double __rintl (long double); +extern long double __scalbnl (long double, int); +extern long double __sqrtl (long double x); +extern long double fabsl (long double x); +extern void __sincosl (long double, long double *, long double *); +extern long double __logbl (long double x); +extern long double __significandl (long double x); +#endif + +/* Prototypes for functions of the IBM Accurate Mathematical Library. */ +extern double __exp1 (double __x, double __xx, double __error); +extern double __sin (double __x); +extern double __cos (double __x); +extern int __branred (double __x, double *__a, double *__aa); +extern void __doasin (double __x, double __dx, double __v[]); +extern void __dubsin (double __x, double __dx, double __v[]); +extern void __dubcos (double __x, double __dx, double __v[]); +extern double __halfulp (double __x, double __y); +extern double __sin32 (double __x, double __res, double __res1); +extern double __cos32 (double __x, double __res, double __res1); +extern double __mpsin (double __x, double __dx); +extern double __mpcos (double __x, double __dx); +extern double __mpsin1 (double __x); +extern double __mpcos1 (double __x); +extern double __slowexp (double __x); +extern double __slowpow (double __x, double __y, double __z); +extern void __docos (double __x, double __dx, double __v[]); + +#endif /* _MATH_PRIVATE_H_ */ diff --git a/newlib/libc/sys/linux/cmath/s_cacos.c b/newlib/libc/sys/linux/cmath/s_cacos.c new file mode 100644 index 000000000..f9864472b --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cacos.c @@ -0,0 +1,42 @@ +/* Return cosine of complex double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ double +__cacos (__complex__ double x) +{ + __complex__ double y; + __complex__ double res; + + y = __casin (x); + + __real__ res = (double) M_PI_2 - __real__ y; + __imag__ res = -__imag__ y; + + return res; +} +weak_alias (__cacos, cacos) +#ifdef NO_LONG_DOUBLE +strong_alias (__cacos, __cacosl) +weak_alias (__cacos, cacosl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_cacosf.c b/newlib/libc/sys/linux/cmath/s_cacosf.c new file mode 100644 index 000000000..bf01890ad --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cacosf.c @@ -0,0 +1,38 @@ +/* Return cosine of complex float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ float +__cacosf (__complex__ float x) +{ + __complex__ float y; + __complex__ float res; + + y = __casinf (x); + + __real__ res = (float) M_PI_2 - __real__ y; + __imag__ res = -__imag__ y; + + return res; +} +weak_alias (__cacosf, cacosf) diff --git a/newlib/libc/sys/linux/cmath/s_cacosh.c b/newlib/libc/sys/linux/cmath/s_cacosh.c new file mode 100644 index 000000000..6ca3426b5 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cacosh.c @@ -0,0 +1,88 @@ +/* Return arc hyperbole cosine for double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ double +__cacosh (__complex__ double x) +{ + __complex__ double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = HUGE_VAL; + + if (rcls == FP_NAN) + __imag__ res = __nan (""); + else + __imag__ res = __copysign ((rcls == FP_INFINITE + ? (__real__ x < 0.0 + ? M_PI - M_PI_4 : M_PI_4) + : M_PI_2), __imag__ x); + } + else if (rcls == FP_INFINITE) + { + __real__ res = HUGE_VAL; + + if (icls >= FP_ZERO) + __imag__ res = __copysign (signbit (__real__ x) ? M_PI : 0.0, + __imag__ x); + else + __imag__ res = __nan (""); + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + __real__ res = 0.0; + __imag__ res = __copysign (M_PI_2, __imag__ x); + } + else + { + __complex__ double y; + + __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0; + __imag__ y = 2.0 * __real__ x * __imag__ x; + + y = __csqrt (y); + + __real__ y += __real__ x; + __imag__ y += __imag__ x; + + res = __clog (y); + } + + return res; +} +weak_alias (__cacosh, cacosh) +#ifdef NO_LONG_DOUBLE +strong_alias (__cacosh, __cacoshl) +weak_alias (__cacosh, cacoshl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_cacoshf.c b/newlib/libc/sys/linux/cmath/s_cacoshf.c new file mode 100644 index 000000000..69054cde3 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cacoshf.c @@ -0,0 +1,98 @@ +/* Return arc hyperbole cosine for float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ float +__cacoshf (__complex__ float x) +{ + __complex__ float res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = HUGE_VALF; + + if (rcls == FP_NAN) + __imag__ res = __nanf (""); + else + __imag__ res = __copysignf ((rcls == FP_INFINITE + ? (__real__ x < 0.0 + ? M_PI - M_PI_4 : M_PI_4) + : M_PI_2), __imag__ x); + } + else if (rcls == FP_INFINITE) + { + __real__ res = HUGE_VALF; + + if (icls >= FP_ZERO) + __imag__ res = __copysignf (signbit (__real__ x) ? M_PI : 0.0, + __imag__ x); + else + __imag__ res = __nanf (""); + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + __real__ res = 0.0; + __imag__ res = __copysignf (M_PI_2, __imag__ x); + } + else + { +#if 1 + __complex__ float y; + + __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0; + __imag__ y = 2.0 * __real__ x * __imag__ x; + + y = __csqrtf (y); + + __real__ y += __real__ x; + __imag__ y += __imag__ x; + + res = __clogf (y); +#else + float re2 = __real__ x * __real__ x; + float im2 = __imag__ x * __imag__ x; + float sq = re2 - im2 - 1.0; + float ro = __ieee754_sqrtf (sq * sq + 4 * re2 * im2); + float a = __ieee754_sqrtf ((sq + ro) / 2.0); + float b = __ieee754_sqrtf ((-sq + ro) / 2.0); + + __real__ res = 0.5 * __ieee754_logf (re2 + __real__ x * 2 * a + + im2 + __imag__ x * 2 * b + + ro); + __imag__ res = __ieee754_atan2f (__imag__ x + b, __real__ x + a); +#endif + } + + return res; +} +weak_alias (__cacoshf, cacoshf) diff --git a/newlib/libc/sys/linux/cmath/s_cacoshl.c b/newlib/libc/sys/linux/cmath/s_cacoshl.c new file mode 100644 index 000000000..3d0cd7f2a --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cacoshl.c @@ -0,0 +1,84 @@ +/* Return arc hyperbole cosine for long double value. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ long double +__cacoshl (__complex__ long double x) +{ + __complex__ long double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = HUGE_VALL; + + if (rcls == FP_NAN) + __imag__ res = __nanl (""); + else + __imag__ res = __copysignl ((rcls == FP_INFINITE + ? (__real__ x < 0.0 + ? M_PIl - M_PI_4l : M_PI_4l) + : M_PI_2l), __imag__ x); + } + else if (rcls == FP_INFINITE) + { + __real__ res = HUGE_VALL; + + if (icls >= FP_ZERO) + __imag__ res = __copysignl (signbit (__real__ x) ? M_PIl : 0.0, + __imag__ x); + else + __imag__ res = __nanl (""); + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + __real__ res = 0.0; + __imag__ res = __copysignl (M_PI_2l, __imag__ x); + } + else + { + __complex__ long double y; + + __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0; + __imag__ y = 2.0 * __real__ x * __imag__ x; + + y = __csqrtl (y); + + __real__ y += __real__ x; + __imag__ y += __imag__ x; + + res = __clogl (y); + } + + return res; +} +weak_alias (__cacoshl, cacoshl) diff --git a/newlib/libc/sys/linux/cmath/s_cacosl.c b/newlib/libc/sys/linux/cmath/s_cacosl.c new file mode 100644 index 000000000..d4bbfec87 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cacosl.c @@ -0,0 +1,38 @@ +/* Return cosine of complex long double value. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ long double +__cacosl (__complex__ long double x) +{ + __complex__ long double y; + __complex__ long double res; + + y = __casinl (x); + + __real__ res = M_PI_2l - __real__ y; + __imag__ res = -__imag__ y; + + return res; +} +weak_alias (__cacosl, cacosl) diff --git a/newlib/libc/sys/linux/cmath/s_casin.c b/newlib/libc/sys/linux/cmath/s_casin.c new file mode 100644 index 000000000..4c164b534 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_casin.c @@ -0,0 +1,66 @@ +/* Return arc sine of complex double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ double +__casin (__complex__ double x) +{ + __complex__ double res; + + if (isnan (__real__ x) || isnan (__imag__ x)) + { + if (__real__ x == 0.0) + { + res = x; + } + else if (__isinf (__real__ x) || __isinf (__imag__ x)) + { + __real__ res = __nan (""); + __imag__ res = __copysign (HUGE_VAL, __imag__ x); + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + } + } + else + { + __complex__ double y; + + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + y = __casinh (y); + + __real__ res = __imag__ y; + __imag__ res = -__real__ y; + } + + return res; +} +weak_alias (__casin, casin) +#ifdef NO_LONG_DOUBLE +strong_alias (__casin, __casinl) +weak_alias (__casin, casinl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_casinf.c b/newlib/libc/sys/linux/cmath/s_casinf.c new file mode 100644 index 000000000..09e52b400 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_casinf.c @@ -0,0 +1,63 @@ +/* Return arc sine of complex float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + + +__complex__ float +__casinf (__complex__ float x) +{ + __complex__ float res; + + if (isnan (__real__ x) || isnan (__imag__ x)) + { + if (__real__ x == 0.0) + { + res = x; + } + else if (__isinff (__real__ x) || __isinff (__imag__ x)) + { + __real__ res = __nanf (""); + __imag__ res = __copysignf (HUGE_VALF, __imag__ x); + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + } + } + else + { + __complex__ float y; + + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + y = __casinhf (y); + + __real__ res = __imag__ y; + __imag__ res = -__real__ y; + } + + return res; +} +weak_alias (__casinf, casinf) diff --git a/newlib/libc/sys/linux/cmath/s_casinh.c b/newlib/libc/sys/linux/cmath/s_casinh.c new file mode 100644 index 000000000..30b9dbb18 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_casinh.c @@ -0,0 +1,84 @@ +/* Return arc hyperbole sine for double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ double +__casinh (__complex__ double x) +{ + __complex__ double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = __copysign (HUGE_VAL, __real__ x); + + if (rcls == FP_NAN) + __imag__ res = __nan (""); + else + __imag__ res = __copysign (rcls >= FP_ZERO ? M_PI_2 : M_PI_4, + __imag__ x); + } + else if (rcls <= FP_INFINITE) + { + __real__ res = __real__ x; + if ((rcls == FP_INFINITE && icls >= FP_ZERO) + || (rcls == FP_NAN && icls == FP_ZERO)) + __imag__ res = __copysign (0.0, __imag__ x); + else + __imag__ res = __nan (""); + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + __complex__ double y; + + __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) + 1.0; + __imag__ y = 2.0 * __real__ x * __imag__ x; + + y = __csqrt (y); + + __real__ y += __real__ x; + __imag__ y += __imag__ x; + + res = __clog (y); + } + + return res; +} +weak_alias (__casinh, casinh) +#ifdef NO_LONG_DOUBLE +strong_alias (__casinh, __casinhl) +weak_alias (__casinh, casinhl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_casinhf.c b/newlib/libc/sys/linux/cmath/s_casinhf.c new file mode 100644 index 000000000..f9fc4e73c --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_casinhf.c @@ -0,0 +1,80 @@ +/* Return arc hyperbole sine for float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ float +__casinhf (__complex__ float x) +{ + __complex__ float res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = __copysignf (HUGE_VALF, __real__ x); + + if (rcls == FP_NAN) + __imag__ res = __nanf (""); + else + __imag__ res = __copysignf (rcls >= FP_ZERO ? M_PI_2 : M_PI_4, + __imag__ x); + } + else if (rcls <= FP_INFINITE) + { + __real__ res = __real__ x; + if ((rcls == FP_INFINITE && icls >= FP_ZERO) + || (rcls == FP_NAN && icls == FP_ZERO)) + __imag__ res = __copysignf (0.0, __imag__ x); + else + __imag__ res = __nanf (""); + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + __complex__ float y; + + __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) + 1.0; + __imag__ y = 2.0 * __real__ x * __imag__ x; + + y = __csqrtf (y); + + __real__ y += __real__ x; + __imag__ y += __imag__ x; + + res = __clogf (y); + } + + return res; +} +weak_alias (__casinhf, casinhf) diff --git a/newlib/libc/sys/linux/cmath/s_casinhl.c b/newlib/libc/sys/linux/cmath/s_casinhl.c new file mode 100644 index 000000000..b48c60932 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_casinhl.c @@ -0,0 +1,80 @@ +/* Return arc hyperbole sine for long double value. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ long double +__casinhl (__complex__ long double x) +{ + __complex__ long double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = __copysignl (HUGE_VALL, __real__ x); + + if (rcls == FP_NAN) + __imag__ res = __nanl (""); + else + __imag__ res = __copysignl (rcls >= FP_ZERO ? M_PI_2l : M_PI_4l, + __imag__ x); + } + else if (rcls <= FP_INFINITE) + { + __real__ res = __real__ x; + if ((rcls == FP_INFINITE && icls >= FP_ZERO) + || (rcls == FP_NAN && icls == FP_ZERO)) + __imag__ res = __copysignl (0.0, __imag__ x); + else + __imag__ res = __nanl (""); + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + __complex__ long double y; + + __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) + 1.0; + __imag__ y = 2.0 * __real__ x * __imag__ x; + + y = __csqrtl (y); + + __real__ y += __real__ x; + __imag__ y += __imag__ x; + + res = __clogl (y); + } + + return res; +} +weak_alias (__casinhl, casinhl) diff --git a/newlib/libc/sys/linux/cmath/s_casinl.c b/newlib/libc/sys/linux/cmath/s_casinl.c new file mode 100644 index 000000000..d6b7a8087 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_casinl.c @@ -0,0 +1,62 @@ +/* Return arc sine of complex long double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ long double +__casinl (__complex__ long double x) +{ + __complex__ long double res; + + if (isnan (__real__ x) || isnan (__imag__ x)) + { + if (__real__ x == 0.0) + { + res = x; + } + else if (__isinfl (__real__ x) || __isinfl (__imag__ x)) + { + __real__ res = __nanl (""); + __imag__ res = __copysignl (HUGE_VALL, __imag__ x); + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + } + } + else + { + __complex__ long double y; + + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + y = __casinhl (y); + + __real__ res = __imag__ y; + __imag__ res = -__real__ y; + } + + return res; +} +weak_alias (__casinl, casinl) diff --git a/newlib/libc/sys/linux/cmath/s_catan.c b/newlib/libc/sys/linux/cmath/s_catan.c new file mode 100644 index 000000000..1d0673ad6 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_catan.c @@ -0,0 +1,89 @@ +/* Return arc tangent of complex double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ double +__catan (__complex__ double x) +{ + __complex__ double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (rcls == FP_INFINITE) + { + __real__ res = __copysign (M_PI_2, __real__ x); + __imag__ res = __copysign (0.0, __imag__ x); + } + else if (icls == FP_INFINITE) + { + if (rcls >= FP_ZERO) + __real__ res = __copysign (M_PI_2, __real__ x); + else + __real__ res = __nan (""); + __imag__ res = __copysign (0.0, __imag__ x); + } + else if (icls == FP_ZERO || icls == FP_INFINITE) + { + __real__ res = __nan (""); + __imag__ res = __copysign (0.0, __imag__ x); + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + double r2, num, den; + + r2 = __real__ x * __real__ x; + + den = 1 - r2 - __imag__ x * __imag__ x; + + __real__ res = 0.5 * __ieee754_atan2 (2.0 * __real__ x, den); + + num = __imag__ x + 1.0; + num = r2 + num * num; + + den = __imag__ x - 1.0; + den = r2 + den * den; + + __imag__ res = 0.25 * __ieee754_log (num / den); + } + + return res; +} +weak_alias (__catan, catan) +#ifdef NO_LONG_DOUBLE +strong_alias (__catan, __catanl) +weak_alias (__catan, catanl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_catanf.c b/newlib/libc/sys/linux/cmath/s_catanf.c new file mode 100644 index 000000000..cc9e5ea7a --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_catanf.c @@ -0,0 +1,85 @@ +/* Return arc tangent of complex float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ float +__catanf (__complex__ float x) +{ + __complex__ float res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (rcls == FP_INFINITE) + { + __real__ res = __copysignf (M_PI_2, __real__ x); + __imag__ res = __copysignf (0.0, __imag__ x); + } + else if (icls == FP_INFINITE) + { + if (rcls >= FP_ZERO) + __real__ res = __copysignf (M_PI_2, __real__ x); + else + __real__ res = __nanf (""); + __imag__ res = __copysignf (0.0, __imag__ x); + } + else if (icls == FP_ZERO || icls == FP_INFINITE) + { + __real__ res = __nanf (""); + __imag__ res = __copysignf (0.0, __imag__ x); + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + float r2, num, den; + + r2 = __real__ x * __real__ x; + + den = 1 - r2 - __imag__ x * __imag__ x; + + __real__ res = 0.5 * __ieee754_atan2f (2.0 * __real__ x, den); + + num = __imag__ x + 1.0; + num = r2 + num * num; + + den = __imag__ x - 1.0; + den = r2 + den * den; + + __imag__ res = 0.25 * __ieee754_logf (num / den); + } + + return res; +} +weak_alias (__catanf, catanf) diff --git a/newlib/libc/sys/linux/cmath/s_catanh.c b/newlib/libc/sys/linux/cmath/s_catanh.c new file mode 100644 index 000000000..e15c073f9 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_catanh.c @@ -0,0 +1,84 @@ +/* Return arc hyperbole tangent for double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ double +__catanh (__complex__ double x) +{ + __complex__ double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = __copysign (0.0, __real__ x); + __imag__ res = __copysign (M_PI_2, __imag__ x); + } + else if (rcls == FP_INFINITE || rcls == FP_ZERO) + { + __real__ res = __copysign (0.0, __real__ x); + if (icls >= FP_ZERO) + __imag__ res = __copysign (M_PI_2, __imag__ x); + else + __imag__ res = __nan (""); + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + double i2, num, den; + + i2 = __imag__ x * __imag__ x; + + num = 1.0 + __real__ x; + num = i2 + num * num; + + den = 1.0 - __real__ x; + den = i2 + den * den; + + __real__ res = 0.25 * (__ieee754_log (num) - __ieee754_log (den)); + + den = 1 - __real__ x * __real__ x - i2; + + __imag__ res = 0.5 * __ieee754_atan2 (2.0 * __imag__ x, den); + } + + return res; +} +weak_alias (__catanh, catanh) +#ifdef NO_LONG_DOUBLE +strong_alias (__catanh, __catanhl) +weak_alias (__catanh, catanhl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_catanhf.c b/newlib/libc/sys/linux/cmath/s_catanhf.c new file mode 100644 index 000000000..30a5a1b8a --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_catanhf.c @@ -0,0 +1,80 @@ +/* Return arc hyperbole tangent for float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ float +__catanhf (__complex__ float x) +{ + __complex__ float res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = __copysignf (0.0, __real__ x); + __imag__ res = __copysignf (M_PI_2, __imag__ x); + } + else if (rcls == FP_INFINITE || rcls == FP_ZERO) + { + __real__ res = __copysignf (0.0, __real__ x); + if (icls >= FP_ZERO) + __imag__ res = __copysignf (M_PI_2, __imag__ x); + else + __imag__ res = __nanf (""); + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + float i2, num, den; + + i2 = __imag__ x * __imag__ x; + + num = 1.0 + __real__ x; + num = i2 + num * num; + + den = 1.0 - __real__ x; + den = i2 + den * den; + + __real__ res = 0.25 * (__ieee754_logf (num) - __ieee754_logf (den)); + + den = 1 - __real__ x * __real__ x - i2; + + __imag__ res = 0.5 * __ieee754_atan2f (2.0 * __imag__ x, den); + } + + return res; +} +weak_alias (__catanhf, catanhf) diff --git a/newlib/libc/sys/linux/cmath/s_catanhl.c b/newlib/libc/sys/linux/cmath/s_catanhl.c new file mode 100644 index 000000000..c3fb0ce5f --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_catanhl.c @@ -0,0 +1,80 @@ +/* Return arc hyperbole tangent for long double value. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ long double +__catanhl (__complex__ long double x) +{ + __complex__ long double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = __copysignl (0.0, __real__ x); + __imag__ res = __copysignl (M_PI_2l, __imag__ x); + } + else if (rcls == FP_INFINITE || rcls == FP_ZERO) + { + __real__ res = __copysignl (0.0, __real__ x); + if (icls >= FP_ZERO) + __imag__ res = __copysignl (M_PI_2l, __imag__ x); + else + __imag__ res = __nanl (""); + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + long double i2, num, den; + + i2 = __imag__ x * __imag__ x; + + num = 1.0 + __real__ x; + num = i2 + num * num; + + den = 1.0 - __real__ x; + den = i2 + den * den; + + __real__ res = 0.25 * (__ieee754_logl (num) - __ieee754_logl (den)); + + den = 1 - __real__ x * __real__ x - i2; + + __imag__ res = 0.5 * __ieee754_atan2l (2.0 * __imag__ x, den); + } + + return res; +} +weak_alias (__catanhl, catanhl) diff --git a/newlib/libc/sys/linux/cmath/s_catanl.c b/newlib/libc/sys/linux/cmath/s_catanl.c new file mode 100644 index 000000000..6cb45e5be --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_catanl.c @@ -0,0 +1,85 @@ +/* Return arc tangent of complex long double value. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ long double +__catanl (__complex__ long double x) +{ + __complex__ long double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (rcls == FP_INFINITE) + { + __real__ res = __copysignl (M_PI_2l, __real__ x); + __imag__ res = __copysignl (0.0, __imag__ x); + } + else if (icls == FP_INFINITE) + { + if (rcls >= FP_ZERO) + __real__ res = __copysignl (M_PI_2l, __real__ x); + else + __real__ res = __nanl (""); + __imag__ res = __copysignl (0.0, __imag__ x); + } + else if (icls == FP_ZERO || icls == FP_INFINITE) + { + __real__ res = __nanl (""); + __imag__ res = __copysignl (0.0, __imag__ x); + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + } + } + else if (rcls == FP_ZERO && icls == FP_ZERO) + { + res = x; + } + else + { + long double r2, num, den; + + r2 = __real__ x * __real__ x; + + den = 1 - r2 - __imag__ x * __imag__ x; + + __real__ res = 0.5 * __ieee754_atan2l (2.0 * __real__ x, den); + + num = __imag__ x + 1.0; + num = r2 + num * num; + + den = __imag__ x - 1.0; + den = r2 + den * den; + + __imag__ res = 0.25 * __ieee754_logl (num / den); + } + + return res; +} +weak_alias (__catanl, catanl) diff --git a/newlib/libc/sys/linux/cmath/s_cbrtl.c b/newlib/libc/sys/linux/cmath/s_cbrtl.c new file mode 100644 index 000000000..d668e377a --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cbrtl.c @@ -0,0 +1,15 @@ +#include +#include +#include + +long double +__cbrtl(long double x) +{ + fputs ("__cbrtl not implemented\n", stderr); + __set_errno (ENOSYS); + return 0.0; +} + +weak_alias (__cbrtl, cbrtl) +stub_warning (cbrtl) +#include diff --git a/newlib/libc/sys/linux/cmath/s_ccos.c b/newlib/libc/sys/linux/cmath/s_ccos.c new file mode 100644 index 000000000..e65ea38a5 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ccos.c @@ -0,0 +1,80 @@ +/* Return cosine of complex double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include "math_private.h" + +__complex__ double +__ccos (__complex__ double x) +{ + __complex__ double res; + + if (!isfinite (__real__ x) || __isnan (__imag__ x)) + { + if (__real__ x == 0.0 || __imag__ x == 0.0) + { + __real__ res = __nan (""); + __imag__ res = 0.0; + +#ifdef FE_INVALID + if (__isinf (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + else if (__isinf (__imag__ x)) + { + __real__ res = HUGE_VAL; + __imag__ res = __nan (""); + +#ifdef FE_INVALID + if (__isinf (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + +#ifdef FE_INVALID + if (isfinite (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __complex__ double y; + + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + res = __ccosh (y); + } + + return res; +} +weak_alias (__ccos, ccos) +#ifdef NO_LONG_DOUBLE +strong_alias (__ccos, __ccosl) +weak_alias (__ccos, ccosl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_ccosf.c b/newlib/libc/sys/linux/cmath/s_ccosf.c new file mode 100644 index 000000000..016d8062b --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ccosf.c @@ -0,0 +1,76 @@ +/* Return cosine of complex float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include "math_private.h" + +__complex__ float +__ccosf (__complex__ float x) +{ + __complex__ float res; + + if (!isfinite (__real__ x) || __isnanf (__imag__ x)) + { + if (__real__ x == 0.0 || __imag__ x == 0.0) + { + __real__ res = __nanf (""); + __imag__ res = 0.0; + +#ifdef FE_INVALID + if (__isinff (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + else if (__isinff (__imag__ x)) + { + __real__ res = HUGE_VALF; + __imag__ res = __nanf (""); + +#ifdef FE_INVALID + if (__isinff (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + +#ifdef FE_INVALID + if (isfinite (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __complex__ float y; + + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + res = __ccoshf (y); + } + + return res; +} +weak_alias (__ccosf, ccosf) diff --git a/newlib/libc/sys/linux/cmath/s_ccosh.c b/newlib/libc/sys/linux/cmath/s_ccosh.c new file mode 100644 index 000000000..f5b29db24 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ccosh.c @@ -0,0 +1,105 @@ +/* Complex cosine hyperbole function for double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ double +__ccosh (__complex__ double x) +{ + __complex__ double retval; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + double sinh_val = __ieee754_sinh (__real__ x); + double cosh_val = __ieee754_cosh (__real__ x); + double sinix, cosix; + + __sincos (__imag__ x, &sinix, &cosix); + + __real__ retval = cosh_val * cosix; + __imag__ retval = sinh_val * sinix; + } + else + { + __imag__ retval = __real__ x == 0.0 ? 0.0 : __nan (""); + __real__ retval = __nan ("") + __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = HUGE_VAL; + __imag__ retval = __imag__ x * __copysign (1.0, __real__ x); + } + else if (icls > FP_ZERO) + { + /* Imaginary part is finite. */ + double sinix, cosix; + + __sincos (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysign (HUGE_VAL, cosix); + __imag__ retval = (__copysign (HUGE_VAL, sinix) + * __copysign (1.0, __real__ x)); + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = HUGE_VAL; + __imag__ retval = __nan ("") + __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __real__ retval = __nan (""); + __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nan (""); + } + + return retval; +} +weak_alias (__ccosh, ccosh) +#ifdef NO_LONG_DOUBLE +strong_alias (__ccosh, __ccoshl) +weak_alias (__ccosh, ccoshl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_ccoshf.c b/newlib/libc/sys/linux/cmath/s_ccoshf.c new file mode 100644 index 000000000..339b6bc1c --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ccoshf.c @@ -0,0 +1,101 @@ +/* Complex cosine hyperbole function for float. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ float +__ccoshf (__complex__ float x) +{ + __complex__ float retval; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + float sinh_val = __ieee754_sinhf (__real__ x); + float cosh_val = __ieee754_coshf (__real__ x); + float sinix, cosix; + + __sincosf (__imag__ x, &sinix, &cosix); + + __real__ retval = cosh_val * cosix; + __imag__ retval = sinh_val * sinix; + } + else + { + __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanf (""); + __real__ retval = __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = HUGE_VALF; + __imag__ retval = __imag__ x * __copysignf (1.0, __real__ x); + } + else if (icls > FP_ZERO) + { + /* Imaginary part is finite. */ + float sinix, cosix; + + __sincosf (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysignf (HUGE_VALF, cosix); + __imag__ retval = (__copysignf (HUGE_VALF, sinix) + * __copysignf (1.0, __real__ x)); + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = HUGE_VALF; + __imag__ retval = __nanf ("") + __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __real__ retval = __nanf (""); + __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanf (""); + } + + return retval; +} +weak_alias (__ccoshf, ccoshf) diff --git a/newlib/libc/sys/linux/cmath/s_ccoshl.c b/newlib/libc/sys/linux/cmath/s_ccoshl.c new file mode 100644 index 000000000..61ffb49ca --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ccoshl.c @@ -0,0 +1,101 @@ +/* Complex cosine hyperbole function for long double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ long double +__ccoshl (__complex__ long double x) +{ + __complex__ long double retval; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + long double sinh_val = __ieee754_sinhl (__real__ x); + long double cosh_val = __ieee754_coshl (__real__ x); + long double sinix, cosix; + + __sincosl (__imag__ x, &sinix, &cosix); + + __real__ retval = cosh_val * cosix; + __imag__ retval = sinh_val * sinix; + } + else + { + __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanl (""); + __real__ retval = __nanl ("") + __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = HUGE_VALL; + __imag__ retval = __imag__ x * __copysignl (1.0, __real__ x); + } + else if (icls > FP_ZERO) + { + /* Imaginary part is finite. */ + long double sinix, cosix; + + __sincosl (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysignl (HUGE_VALL, cosix); + __imag__ retval = (__copysignl (HUGE_VALL, sinix) + * __copysignl (1.0, __real__ x)); + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = HUGE_VALL; + __imag__ retval = __nanl ("") + __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __real__ retval = __nanl (""); + __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanl (""); + } + + return retval; +} +weak_alias (__ccoshl, ccoshl) diff --git a/newlib/libc/sys/linux/cmath/s_ccosl.c b/newlib/libc/sys/linux/cmath/s_ccosl.c new file mode 100644 index 000000000..4ebe2c347 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ccosl.c @@ -0,0 +1,76 @@ +/* Return cosine of complex long double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + + +__complex__ long double +__ccosl (__complex__ long double x) +{ + __complex__ long double res; + + if (!isfinite (__real__ x) || __isnanl (__imag__ x)) + { + if (__real__ x == 0.0 || __imag__ x == 0.0) + { + __real__ res = __nanl (""); + __imag__ res = 0.0; + +#ifdef FE_INVALID + if (__isinfl (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + else if (__isinfl (__imag__ x)) + { + __real__ res = HUGE_VALL; + __imag__ res = __nanl (""); + +#ifdef FE_INVALID + if (__isinfl (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + +#ifdef FE_INVALID + if (isfinite (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __complex__ long double y; + + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + res = __ccoshl (y); + } + + return res; +} +weak_alias (__ccosl, ccosl) diff --git a/newlib/libc/sys/linux/cmath/s_cexp.c b/newlib/libc/sys/linux/cmath/s_cexp.c new file mode 100644 index 000000000..5a299b768 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cexp.c @@ -0,0 +1,127 @@ +/* Return value of complex exponential function for double complex value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ double +__cexp (__complex__ double x) +{ + __complex__ double retval; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + double exp_val = __ieee754_exp (__real__ x); + double sinix, cosix; + + __sincos (__imag__ x, &sinix, &cosix); + + if (isfinite (exp_val)) + { + __real__ retval = exp_val * cosix; + __imag__ retval = exp_val * sinix; + } + else + { + __real__ retval = __copysign (exp_val, cosix); + __imag__ retval = __copysign (exp_val, sinix); + } + } + else + { + /* If the imaginary part is +-inf or NaN and the real part + is not +-inf the result is NaN + iNaN. */ + __real__ retval = __nan (""); + __imag__ retval = __nan (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + double value = signbit (__real__ x) ? 0.0 : HUGE_VAL; + + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = value; + __imag__ retval = __imag__ x; + } + else + { + double sinix, cosix; + + __sincos (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysign (value, cosix); + __imag__ retval = __copysign (value, sinix); + } + } + else if (signbit (__real__ x) == 0) + { + __real__ retval = HUGE_VAL; + __imag__ retval = __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = 0.0; + __imag__ retval = __copysign (0.0, __imag__ x); + } + } + else + { + /* If the real part is NaN the result is NaN + iNaN. */ + __real__ retval = __nan (""); + __imag__ retval = __nan (""); + +#ifdef FE_INVALID + if (rcls != FP_NAN || icls != FP_NAN) + feraiseexcept (FE_INVALID); +#endif + } + + return retval; +} +weak_alias (__cexp, cexp) +#ifdef NO_LONG_DOUBLE +strong_alias (__cexp, __cexpl) +weak_alias (__cexp, cexpl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_cexpf.c b/newlib/libc/sys/linux/cmath/s_cexpf.c new file mode 100644 index 000000000..93bfe2049 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cexpf.c @@ -0,0 +1,123 @@ +/* Return value of complex exponential function for float complex value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ float +__cexpf (__complex__ float x) +{ + __complex__ float retval; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + float exp_val = __ieee754_expf (__real__ x); + float sinix, cosix; + + __sincosf (__imag__ x, &sinix, &cosix); + + if (isfinite (exp_val)) + { + __real__ retval = exp_val * cosix; + __imag__ retval = exp_val * sinix; + } + else + { + __real__ retval = __copysignf (exp_val, cosix); + __imag__ retval = __copysignf (exp_val, sinix); + } + } + else + { + /* If the imaginary part is +-inf or NaN and the real part + is not +-inf the result is NaN + iNaN. */ + __real__ retval = __nanf (""); + __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + float value = signbit (__real__ x) ? 0.0 : HUGE_VALF; + + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = value; + __imag__ retval = __imag__ x; + } + else + { + float sinix, cosix; + + __sincosf (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysignf (value, cosix); + __imag__ retval = __copysignf (value, sinix); + } + } + else if (signbit (__real__ x) == 0) + { + __real__ retval = HUGE_VALF; + __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = 0.0; + __imag__ retval = __copysignf (0.0, __imag__ x); + } + } + else + { + /* If the real part is NaN the result is NaN + iNaN. */ + __real__ retval = __nanf (""); + __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + if (rcls != FP_NAN || icls != FP_NAN) + feraiseexcept (FE_INVALID); +#endif + } + + return retval; +} +weak_alias (__cexpf, cexpf) diff --git a/newlib/libc/sys/linux/cmath/s_cexpl.c b/newlib/libc/sys/linux/cmath/s_cexpl.c new file mode 100644 index 000000000..cf6bc974a --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cexpl.c @@ -0,0 +1,123 @@ +/* Return value of complex exponential function for long double complex value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ long double +__cexpl (__complex__ long double x) +{ + __complex__ long double retval; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + long double exp_val = __ieee754_expl (__real__ x); + long double sinix, cosix; + + __sincosl (__imag__ x, &sinix, &cosix); + + if (isfinite (exp_val)) + { + __real__ retval = exp_val * cosix; + __imag__ retval = exp_val * sinix; + } + else + { + __real__ retval = __copysignl (exp_val, cosix); + __imag__ retval = __copysignl (exp_val, sinix); + } + } + else + { + /* If the imaginary part is +-inf or NaN and the real part + is not +-inf the result is NaN + iNaN. */ + __real__ retval = __nanl (""); + __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL; + + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = value; + __imag__ retval = __imag__ x; + } + else + { + long double sinix, cosix; + + __sincosl (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysignl (value, cosix); + __imag__ retval = __copysignl (value, sinix); + } + } + else if (signbit (__real__ x) == 0) + { + __real__ retval = HUGE_VALL; + __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = 0.0; + __imag__ retval = __copysignl (0.0, __imag__ x); + } + } + else + { + /* If the real part is NaN the result is NaN + iNaN. */ + __real__ retval = __nanl (""); + __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + if (rcls != FP_NAN || icls != FP_NAN) + feraiseexcept (FE_INVALID); +#endif + } + + return retval; +} +weak_alias (__cexpl, cexpl) diff --git a/newlib/libc/sys/linux/cmath/s_clog.c b/newlib/libc/sys/linux/cmath/s_clog.c new file mode 100644 index 000000000..f796024b4 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_clog.c @@ -0,0 +1,65 @@ +/* Compute complex natural logarithm. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ double +__clog (__complex__ double x) +{ + __complex__ double result; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls == FP_ZERO && icls == FP_ZERO) + { + /* Real and imaginary part are 0.0. */ + __imag__ result = signbit (__real__ x) ? M_PI : 0.0; + __imag__ result = __copysign (__imag__ result, __imag__ x); + /* Yes, the following line raises an exception. */ + __real__ result = -1.0 / fabs (__real__ x); + } + else if (rcls != FP_NAN && icls != FP_NAN) + { + /* Neither real nor imaginary part is NaN. */ + __real__ result = __ieee754_log (__ieee754_hypot (__real__ x, + __imag__ x)); + __imag__ result = __ieee754_atan2 (__imag__ x, __real__ x); + } + else + { + __imag__ result = __nan (""); + if (rcls == FP_INFINITE || icls == FP_INFINITE) + /* Real or imaginary part is infinite. */ + __real__ result = HUGE_VAL; + else + __real__ result = __nan (""); + } + + return result; +} +weak_alias (__clog, clog) +#ifdef NO_LONG_DOUBLE +strong_alias (__clog, __clogl) +weak_alias (__clog, clogl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_clog10.c b/newlib/libc/sys/linux/cmath/s_clog10.c new file mode 100644 index 000000000..62c2ca724 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_clog10.c @@ -0,0 +1,65 @@ +/* Compute complex base 10 logarithm. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ double +__clog10 (__complex__ double x) +{ + __complex__ double result; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls == FP_ZERO && icls == FP_ZERO) + { + /* Real and imaginary part are 0.0. */ + __imag__ result = signbit (__real__ x) ? M_PI : 0.0; + __imag__ result = __copysign (__imag__ result, __imag__ x); + /* Yes, the following line raises an exception. */ + __real__ result = -1.0 / fabs (__real__ x); + } + else if (rcls != FP_NAN && icls != FP_NAN) + { + /* Neither real nor imaginary part is NaN. */ + __real__ result = __ieee754_log10 (__ieee754_hypot (__real__ x, + __imag__ x)); + __imag__ result = M_LOG10E * __ieee754_atan2 (__imag__ x, __real__ x); + } + else + { + __imag__ result = __nan (""); + if (rcls == FP_INFINITE || icls == FP_INFINITE) + /* Real or imaginary part is infinite. */ + __real__ result = HUGE_VAL; + else + __real__ result = __nan (""); + } + + return result; +} +weak_alias (__clog10, clog10) +#ifdef NO_LONG_DOUBLE +strong_alias (__clog10, __clog10l) +weak_alias (__clog10, clog10l) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_clog10f.c b/newlib/libc/sys/linux/cmath/s_clog10f.c new file mode 100644 index 000000000..6d60c5fc2 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_clog10f.c @@ -0,0 +1,61 @@ +/* Compute complex base 10 logarithm. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ float +__clog10f (__complex__ float x) +{ + __complex__ float result; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls == FP_ZERO && icls == FP_ZERO) + { + /* Real and imaginary part are 0.0. */ + __imag__ result = signbit (__real__ x) ? M_PI : 0.0; + __imag__ result = __copysignf (__imag__ result, __imag__ x); + /* Yes, the following line raises an exception. */ + __real__ result = -1.0 / fabsf (__real__ x); + } + else if (rcls != FP_NAN && icls != FP_NAN) + { + /* Neither real nor imaginary part is NaN. */ + __real__ result = __ieee754_log10f (__ieee754_hypotf (__real__ x, + __imag__ x)); + __imag__ result = M_LOG10E * __ieee754_atan2f (__imag__ x, __real__ x); + } + else + { + __imag__ result = __nanf (""); + if (rcls == FP_INFINITE || icls == FP_INFINITE) + /* Real or imaginary part is infinite. */ + __real__ result = HUGE_VALF; + else + __real__ result = __nanf (""); + } + + return result; +} +weak_alias (__clog10f, clog10f) diff --git a/newlib/libc/sys/linux/cmath/s_clog10l.c b/newlib/libc/sys/linux/cmath/s_clog10l.c new file mode 100644 index 000000000..f901543d0 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_clog10l.c @@ -0,0 +1,61 @@ +/* Compute complex base 10 logarithm. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ long double +__clog10l (__complex__ long double x) +{ + __complex__ long double result; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls == FP_ZERO && icls == FP_ZERO) + { + /* Real and imaginary part are 0.0. */ + __imag__ result = signbit (__real__ x) ? M_PIl : 0.0; + __imag__ result = __copysignl (__imag__ result, __imag__ x); + /* Yes, the following line raises an exception. */ + __real__ result = -1.0 / fabsl (__real__ x); + } + else if (rcls != FP_NAN && icls != FP_NAN) + { + /* Neither real nor imaginary part is NaN. */ + __real__ result = __ieee754_log10l (__ieee754_hypotl (__real__ x, + __imag__ x)); + __imag__ result = M_LOG10El * __ieee754_atan2l (__imag__ x, __real__ x); + } + else + { + __imag__ result = __nanl (""); + if (rcls == FP_INFINITE || icls == FP_INFINITE) + /* Real or imaginary part is infinite. */ + __real__ result = HUGE_VALL; + else + __real__ result = __nanl (""); + } + + return result; +} +weak_alias (__clog10l, clog10l) diff --git a/newlib/libc/sys/linux/cmath/s_clogf.c b/newlib/libc/sys/linux/cmath/s_clogf.c new file mode 100644 index 000000000..c7151f2e5 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_clogf.c @@ -0,0 +1,61 @@ +/* Compute complex natural logarithm. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ float +__clogf (__complex__ float x) +{ + __complex__ float result; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls == FP_ZERO && icls == FP_ZERO) + { + /* Real and imaginary part are 0.0. */ + __imag__ result = signbit (__real__ x) ? M_PI : 0.0; + __imag__ result = __copysignf (__imag__ result, __imag__ x); + /* Yes, the following line raises an exception. */ + __real__ result = -1.0 / fabsf (__real__ x); + } + else if (rcls != FP_NAN && icls != FP_NAN) + { + /* Neither real nor imaginary part is NaN. */ + __real__ result = __ieee754_logf (__ieee754_hypotf (__real__ x, + __imag__ x)); + __imag__ result = __ieee754_atan2f (__imag__ x, __real__ x); + } + else + { + __imag__ result = __nanf (""); + if (rcls == FP_INFINITE || icls == FP_INFINITE) + /* Real or imaginary part is infinite. */ + __real__ result = HUGE_VALF; + else + __real__ result = __nanf (""); + } + + return result; +} +weak_alias (__clogf, clogf) diff --git a/newlib/libc/sys/linux/cmath/s_clogl.c b/newlib/libc/sys/linux/cmath/s_clogl.c new file mode 100644 index 000000000..43118f768 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_clogl.c @@ -0,0 +1,61 @@ +/* Compute complex natural logarithm. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ long double +__clogl (__complex__ long double x) +{ + __complex__ long double result; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls == FP_ZERO && icls == FP_ZERO) + { + /* Real and imaginary part are 0.0. */ + __imag__ result = signbit (__real__ x) ? M_PIl : 0.0; + __imag__ result = __copysignl (__imag__ result, __imag__ x); + /* Yes, the following line raises an exception. */ + __real__ result = -1.0 / fabsl (__real__ x); + } + else if (rcls != FP_NAN && icls != FP_NAN) + { + /* Neither real nor imaginary part is NaN. */ + __real__ result = __ieee754_logl (__ieee754_hypotl (__real__ x, + __imag__ x)); + __imag__ result = __ieee754_atan2l (__imag__ x, __real__ x); + } + else + { + __imag__ result = __nanl (""); + if (rcls == FP_INFINITE || icls == FP_INFINITE) + /* Real or imaginary part is infinite. */ + __real__ result = HUGE_VALL; + else + __real__ result = __nanl (""); + } + + return result; +} +weak_alias (__clogl, clogl) diff --git a/newlib/libc/sys/linux/cmath/s_cpow.c b/newlib/libc/sys/linux/cmath/s_cpow.c new file mode 100644 index 000000000..9018a8a65 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cpow.c @@ -0,0 +1,34 @@ +/* Complex power of double values. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ double +__cpow (__complex__ double x, __complex__ double c) +{ + return __cexp (c * __clog (x)); +} +weak_alias (__cpow, cpow) +#ifdef NO_LONG_DOUBLE +strong_alias (__cpow, __cpowl) +weak_alias (__cpow, cpowl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_cpowf.c b/newlib/libc/sys/linux/cmath/s_cpowf.c new file mode 100644 index 000000000..b0c032422 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cpowf.c @@ -0,0 +1,30 @@ +/* Complex power of float values. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ float +__cpowf (__complex__ float x, __complex__ float c) +{ + return __cexpf (c * __clogf (x)); +} +weak_alias (__cpowf, cpowf) diff --git a/newlib/libc/sys/linux/cmath/s_cpowl.c b/newlib/libc/sys/linux/cmath/s_cpowl.c new file mode 100644 index 000000000..4c358b3eb --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cpowl.c @@ -0,0 +1,30 @@ +/* Complex power of long double values. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + +__complex__ long double +__cpowl (__complex__ long double x, __complex__ long double c) +{ + return __cexpl (c * __clogl (x)); +} +weak_alias (__cpowl, cpowl) diff --git a/newlib/libc/sys/linux/cmath/s_cproj.c b/newlib/libc/sys/linux/cmath/s_cproj.c new file mode 100644 index 000000000..6c9e41704 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cproj.c @@ -0,0 +1,51 @@ +/* Compute projection of complex double value to Riemann sphere. + Copyright (C) 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ double +__cproj (__complex__ double x) +{ + __complex__ double res; + + if (isnan (__real__ x) && isnan (__imag__ x)) + return x; + else if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + __real__ res = INFINITY; + __imag__ res = __copysign (0.0, __imag__ x); + } + else + { + double den = __real__ x * __real__ x + __imag__ x * __imag__ x + 1.0; + + __real__ res = (2.0 * __real__ x) / den; + __imag__ res = (2.0 * __imag__ x) / den; + } + + return res; +} +weak_alias (__cproj, cproj) +#ifdef NO_LONG_DOUBLE +strong_alias (__cproj, __cprojl) +weak_alias (__cproj, cprojl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_cprojf.c b/newlib/libc/sys/linux/cmath/s_cprojf.c new file mode 100644 index 000000000..a302078b5 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cprojf.c @@ -0,0 +1,47 @@ +/* Compute projection of complex float value to Riemann sphere. + Copyright (C) 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include "math_private.h" + +__complex__ float +__cprojf (__complex__ float x) +{ + __complex__ float res; + + if (isnan (__real__ x) && isnan (__imag__ x)) + return x; + else if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + __real__ res = INFINITY; + __imag__ res = __copysignf (0.0, __imag__ x); + } + else + { + float den = __real__ x * __real__ x + __imag__ x * __imag__ x + 1.0; + + __real__ res = (2.0 * __real__ x) / den; + __imag__ res = (2.0 * __imag__ x) / den; + } + + return res; +} +weak_alias (__cprojf, cprojf) diff --git a/newlib/libc/sys/linux/cmath/s_cprojl.c b/newlib/libc/sys/linux/cmath/s_cprojl.c new file mode 100644 index 000000000..c70cdc47d --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_cprojl.c @@ -0,0 +1,48 @@ +/* Compute projection of complex long double value to Riemann sphere. + Copyright (C) 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + +__complex__ long double +__cprojl (__complex__ long double x) +{ + __complex__ long double res; + + if (isnan (__real__ x) && isnan (__imag__ x)) + return x; + else if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + __real__ res = INFINITY; + __imag__ res = __copysignl (0.0, __imag__ x); + } + else + { + long double den = (__real__ x * __real__ x + __imag__ x * __imag__ x + + 1.0); + + __real__ res = (2.0 * __real__ x) / den; + __imag__ res = (2.0 * __imag__ x) / den; + } + + return res; +} +weak_alias (__cprojl, cprojl) diff --git a/newlib/libc/sys/linux/cmath/s_csin.c b/newlib/libc/sys/linux/cmath/s_csin.c new file mode 100644 index 000000000..eb380e2c3 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csin.c @@ -0,0 +1,131 @@ +/* Complex sine function for double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ double +__csin (__complex__ double x) +{ + __complex__ double retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabs (__real__ x); + + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + double sinh_val = __ieee754_sinh (__imag__ x); + double cosh_val = __ieee754_cosh (__imag__ x); + double sinix, cosix; + + __sincos (__real__ x, &sinix, &cosix); + + __real__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * cosix; + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = __nan (""); + __imag__ retval = __imag__ x; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nan (""); + __imag__ retval = __nan (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + } + else if (icls == FP_INFINITE) + { + /* Imaginary part is infinite. */ + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __imag__ x; + } + else if (rcls > FP_ZERO) + { + /* Real part is finite. */ + double sinix, cosix; + + __sincos (__real__ x, &sinix, &cosix); + + __real__ retval = __copysign (HUGE_VAL, sinix); + __imag__ retval = __copysign (HUGE_VAL, cosix); + + if (negate) + __real__ retval = -__real__ retval; + if (signbit (__imag__ x)) + __imag__ retval = -__imag__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = __nan (""); + __imag__ retval = HUGE_VAL; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + if (rcls == FP_ZERO) + __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0); + else + __real__ retval = __nan (""); + __imag__ retval = __nan (""); + } + + return retval; +} +weak_alias (__csin, csin) +#ifdef NO_LONG_DOUBLE +strong_alias (__csin, __csinl) +weak_alias (__csin, csinl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_csinf.c b/newlib/libc/sys/linux/cmath/s_csinf.c new file mode 100644 index 000000000..b7278810d --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csinf.c @@ -0,0 +1,127 @@ +/* Complex sine function for float. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ float +__csinf (__complex__ float x) +{ + __complex__ float retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabsf (__real__ x); + + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + float sinh_val = __ieee754_sinhf (__imag__ x); + float cosh_val = __ieee754_coshf (__imag__ x); + float sinix, cosix; + + __sincosf (__real__ x, &sinix, &cosix); + + __real__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * cosix; + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = __nanf (""); + __imag__ retval = __imag__ x; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nanf (""); + __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + } + else if (icls == FP_INFINITE) + { + /* Imaginary part is infinite. */ + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __imag__ x; + } + else if (rcls > FP_ZERO) + { + /* Real part is finite. */ + float sinix, cosix; + + __sincosf (__real__ x, &sinix, &cosix); + + __real__ retval = __copysignf (HUGE_VALF, sinix); + __imag__ retval = __copysignf (HUGE_VALF, cosix); + + if (negate) + __real__ retval = -__real__ retval; + if (signbit (__imag__ x)) + __imag__ retval = -__imag__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = __nanf (""); + __imag__ retval = HUGE_VALF; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + if (rcls == FP_ZERO) + __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0); + else + __real__ retval = __nanf (""); + __imag__ retval = __nanf (""); + } + + return retval; +} +weak_alias (__csinf, csinf) diff --git a/newlib/libc/sys/linux/cmath/s_csinh.c b/newlib/libc/sys/linux/cmath/s_csinh.c new file mode 100644 index 000000000..f0e0cc61f --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csinh.c @@ -0,0 +1,126 @@ +/* Complex sine hyperbole function for double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ double +__csinh (__complex__ double x) +{ + __complex__ double retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabs (__real__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + double sinh_val = __ieee754_sinh (__real__ x); + double cosh_val = __ieee754_cosh (__real__ x); + double sinix, cosix; + + __sincos (__imag__ x, &sinix, &cosix); + + __real__ retval = sinh_val * cosix; + __imag__ retval = cosh_val * sinix; + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __nan ("") + __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nan (""); + __imag__ retval = __nan (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = negate ? -HUGE_VAL : HUGE_VAL; + __imag__ retval = __imag__ x; + } + else if (icls > FP_ZERO) + { + /* Imaginary part is finite. */ + double sinix, cosix; + + __sincos (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysign (HUGE_VAL, cosix); + __imag__ retval = __copysign (HUGE_VAL, sinix); + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = HUGE_VAL; + __imag__ retval = __nan ("") + __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __real__ retval = __nan (""); + __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nan (""); + } + + return retval; +} +weak_alias (__csinh, csinh) +#ifdef NO_LONG_DOUBLE +strong_alias (__csinh, __csinhl) +weak_alias (__csinh, csinhl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_csinhf.c b/newlib/libc/sys/linux/cmath/s_csinhf.c new file mode 100644 index 000000000..5cf80d0f9 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csinhf.c @@ -0,0 +1,122 @@ +/* Complex sine hyperbole function for float. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ float +__csinhf (__complex__ float x) +{ + __complex__ float retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabsf (__real__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + float sinh_val = __ieee754_sinhf (__real__ x); + float cosh_val = __ieee754_coshf (__real__ x); + float sinix, cosix; + + __sincosf (__imag__ x, &sinix, &cosix); + + __real__ retval = sinh_val * cosix; + __imag__ retval = cosh_val * sinix; + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __nanf ("") + __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nanf (""); + __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = negate ? -HUGE_VALF : HUGE_VALF; + __imag__ retval = __imag__ x; + } + else if (icls > FP_ZERO) + { + /* Imaginary part is finite. */ + float sinix, cosix; + + __sincosf (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysignf (HUGE_VALF, cosix); + __imag__ retval = __copysignf (HUGE_VALF, sinix); + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = HUGE_VALF; + __imag__ retval = __nanf ("") + __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __real__ retval = __nanf (""); + __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanf (""); + } + + return retval; +} +weak_alias (__csinhf, csinhf) diff --git a/newlib/libc/sys/linux/cmath/s_csinhl.c b/newlib/libc/sys/linux/cmath/s_csinhl.c new file mode 100644 index 000000000..226075634 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csinhl.c @@ -0,0 +1,122 @@ +/* Complex sine hyperbole function for long double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ long double +__csinhl (__complex__ long double x) +{ + __complex__ long double retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabsl (__real__ x); + + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + long double sinh_val = __ieee754_sinhl (__real__ x); + long double cosh_val = __ieee754_coshl (__real__ x); + long double sinix, cosix; + + __sincosl (__imag__ x, &sinix, &cosix); + + __real__ retval = sinh_val * cosix; + __imag__ retval = cosh_val * sinix; + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __nanl ("") + __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nanl (""); + __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + } + else if (rcls == FP_INFINITE) + { + /* Real part is infinite. */ + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = negate ? -HUGE_VALL : HUGE_VALL; + __imag__ retval = __imag__ x; + } + else if (icls > FP_ZERO) + { + /* Imaginary part is finite. */ + long double sinix, cosix; + + __sincosl (__imag__ x, &sinix, &cosix); + + __real__ retval = __copysignl (HUGE_VALL, cosix); + __imag__ retval = __copysignl (HUGE_VALL, sinix); + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = HUGE_VALL; + __imag__ retval = __nanl ("") + __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + __real__ retval = __nanl (""); + __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanl (""); + } + + return retval; +} +weak_alias (__csinhl, csinhl) diff --git a/newlib/libc/sys/linux/cmath/s_csinl.c b/newlib/libc/sys/linux/cmath/s_csinl.c new file mode 100644 index 000000000..f7a1c4360 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csinl.c @@ -0,0 +1,127 @@ +/* Complex sine function for long double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ long double +__csinl (__complex__ long double x) +{ + __complex__ long double retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabsl (__real__ x); + + if (icls >= FP_ZERO) + { + /* Imaginary part is finite. */ + if (rcls >= FP_ZERO) + { + /* Real part is finite. */ + long double sinh_val = __ieee754_sinhl (__imag__ x); + long double cosh_val = __ieee754_coshl (__imag__ x); + long double sinix, cosix; + + __sincosl (__real__ x, &sinix, &cosix); + + __real__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * cosix; + + if (negate) + __real__ retval = -__real__ retval; + } + else + { + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = __nanl (""); + __imag__ retval = __imag__ x; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nanl (""); + __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } + } + } + else if (icls == FP_INFINITE) + { + /* Imaginary part is infinite. */ + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __imag__ x; + } + else if (rcls > FP_ZERO) + { + /* Real part is finite. */ + long double sinix, cosix; + + __sincosl (__real__ x, &sinix, &cosix); + + __real__ retval = __copysignl (HUGE_VALL, sinix); + __imag__ retval = __copysignl (HUGE_VALL, cosix); + + if (negate) + __real__ retval = -__real__ retval; + if (signbit (__imag__ x)) + __imag__ retval = -__imag__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = __nanl (""); + __imag__ retval = HUGE_VALL; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + if (rcls == FP_ZERO) + __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0); + else + __real__ retval = __nanl (""); + __imag__ retval = __nanl (""); + } + + return retval; +} +weak_alias (__csinl, csinl) diff --git a/newlib/libc/sys/linux/cmath/s_csqrt.c b/newlib/libc/sys/linux/cmath/s_csqrt.c new file mode 100644 index 000000000..0bb6690b1 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csqrt.c @@ -0,0 +1,114 @@ +/* Complex square root of double value. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Based on an algorithm by Stephen L. Moshier . + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ double +__csqrt (__complex__ double x) +{ + __complex__ double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = HUGE_VAL; + __imag__ res = __imag__ x; + } + else if (rcls == FP_INFINITE) + { + if (__real__ x < 0.0) + { + __real__ res = icls == FP_NAN ? __nan ("") : 0; + __imag__ res = __copysign (HUGE_VAL, __imag__ x); + } + else + { + __real__ res = __real__ x; + __imag__ res = (icls == FP_NAN + ? __nan ("") : __copysign (0.0, __imag__ x)); + } + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + } + } + else + { + if (icls == FP_ZERO) + { + if (__real__ x < 0.0) + { + __real__ res = 0.0; + __imag__ res = __copysign (__ieee754_sqrt (-__real__ x), + __imag__ x); + } + else + { + __real__ res = fabs (__ieee754_sqrt (__real__ x)); + __imag__ res = __copysign (0.0, __imag__ x); + } + } + else if (rcls == FP_ZERO) + { + double r = __ieee754_sqrt (0.5 * fabs (__imag__ x)); + + __real__ res = __copysign (r, __imag__ x); + __imag__ res = r; + } + else + { + double d, r, s; + + d = __ieee754_hypot (__real__ x, __imag__ x); + /* Use the identity 2 Re res Im res = Im x + to avoid cancellation error in d +/- Re x. */ + if (__real__ x > 0) + { + r = __ieee754_sqrt (0.5 * d + 0.5 * __real__ x); + s = (0.5 * __imag__ x) / r; + } + else + { + s = __ieee754_sqrt (0.5 * d - 0.5 * __real__ x); + r = fabs ((0.5 * __imag__ x) / s); + } + + __real__ res = r; + __imag__ res = __copysign (s, __imag__ x); + } + } + + return res; +} +weak_alias (__csqrt, csqrt) +#ifdef NO_LONG_DOUBLE +strong_alias (__csqrt, __csqrtl) +weak_alias (__csqrt, csqrtl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_csqrtf.c b/newlib/libc/sys/linux/cmath/s_csqrtf.c new file mode 100644 index 000000000..f7b18368b --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csqrtf.c @@ -0,0 +1,110 @@ +/* Complex square root of float value. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Based on an algorithm by Stephen L. Moshier . + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ float +__csqrtf (__complex__ float x) +{ + __complex__ float res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = HUGE_VALF; + __imag__ res = __imag__ x; + } + else if (rcls == FP_INFINITE) + { + if (__real__ x < 0.0) + { + __real__ res = icls == FP_NAN ? __nanf ("") : 0; + __imag__ res = __copysignf (HUGE_VALF, __imag__ x); + } + else + { + __real__ res = __real__ x; + __imag__ res = (icls == FP_NAN + ? __nanf ("") : __copysignf (0.0, __imag__ x)); + } + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + } + } + else + { + if (icls == FP_ZERO) + { + if (__real__ x < 0.0) + { + __real__ res = 0.0; + __imag__ res = __copysignf (__ieee754_sqrtf (-__real__ x), + __imag__ x); + } + else + { + __real__ res = fabsf (__ieee754_sqrtf (__real__ x)); + __imag__ res = __copysignf (0.0, __imag__ x); + } + } + else if (rcls == FP_ZERO) + { + float r = __ieee754_sqrtf (0.5 * fabsf (__imag__ x)); + + __real__ res = __copysignf (r, __imag__ x); + __imag__ res = r; + } + else + { + float d, r, s; + + d = __ieee754_hypotf (__real__ x, __imag__ x); + /* Use the identity 2 Re res Im res = Im x + to avoid cancellation error in d +/- Re x. */ + if (__real__ x > 0) + { + r = __ieee754_sqrtf (0.5f * d + 0.5f * __real__ x); + s = (0.5f * __imag__ x) / r; + } + else + { + s = __ieee754_sqrtf (0.5f * d - 0.5f * __real__ x); + r = fabsf ((0.5f * __imag__ x) / s); + } + + __real__ res = r; + __imag__ res = __copysignf (s, __imag__ x); + } + } + + return res; +} +weak_alias (__csqrtf, csqrtf) diff --git a/newlib/libc/sys/linux/cmath/s_csqrtl.c b/newlib/libc/sys/linux/cmath/s_csqrtl.c new file mode 100644 index 000000000..8e27750a0 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_csqrtl.c @@ -0,0 +1,110 @@ +/* Complex square root of long double value. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Based on an algorithm by Stephen L. Moshier . + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "math_private.h" + + +__complex__ long double +__csqrtl (__complex__ long double x) +{ + __complex__ long double res; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + { + if (icls == FP_INFINITE) + { + __real__ res = HUGE_VALL; + __imag__ res = __imag__ x; + } + else if (rcls == FP_INFINITE) + { + if (__real__ x < 0.0) + { + __real__ res = icls == FP_NAN ? __nanl ("") : 0; + __imag__ res = __copysignl (HUGE_VALL, __imag__ x); + } + else + { + __real__ res = __real__ x; + __imag__ res = (icls == FP_NAN + ? __nanl ("") : __copysignl (0.0, __imag__ x)); + } + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + } + } + else + { + if (icls == FP_ZERO) + { + if (__real__ x < 0.0) + { + __real__ res = 0.0; + __imag__ res = __copysignl (__ieee754_sqrtl (-__real__ x), + __imag__ x); + } + else + { + __real__ res = fabsl (__ieee754_sqrtl (__real__ x)); + __imag__ res = __copysignl (0.0, __imag__ x); + } + } + else if (rcls == FP_ZERO) + { + long double r = __ieee754_sqrtl (0.5 * fabsl (__imag__ x)); + + __real__ res = __copysignl (r, __imag__ x); + __imag__ res = r; + } + else + { + long double d, r, s; + + d = __ieee754_hypotl (__real__ x, __imag__ x); + /* Use the identity 2 Re res Im res = Im x + to avoid cancellation error in d +/- Re x. */ + if (__real__ x > 0) + { + r = __ieee754_sqrtl (0.5L * d + 0.5L * __real__ x); + s = (0.5L * __imag__ x) / r; + } + else + { + s = __ieee754_sqrtl (0.5L * d - 0.5L * __real__ x); + r = fabsl ((0.5L * __imag__ x) / s); + } + + __real__ res = r; + __imag__ res = __copysignl (s, __imag__ x); + } + } + + return res; +} +weak_alias (__csqrtl, csqrtl) diff --git a/newlib/libc/sys/linux/cmath/s_ctan.c b/newlib/libc/sys/linux/cmath/s_ctan.c new file mode 100644 index 000000000..6a09fe465 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ctan.c @@ -0,0 +1,74 @@ +/* Complex tangent function for double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ double +__ctan (__complex__ double x) +{ + __complex__ double res; + + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + if (__isinf (__imag__ x)) + { + __real__ res = __copysign (0.0, __real__ x); + __imag__ res = __copysign (1.0, __imag__ x); + } + else if (__real__ x == 0.0) + { + res = x; + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + +#ifdef FE_INVALID + if (__isinf (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + double sin2rx, cos2rx; + double den; + + __sincos (2.0 * __real__ x, &sin2rx, &cos2rx); + + den = cos2rx + __ieee754_cosh (2.0 * __imag__ x); + + __real__ res = sin2rx / den; + __imag__ res = __ieee754_sinh (2.0 * __imag__ x) / den; + } + + return res; +} +weak_alias (__ctan, ctan) +#ifdef NO_LONG_DOUBLE +strong_alias (__ctan, __ctanl) +weak_alias (__ctan, ctanl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_ctanf.c b/newlib/libc/sys/linux/cmath/s_ctanf.c new file mode 100644 index 000000000..89bc84741 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ctanf.c @@ -0,0 +1,70 @@ +/* Complex tangent function for float. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ float +__ctanf (__complex__ float x) +{ + __complex__ float res; + + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + if (__isinff (__imag__ x)) + { + __real__ res = __copysignf (0.0, __real__ x); + __imag__ res = __copysignf (1.0, __imag__ x); + } + else if (__real__ x == 0.0) + { + res = x; + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + +#ifdef FE_INVALID + if (__isinff (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + float sin2rx, cos2rx; + float den; + + __sincosf (2.0 * __real__ x, &sin2rx, &cos2rx); + + den = cos2rx + __ieee754_coshf (2.0 * __imag__ x); + + __real__ res = sin2rx / den; + __imag__ res = __ieee754_sinhf (2.0 * __imag__ x) / den; + } + + return res; +} +weak_alias (__ctanf, ctanf) diff --git a/newlib/libc/sys/linux/cmath/s_ctanh.c b/newlib/libc/sys/linux/cmath/s_ctanh.c new file mode 100644 index 000000000..971cd9040 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ctanh.c @@ -0,0 +1,74 @@ +/* Complex hyperbole tangent for double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ double +__ctanh (__complex__ double x) +{ + __complex__ double res; + + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + if (__isinf (__real__ x)) + { + __real__ res = __copysign (1.0, __real__ x); + __imag__ res = __copysign (0.0, __imag__ x); + } + else if (__imag__ x == 0.0) + { + res = x; + } + else + { + __real__ res = __nan (""); + __imag__ res = __nan (""); + +#ifdef FE_INVALID + if (__isinf (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + double sin2ix, cos2ix; + double den; + + __sincos (2.0 * __imag__ x, &sin2ix, &cos2ix); + + den = (__ieee754_cosh (2.0 * __real__ x) + cos2ix); + + __real__ res = __ieee754_sinh (2.0 * __real__ x) / den; + __imag__ res = sin2ix / den; + } + + return res; +} +weak_alias (__ctanh, ctanh) +#ifdef NO_LONG_DOUBLE +strong_alias (__ctanh, __ctanhl) +weak_alias (__ctanh, ctanhl) +#endif diff --git a/newlib/libc/sys/linux/cmath/s_ctanhf.c b/newlib/libc/sys/linux/cmath/s_ctanhf.c new file mode 100644 index 000000000..b9e3c57fc --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ctanhf.c @@ -0,0 +1,70 @@ +/* Complex hyperbole tangent for float. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ float +__ctanhf (__complex__ float x) +{ + __complex__ float res; + + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + if (__isinff (__real__ x)) + { + __real__ res = __copysignf (1.0, __real__ x); + __imag__ res = __copysignf (0.0, __imag__ x); + } + else if (__imag__ x == 0.0) + { + res = x; + } + else + { + __real__ res = __nanf (""); + __imag__ res = __nanf (""); + +#ifdef FE_INVALID + if (__isinff (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + float sin2ix, cos2ix; + float den; + + __sincosf (2.0 * __imag__ x, &sin2ix, &cos2ix); + + den = (__ieee754_coshf (2.0 * __real__ x) + cos2ix); + + __real__ res = __ieee754_sinhf (2.0 * __real__ x) / den; + __imag__ res = sin2ix / den; + } + + return res; +} +weak_alias (__ctanhf, ctanhf) diff --git a/newlib/libc/sys/linux/cmath/s_ctanhl.c b/newlib/libc/sys/linux/cmath/s_ctanhl.c new file mode 100644 index 000000000..7bf6b3919 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ctanhl.c @@ -0,0 +1,70 @@ +/* Complex hyperbole tangent for long double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ long double +__ctanhl (__complex__ long double x) +{ + __complex__ long double res; + + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + if (__isinfl (__real__ x)) + { + __real__ res = __copysignl (1.0, __real__ x); + __imag__ res = __copysignl (0.0, __imag__ x); + } + else if (__imag__ x == 0.0) + { + res = x; + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + +#ifdef FE_INVALID + if (__isinfl (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + long double sin2ix, cos2ix; + long double den; + + __sincosl (2.0 * __imag__ x, &sin2ix, &cos2ix); + + den = (__ieee754_coshl (2.0 * __real__ x) + cos2ix); + + __real__ res = __ieee754_sinhl (2.0 * __real__ x) / den; + __imag__ res = sin2ix / den; + } + + return res; +} +weak_alias (__ctanhl, ctanhl) diff --git a/newlib/libc/sys/linux/cmath/s_ctanl.c b/newlib/libc/sys/linux/cmath/s_ctanl.c new file mode 100644 index 000000000..fa153e9b3 --- /dev/null +++ b/newlib/libc/sys/linux/cmath/s_ctanl.c @@ -0,0 +1,70 @@ +/* Complex tangent function for long double. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "math_private.h" + + +__complex__ long double +__ctanl (__complex__ long double x) +{ + __complex__ long double res; + + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) + { + if (__isinfl (__imag__ x)) + { + __real__ res = __copysignl (0.0, __real__ x); + __imag__ res = __copysignl (1.0, __imag__ x); + } + else if (__real__ x == 0.0) + { + res = x; + } + else + { + __real__ res = __nanl (""); + __imag__ res = __nanl (""); + +#ifdef FE_INVALID + if (__isinfl (__real__ x)) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + long double sin2rx, cos2rx; + long double den; + + __sincosl (2.0 * __real__ x, &sin2rx, &cos2rx); + + den = cos2rx + __ieee754_coshl (2.0 * __imag__ x); + + __real__ res = sin2rx / den; + __imag__ res = __ieee754_sinhl (2.0 * __imag__ x) / den; + } + + return res; +} +weak_alias (__ctanl, ctanl) diff --git a/newlib/libc/sys/linux/configure b/newlib/libc/sys/linux/configure index f5e2c8860..7b7ebed61 100755 --- a/newlib/libc/sys/linux/configure +++ b/newlib/libc/sys/linux/configure @@ -3071,7 +3071,7 @@ done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "Makefile cmath/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then diff --git a/newlib/libc/sys/linux/configure.in b/newlib/libc/sys/linux/configure.in index 75143b00b..2e01a4f44 100644 --- a/newlib/libc/sys/linux/configure.in +++ b/newlib/libc/sys/linux/configure.in @@ -32,4 +32,4 @@ AC_SUBST(LINUX_MACH_LIB) AC_CONFIG_SUBDIRS(machine $EXTRA_DIRS) -AC_OUTPUT(Makefile) +AC_OUTPUT(Makefile cmath/Makefile) diff --git a/newlib/libc/sys/linux/include/cmathcalls.h b/newlib/libc/sys/linux/include/cmathcalls.h new file mode 100644 index 000000000..c680c6d8e --- /dev/null +++ b/newlib/libc/sys/linux/include/cmathcalls.h @@ -0,0 +1,158 @@ +/* Prototype declarations for complex math functions; + helper file for . + Copyright (C) 1997, 1998, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* NOTE: Because of the special way this file is used by , this + file must NOT be protected from multiple inclusion as header files + usually are. + + This file provides prototype declarations for the math functions. + Most functions are declared using the macro: + + __MATHCALL (NAME, (ARGS...)); + + This means there is a function `NAME' returning `double' and a function + `NAMEf' returning `float'. Each place `_Mdouble_' appears in the + prototype, that is actually `double' in the prototype for `NAME' and + `float' in the prototype for `NAMEf'. Reentrant variant functions are + called `NAME_r' and `NAMEf_r'. + + Functions returning other types like `int' are declared using the macro: + + __MATHDECL (TYPE, NAME, (ARGS...)); + + This is just like __MATHCALL but for a function returning `TYPE' + instead of `_Mdouble_'. In all of these cases, there is still + both a `NAME' and a `NAMEf' that takes `float' arguments. */ + +#ifndef _COMPLEX_H +#error "Never use directly; include instead." +#endif + +#define _Mdouble_complex_ _Mdouble_ _Complex + + +/* Trigonometric functions. */ + +/* Arc cosine of Z. */ +__MATHCALL (cacos, (_Mdouble_complex_ __z)); +/* Arc sine of Z. */ +__MATHCALL (casin, (_Mdouble_complex_ __z)); +/* Arc tangent of Z. */ +__MATHCALL (catan, (_Mdouble_complex_ __z)); + +/* Cosine of Z. */ +__MATHCALL (ccos, (_Mdouble_complex_ __z)); +/* Sine of Z. */ +__MATHCALL (csin, (_Mdouble_complex_ __z)); +/* Tangent of Z. */ +__MATHCALL (ctan, (_Mdouble_complex_ __z)); + + +/* Hyperbolic functions. */ + +/* Hyperbolic arc cosine of Z. */ +__MATHCALL (cacosh, (_Mdouble_complex_ __z)); +/* Hyperbolic arc sine of Z. */ +__MATHCALL (casinh, (_Mdouble_complex_ __z)); +/* Hyperbolic arc tangent of Z. */ +__MATHCALL (catanh, (_Mdouble_complex_ __z)); + +/* Hyperbolic cosine of Z. */ +__MATHCALL (ccosh, (_Mdouble_complex_ __z)); +/* Hyperbolic sine of Z. */ +__MATHCALL (csinh, (_Mdouble_complex_ __z)); +/* Hyperbolic tangent of Z. */ +__MATHCALL (ctanh, (_Mdouble_complex_ __z)); + + +/* Exponential and logarithmic functions. */ + +/* Exponential function of Z. */ +__MATHCALL (cexp, (_Mdouble_complex_ __z)); + +/* Natural logarithm of Z. */ +__MATHCALL (clog, (_Mdouble_complex_ __z)); + +#ifdef __USE_GNU +/* The base 10 logarithm is not defined by the standard but to implement + the standard C++ library it is handy. */ +__MATHCALL (clog10, (_Mdouble_complex_ __z)); +#endif + +/* Power functions. */ + +/* Return X to the Y power. */ +__MATHCALL (cpow, (_Mdouble_complex_ __x, _Mdouble_complex_ __y)); + +/* Return the square root of Z. */ +__MATHCALL (csqrt, (_Mdouble_complex_ __z)); + + +/* Absolute value, conjugates, and projection. */ + +/* Absolute value of Z. */ +__MATHDECL (_Mdouble_,cabs, (_Mdouble_complex_ __z)); + +/* Argument value of Z. */ +__MATHDECL (_Mdouble_,carg, (_Mdouble_complex_ __z)); + +/* Complex conjugate of Z. */ +__MATHCALL (conj, (_Mdouble_complex_ __z)); + +/* Projection of Z onto the Riemann sphere. */ +__MATHCALL (cproj, (_Mdouble_complex_ __z)); + + +/* Decomposing complex values. */ + +/* Imaginary part of Z. */ +__MATHDECL (_Mdouble_,cimag, (_Mdouble_complex_ __z)); + +/* Real part of Z. */ +__MATHDECL (_Mdouble_,creal, (_Mdouble_complex_ __z)); + + +/* Now some optimized versions. GCC has handy notations for these + functions. Recent GCC handles these as builtin functions so does + not need inlines. */ +#if defined __GNUC__ && !__GNUC_PREREQ (2, 97) && defined __OPTIMIZE__ + +/* Imaginary part of Z. */ +extern __inline _Mdouble_ +__MATH_PRECNAME(cimag) (_Mdouble_complex_ __z) __THROW +{ + return __imag__ __z; +} + +/* Real part of Z. */ +extern __inline _Mdouble_ +__MATH_PRECNAME(creal) (_Mdouble_complex_ __z) __THROW +{ + return __real__ __z; +} + +/* Complex conjugate of Z. */ +extern __inline _Mdouble_complex_ +__MATH_PRECNAME(conj) (_Mdouble_complex_ __z) __THROW +{ + return __extension__ ~__z; +} + +#endif diff --git a/newlib/libc/sys/linux/include/complex.h b/newlib/libc/sys/linux/include/complex.h new file mode 100644 index 000000000..daa465674 --- /dev/null +++ b/newlib/libc/sys/linux/include/complex.h @@ -0,0 +1,108 @@ +/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99: 7.3 Complex arithmetic + */ + +#ifndef _COMPLEX_H +#define _COMPLEX_H 1 + +#include +#include + +__BEGIN_DECLS + +#define __CONCAT(x,y) x ## y +/* We might need to add support for more compilers here. But since ISO + C99 is out hopefully all maintained compilers will soon provide the data + types `float complex' and `double complex'. */ +#if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97) +# define _Complex __complex__ +#endif + +#define complex _Complex + +/* Narrowest imaginary unit. This depends on the floating-point + evaluation method. + XXX This probably has to go into a gcc related file. */ +#define _Complex_I (__extension__ 1.0iF) + +/* Another more descriptive name is `I'. + XXX Once we have the imaginary support switch this to _Imaginary_I. */ +#undef I +#define I _Complex_I + +/* The file contains the prototypes for all the + actual math functions. These macros are used for those prototypes, + so we can easily declare each function as both `name' and `__name', + and can declare the float versions `namef' and `__namef'. */ + +#define __MATHCALL(function, args) \ + __MATHDECL (_Mdouble_complex_,function, args) +#define __MATHDECL(type, function, args) \ + __MATHDECL_1(type, function, args); \ + __MATHDECL_1(type, __CONCAT(__,function), args) +#define __MATHDECL_1(type, function, args) \ + extern type __MATH_PRECNAME(function) args __THROW + +#define _Mdouble_ double +#define __MATH_PRECNAME(name) name +#include +#undef _Mdouble_ +#undef __MATH_PRECNAME + +/* Now the float versions. */ +#ifndef _Mfloat_ +# define _Mfloat_ float +#endif +#define _Mdouble_ _Mfloat_ +#ifdef __STDC__ +# define __MATH_PRECNAME(name) name##f +#else +# define __MATH_PRECNAME(name) name/**/f +#endif +#include +#undef _Mdouble_ +#undef __MATH_PRECNAME + +#if 0 +/* And the long double versions. It is non-critical to define them + here unconditionally since `long double' is required in ISO C99. */ +#if __STDC__ - 0 || __GNUC__ - 0 && !defined __NO_LONG_DOUBLE_MATH +# ifndef _Mlong_double_ +# define _Mlong_double_ long double +# endif +# define _Mdouble_ _Mlong_double_ +# ifdef __STDC__ +# define __MATH_PRECNAME(name) name##l +# else +# define __MATH_PRECNAME(name) name/**/l +# endif +# include +#endif +#endif +#undef _Mdouble_ +#undef __MATH_PRECNAME +#undef __MATHDECL_1 +#undef __MATHDECL +#undef __MATHCALL + +__END_DECLS + +#endif /* complex.h */ diff --git a/newlib/libc/sys/linux/machine/i386/huge_val.h b/newlib/libc/sys/linux/machine/i386/huge_val.h new file mode 100644 index 000000000..171517710 --- /dev/null +++ b/newlib/libc/sys/linux/machine/i386/huge_val.h @@ -0,0 +1,56 @@ +/* `HUGE_VAL' constants for ix86 (where it is infinity). + Used by and functions for overflow. + Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +/* ISO C99 extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */ + +# if __GNUC_PREREQ(2,96) + +# define HUGE_VALF (__extension__ 0x1.0p255f) +# define HUGE_VALL (__extension__ 0x1.0p32767L) + +# else + +# define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } + +# define __huge_valf_t union { unsigned char __c[4]; float __f; } +# ifdef __GNUC__ +# define HUGE_VALF (__extension__ \ + ((__huge_valf_t) { __c: __HUGE_VALF_bytes }).__f) +# else /* Not GCC. */ +static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; +# define HUGE_VALF (__huge_valf.__f) +# endif /* GCC. */ + + +# define __HUGE_VALL_bytes { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 } + +# define __huge_vall_t union { unsigned char __c[12]; long double __ld; } +# ifdef __GNUC__ +# define HUGE_VALL (__extension__ \ + ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld) +# else /* Not GCC. */ +static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes }; +# define HUGE_VALL (__huge_vall.__ld) +# endif /* GCC. */ + +# endif /* GCC 2.95 */ + -- cgit v1.2.3