From b9e7cd9a846cf584049a719bbd0e4cabe3c50bea Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 6 Feb 2015 16:14:04 +0000 Subject: * libc/include/complex.h (cabsl): Add prototype. (cimagl): Add prototype. (creall): Add prototype. * libc/include/ieeefp.h: Include float.h. (EXT_EXPBITS, EXT_FRACHBITS, EXT_FRACLBITS) (EXT_EXP_INFNAN. EXT_EXP_BIAS, EXT_FRACBITS): Define. (struct ieee_ext, union ieee_ext_u): New types for long double support. * libc/include/math.h (finitel): Add prototype. (hypotl): Add prototype. (sqrtl): Add prototype. * libm/common/Makefile.am (lsrc): Add sl_finite.c. * libm/common/Makefile.in: Regenerate. * libm/common/fdlibm.h (__ieee754_hypotl): Add prototype. * libm/common/hypotl.c (hypotl): Add implementation for when long double is larger than double. * libm/common/sqrtl.c (sqrtl): Likewise. * libm/common/sl_finite.c: New file. Adds implementation of the finitel function. * libm/complex/Makefile.am (lsrc): Define. (libcomplex_la_SOURCES): Add lsrc. (lib_a_SOURCES): Add lsrc. * libm/complex/Makefile.in: Regenerate. * libm/complex/cabs.c: Add documentation of cabsl function. * libm/complex/cimag.c: Add documentation of cimagl function. * libm/complex/creall.c: Add documentation of creall function. * libm/complex/cabsl.c: New file. Adds implementation of the cabsl function. * libm/complex/cimagl.c: New file. Adds implementation of the cimagl function. * libm/complex/creall.c: New file. Adds implementation of the creall function. * libm/math/Makefile.am (lsrc): Define. (libmath_la_SOURCES): Add lsrc. (lib_a_SOURCES): Add lsrc. * libm/math/Makefile.in: Regenerate. * libm/math/el_hypot.c: New file. Adds implementation of the __ieee754_hypotl function. --- newlib/libm/complex/Makefile.am | 7 ++++--- newlib/libm/complex/Makefile.in | 36 ++++++++++++++++++++++++++++++++---- newlib/libm/complex/cabs.c | 16 +++++++++++----- newlib/libm/complex/cabsl.c | 18 ++++++++++++++++++ newlib/libm/complex/cimag.c | 16 +++++++++++----- newlib/libm/complex/cimagl.c | 16 ++++++++++++++++ newlib/libm/complex/creal.c | 18 ++++++++++++------ newlib/libm/complex/creall.c | 16 ++++++++++++++++ 8 files changed, 120 insertions(+), 23 deletions(-) create mode 100644 newlib/libm/complex/cabsl.c create mode 100644 newlib/libm/complex/cimagl.c create mode 100644 newlib/libm/complex/creall.c (limited to 'newlib/libm/complex') diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am index dbbe759be..1c4a50255 100644 --- a/newlib/libm/complex/Makefile.am +++ b/newlib/libm/complex/Makefile.am @@ -9,7 +9,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \ cexp.c cimag.c clog.c conj.c \ cpow.c cproj.c creal.c \ csin.c csinh.c csqrt.c ctan.c ctanh.c - + +lsrc = cabsl.c creall.c cimagl.c fsrc = cabsf.c casinf.c ccosf.c cimagf.c cprojf.c \ csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c \ @@ -21,11 +22,11 @@ libcomplex_la_LDFLAGS = -Xcompiler -nostdlib if USE_LIBTOOL noinst_LTLIBRARIES = libcomplex.la -libcomplex_la_SOURCES = $(src) $(fsrc) +libcomplex_la_SOURCES = $(src) $(fsrc) $(lsrc) noinst_DATA = objectlist.awk.in else noinst_LIBRARIES = lib.a -lib_a_SOURCES = $(src) $(fsrc) +lib_a_SOURCES = $(src) $(fsrc) $(lsrc) lib_a_CFLAGS = $(AM_CFLAGS) noinst_DATA = endif # USE_LIBTOOL diff --git a/newlib/libm/complex/Makefile.in b/newlib/libm/complex/Makefile.in index 8a0d4b468..cf731e72f 100644 --- a/newlib/libm/complex/Makefile.in +++ b/newlib/libm/complex/Makefile.in @@ -79,8 +79,11 @@ am__objects_2 = lib_a-cabsf.$(OBJEXT) lib_a-casinf.$(OBJEXT) \ lib_a-cargf.$(OBJEXT) lib_a-catanhf.$(OBJEXT) \ lib_a-cexpf.$(OBJEXT) lib_a-cpowf.$(OBJEXT) \ lib_a-csinhf.$(OBJEXT) +am__objects_5 = lib_a-cabsl.$(OBJEXT) lib_a-creall.$(OBJEXT) \ + lib_a-cimagl.$(OBJEXT) @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \ -@USE_LIBTOOL_FALSE@ $(am__objects_2) +@USE_LIBTOOL_FALSE@ $(am__objects_2) \ +@USE_LIBTOOL_FALSE@ $(am__objects_5) lib_a_OBJECTS = $(am_lib_a_OBJECTS) LTLIBRARIES = $(noinst_LTLIBRARIES) libcomplex_la_LIBADD = @@ -93,8 +96,10 @@ am__objects_4 = cabsf.lo casinf.lo ccosf.lo cimagf.lo cprojf.lo \ ctanf.lo cacoshf.lo catanf.lo cephes_subrf.lo conjf.lo \ csinf.lo ctanhf.lo cargf.lo catanhf.lo cexpf.lo cpowf.lo \ csinhf.lo +am__objects_6 = cabsl.lo creall.lo ciamgl.lo @USE_LIBTOOL_TRUE@am_libcomplex_la_OBJECTS = $(am__objects_3) \ -@USE_LIBTOOL_TRUE@ $(am__objects_4) +@USE_LIBTOOL_TRUE@ $(am__objects_4) \ +@USE_LIBTOOL_TRUE@ $(am__objects_6) libcomplex_la_OBJECTS = $(am_libcomplex_la_OBJECTS) libcomplex_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -249,6 +254,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \ cpow.c cproj.c creal.c \ csin.c csinh.c csqrt.c ctan.c ctanh.c +lsrc = cabsl.c creall.c cimagl.c + fsrc = cabsf.c casinf.c ccosf.c cimagf.c cprojf.c \ csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c \ crealf.c ctanf.c cacoshf.c catanf.c \ @@ -257,11 +264,11 @@ fsrc = cabsf.c casinf.c ccosf.c cimagf.c cprojf.c \ libcomplex_la_LDFLAGS = -Xcompiler -nostdlib @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libcomplex.la -@USE_LIBTOOL_TRUE@libcomplex_la_SOURCES = $(src) $(fsrc) +@USE_LIBTOOL_TRUE@libcomplex_la_SOURCES = $(src) $(fsrc) $(lsrc) @USE_LIBTOOL_FALSE@noinst_DATA = @USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in @USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a -@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(src) $(fsrc) +@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(src) $(fsrc) $(lsrc) @USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS) chobj = cabs.def cacos.def cacosh.def carg.def \ casin.def casinh.def catan.def catanh.def \ @@ -617,6 +624,27 @@ lib_a-csinhf.o: csinhf.c lib_a-csinhf.obj: csinhf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-csinhf.obj `if test -f 'csinhf.c'; then $(CYGPATH_W) 'csinhf.c'; else $(CYGPATH_W) '$(srcdir)/csinhf.c'; fi` +lib_a-cabsl.o: cabsl.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cabsl.o `test -f 'cabsl.c' || echo '$(srcdir)/'`cabsl.c + +lib_a-cabsl.obj: cabsl.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cabsl.obj `if test -f 'cabsl.c'; then $(CYGPATH_W) 'cabsl.c'; else $(CYGPATH_W) '$(srcdir)/cabsl.c'; fi` + +lib_a-creall.o: creall.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-creall.o `test -f 'creall.c' || echo '$(srcdir)/'`creall.c + +lib_a-creall.obj: creall.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-creall.obj `if test -f 'creall.c'; then $(CYGPATH_W) 'creall.c'; else $(CYGPATH_W) '$(srcdir)/creall.c'; fi` + +lib_a-cimagl.o: cimagl.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cimagl.o `test -f 'cimagl.c' || echo '$(srcdir)/'`cimagl.c + +lib_a-cimagl.obj: cimagl.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cimagl.obj `if test -f 'cimagl.c'; then $(CYGPATH_W) 'cimagl.c'; else $(CYGPATH_W) '$(srcdir)/cimagl.c'; fi` + + + + mostlyclean-libtool: -rm -f *.lo diff --git a/newlib/libm/complex/cabs.c b/newlib/libm/complex/cabs.c index 2750fab9a..69091d71a 100644 --- a/newlib/libm/complex/cabs.c +++ b/newlib/libm/complex/cabs.c @@ -10,17 +10,20 @@ /* FUNCTION - <>, <>---complex absolute-value + <>, <>, <>---complex absolute-value INDEX cabs INDEX cabsf +INDEX + cabsl ANSI_SYNOPSIS #include double cabs(double complex <[z]>); float cabsf(float complex <[z]>); + long double cabsl(long double complex <[z]>); DESCRIPTION @@ -28,16 +31,19 @@ DESCRIPTION (also called norm, modulus, or magnitude) of <[z]>. <> is identical to <>, except that it performs - its calculations on <>. + its calculations on <>. + + <> is identical to <>, except that it performs + its calculations on <>. RETURNS - The cabs functions return the complex absolute value. + The cabs* functions return the complex absolute value. PORTABILITY - <> and <> are ISO C99 + <>, <> and <> are ISO C99 QUICKREF - <> and <> are ISO C99 + <>, <> and <> are ISO C99 */ diff --git a/newlib/libm/complex/cabsl.c b/newlib/libm/complex/cabsl.c new file mode 100644 index 000000000..091f2cd53 --- /dev/null +++ b/newlib/libm/complex/cabsl.c @@ -0,0 +1,18 @@ +/* Copyright (C) 2015 by Red Hat, Incorporated. All rights reserved. + * + * Permission to use, copy, modify, and distribute this software + * is freely granted, provided that this notice is preserved. + */ + +#include +#include + +long double +cabsl (long double complex z) +{ +#ifdef _LDBL_EQ_DBL + return cabs (z); +#else + return hypotl (creall (z), cimagl (z)); +#endif +} diff --git a/newlib/libm/complex/cimag.c b/newlib/libm/complex/cimag.c index 1d2d77414..959dbc9a4 100644 --- a/newlib/libm/complex/cimag.c +++ b/newlib/libm/complex/cimag.c @@ -10,33 +10,39 @@ /* FUNCTION - <>, <>---imaginary part + <>, <>, <>---imaginary part INDEX cimag INDEX cimagf +INDEX + cimagl ANSI_SYNOPSIS #include double cimag(double complex <[z]>); float cimagf(float complex <[z]>); + long double cimagl(long double complex <[z]>); DESCRIPTION These functions compute the imaginary part of <[z]>. <> is identical to <>, except that it performs - its calculations on <>. + its calculations on <>. + + <> is identical to <>, except that it performs + its calculations on <>. RETURNS - The cimag functions return the imaginary part value (as a real). + The cimag* functions return the imaginary part value (as a real). PORTABILITY - <> and <> are ISO C99 + <>, <> and <> are ISO C99 QUICKREF - <> and <> are ISO C99 + <>, <> and <> are ISO C99 */ diff --git a/newlib/libm/complex/cimagl.c b/newlib/libm/complex/cimagl.c new file mode 100644 index 000000000..a5afdc456 --- /dev/null +++ b/newlib/libm/complex/cimagl.c @@ -0,0 +1,16 @@ +/* Copyright (C) 2015 by Red Hat, Incorporated. All rights reserved. + * + * Permission to use, copy, modify, and distribute this software + * is freely granted, provided that this notice is preserved. + */ + +#include +#include "../common/fdlibm.h" + +long double +cimagl (long double complex z) +{ + long_double_complex w = { .z = z }; + + return IMAG_PART (w); +} diff --git a/newlib/libm/complex/creal.c b/newlib/libm/complex/creal.c index c621561ae..1652a5f8e 100644 --- a/newlib/libm/complex/creal.c +++ b/newlib/libm/complex/creal.c @@ -10,33 +10,39 @@ /* FUNCTION - <>, <>---real part + <>, <>, <>---real part INDEX creal INDEX crealf +INDEX + creall ANSI_SYNOPSIS #include double creal(double complex <[z]>); float crealf(float complex <[z]>); + double long creall(long double complex <[z]>); - + DESCRIPTION These functions compute the real part of <[z]>. <> is identical to <>, except that it performs - its calculations on <>. + its calculations on <>. + + <> is identical to <>, except that it performs + its calculations on <>. RETURNS - The creal functions return the real part value. + The creal* functions return the real part value. PORTABILITY - <> and <> are ISO C99 + <>, <> and <> are ISO C99 QUICKREF - <> and <> are ISO C99 + <>, <> and <> are ISO C99 */ diff --git a/newlib/libm/complex/creall.c b/newlib/libm/complex/creall.c new file mode 100644 index 000000000..7aa88c272 --- /dev/null +++ b/newlib/libm/complex/creall.c @@ -0,0 +1,16 @@ +/* Copyright (C) 2015 by Red Hat, Incorporated. All rights reserved. + * + * Permission to use, copy, modify, and distribute this software + * is freely granted, provided that this notice is preserved. + */ + +#include +#include "../common/fdlibm.h" + +long double +creall (long double complex z) +{ + long_double_complex w = { .z = z }; + + return (REAL_PART(w)); +} -- cgit v1.2.3