This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Adding ccosl.c to newlib
- From: Aditya Upadhyay <aadit0402 at gmail dot com>
- To: newlib at sourceware dot org
- Date: Sun, 25 Jun 2017 02:33:00 +0530
- Subject: Adding ccosl.c to newlib
- Authentication-results: sourceware.org; auth=none
Hello Developers,
This is the patch for ccosl.c ported it from NetBSD. I am requesting
you to please review the same.
Thanks & Regards,
Aditya Upadhyay
From d22ce8829ea61128477fa6659bb625b5aa76597d Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Sun, 25 Jun 2017 02:29:10 +0530
Subject: [PATCH] Adding ccosl.c to newlib.
---
newlib/libm/complex/Makefile.am | 2 +-
newlib/libm/complex/Makefile.in | 14 ++++++++++---
newlib/libm/complex/ccosl.c | 45 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 4 deletions(-)
create mode 100644 newlib/libm/complex/ccosl.c
diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index fb57c39..bb3ffef 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -10,7 +10,7 @@ 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 ccoshl.c cacoshl.c csqrtl.c clogl.c cephes_subrl.c cargl.c cprojl.c cexpl.c cacosl.c
+lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c csqrtl.c clogl.c cephes_subrl.c cargl.c cprojl.c cexpl.c cacosl.c ccosl.c
fsrc = cabsf.c casinf.c ccosf.c cimagf.c cprojf.c \
csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
diff --git a/newlib/libm/complex/Makefile.in b/newlib/libm/complex/Makefile.in
index 0139415..c17c9d2 100644
--- a/newlib/libm/complex/Makefile.in
+++ b/newlib/libm/complex/Makefile.in
@@ -100,7 +100,7 @@ am__objects_3 = lib_a-cabsl.$(OBJEXT) lib_a-creall.$(OBJEXT) \
lib_a-cimagl.$(OBJEXT) lib_a-ccoshl.$(OBJEXT) lib_a-cacoshl.$(OBJEXT) \
lib_a-clogl.$(OBJEXT) lib_a-csqrtl.$(OBJEXT) lib_a-cephes_subrl.$(OBJEXT) \
lib_a-cargl.$(OBJEXT) lib_a-cprojl.$(OBJEXT) lib_a-cexpl.$(OBJEXT) \
- lib_a-cacosl.$(OBJEXT)
+ lib_a-cacosl.$(OBJEXT) lib_a-ccosl.$(OBJEXT)
@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \
@USE_LIBTOOL_FALSE@ $(am__objects_2) $(am__objects_3)
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
@@ -116,7 +116,7 @@ am__objects_5 = cabsf.lo casinf.lo ccosf.lo cimagf.lo cprojf.lo \
conjf.lo csinf.lo ctanhf.lo cargf.lo catanhf.lo cexpf.lo \
cpowf.lo csinhf.lo
am__objects_6 = cabsl.lo creall.lo cimagl.lo ccoshl.lo cacoshl.lo \
- clogl.lo csqrtl.lo cephes_subrl.lo cargl.lo cprojl.lo cexpl.lo cacosl.lo
+ clogl.lo csqrtl.lo cephes_subrl.lo cargl.lo cprojl.lo cexpl.lo cacosl.lo ccosl.lo
@USE_LIBTOOL_TRUE@am_libcomplex_la_OBJECTS = $(am__objects_4) \
@USE_LIBTOOL_TRUE@ $(am__objects_5) $(am__objects_6)
libcomplex_la_OBJECTS = $(am_libcomplex_la_OBJECTS)
@@ -280,7 +280,9 @@ 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 ccoshl.c cacoshl.c clogl.c csqrtl.c cephes_subrl.c cargl.c cprojl.c cexpl.c cacosl.c
+lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
+ clogl.c csqrtl.c cephes_subrl.c cargl.c \
+ cprojl.c cexpl.c cacosl.c ccosl.c
fsrc = cabsf.c casinf.c ccosf.c cimagf.c cprojf.c \
csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
crealf.c ctanf.c cacoshf.c catanf.c \
@@ -669,6 +671,12 @@ lib_a-cacosl.o: cacosl.c
lib_a-cacosl.obj: cacosl.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cacosl.obj `if test -f 'cacosl.c'; then $(CYGPATH_W) 'cacosl.c'; else $(CYGPATH_W) '$(srcdir)/cacosl.c'; fi`
+lib_a-ccosl.o: ccosl.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ccosl.o `test -f 'ccosl.c' || echo '$(srcdir)/'`ccosl.c
+
+lib_a-ccosl.obj: ccosl.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ccosl.obj `if test -f 'ccosl.c'; then $(CYGPATH_W) 'ccosl.c'; else $(CYGPATH_W) '$(srcdir)/ccosl.c'; fi`
+
lib_a-catanhf.o: catanhf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-catanhf.o `test -f 'catanhf.c' || echo '$(srcdir)/'`catanhf.c
diff --git a/newlib/libm/complex/ccosl.c b/newlib/libm/complex/ccosl.c
new file mode 100644
index 0000000..c310f40
--- /dev/null
+++ b/newlib/libm/complex/ccosl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: ccosl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software written by Stephen L. Moshier.
+ * It is redistributed by the NetBSD Foundation by permission of the author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <complex.h>
+#include <math.h>
+#include "cephes_subrl.h"
+
+long double complex
+ccosl(long double complex z)
+{
+ long double complex w;
+ long double ch, sh;
+
+ _cchshl(cimagl(z), &ch, &sh);
+ w = cosl(creall(z)) * ch - (sinl(creall(z)) * sh) * I;
+ return w;
+}
--
2.7.4