public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Long double complex methods
@ 2017-06-28 13:53 Aditya Upadhyay
  0 siblings, 0 replies; 19+ messages in thread
From: Aditya Upadhyay @ 2017-06-28 13:53 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

Hello Developers,

This is the patch for conjl.c and ctanl.c ported from NetBSD. Please
review the same and suggest me needed modification.


Thanks & Regards,
Aditya Upadhyay

[-- Attachment #2: 0011-Importing-conjl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3099 bytes --]

From 35fea5cb4912073b8027b0622dd9143b8bd61803 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Wed, 28 Jun 2017 18:50:52 +0530
Subject: [PATCH 11/12] Importing conjl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/conjl.c     | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 newlib/libm/complex/conjl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index e121ac5..979a9a9 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \ 
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c cephes_subrl.c\
-       cacosl.c ccosl.c cpowl.c
+       cacosl.c ccosl.c cpowl.c conjl.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/conjl.c b/newlib/libm/complex/conjl.c
new file mode 100644
index 0000000..35094ce
--- /dev/null
+++ b/newlib/libm/complex/conjl.c
@@ -0,0 +1,46 @@
+/*	$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 <sys/cdefs.h>
+__RCSID("$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $");
+
+#include <complex.h>
+#include "../common/fdlibm.h"
+
+/*
+ * conjl(long double complex z)
+ * This function returns the complex conjugate value of its argument, z.
+ */
+long double complex
+conjl(long double complex z)
+{
+	long_double_complex w = { .z = z };
+
+	IMAG_PART(w) = -IMAG_PART(w);
+
+	return (w.z);
+}
-- 
2.7.4


[-- Attachment #3: 0012-Porting-ctanl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3329 bytes --]

From b0f90b446b21c0ee16aef03614580ade8d0ac43b Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Wed, 28 Jun 2017 19:06:03 +0530
Subject: [PATCH 12/12] Porting ctanl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  3 ++-
 newlib/libm/complex/ctanl.c     | 56 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 newlib/libm/complex/ctanl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 979a9a9..02cab35 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \ 
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c cephes_subrl.c\
-       cacosl.c ccosl.c cpowl.c conjl.c
+       cacosl.c ccosl.c cpowl.c conjl.c \
+       ctanl.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/ctanl.c b/newlib/libm/complex/ctanl.c
new file mode 100644
index 0000000..9255bdb
--- /dev/null
+++ b/newlib/libm/complex/ctanl.c
@@ -0,0 +1,56 @@
+/* $NetBSD: ctanl.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
+ctanl(long double complex z)
+{
+	long double complex w;
+	long double d;
+
+	d = cosl(2.0L * creall(z)) + coshl(2.0L * cimagl(z));
+
+	if (fabsl(d) < 0.25L)
+		d = _ctansl(z);
+
+	if (d == 0.0L) {
+		/* mtherr ("ctan", OVERFLOW); */
+		w = HUGE_VALF + HUGE_VALF * I;
+		return w;
+	}
+
+	w = sinl(2.0L * creall(z)) / d + (sinhl(2.0L * cimagl(z)) / d) * I;
+	return w;
+}
-- 
2.7.4


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-07-05  9:02                     ` Aditya Upadhyay
@ 2017-07-05 12:40                       ` Corinna Vinschen
  0 siblings, 0 replies; 19+ messages in thread
From: Corinna Vinschen @ 2017-07-05 12:40 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 925 bytes --]

On Jul  5 14:32, Aditya Upadhyay wrote:
> I have made mistakes while using git. Sorry for that.
> 
> Thanks & Regards,
> Aditya Upadhyay
> 
> On Wed, Jul 5, 2017 at 1:57 PM, Corinna Vinschen <vinschen@redhat.com> wrote:
> > On Jul  5 03:26, Aditya Upadhyay wrote:
> >> Removed blank lines from complex.h.
> >> The modified patch for fix warnings , i am attaching here. Please check it once.
> >
> > No, the attached patch is only fixing whitespace, the rest of the patch
> > is missing.  Please make sure to send the complete patch.
> >
> >
> > Thanks,
> > Corinna
> >
> >> From bd596dd4125acbe7bd2922f25a44e4dbf31bc4b0 Mon Sep 17 00:00:00 2001
> >> From: Aditya Upadhyay <aadit0402@gmail.com>
> >> Date: Wed, 5 Jul 2017 03:20:19 +0530
> >> Subject: [PATCH v2 2/2] Fixed warnings for some long double complex methods

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-07-05  8:27                   ` Corinna Vinschen
@ 2017-07-05  9:02                     ` Aditya Upadhyay
  2017-07-05 12:40                       ` Corinna Vinschen
  0 siblings, 1 reply; 19+ messages in thread
From: Aditya Upadhyay @ 2017-07-05  9:02 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 1788 bytes --]

I have made mistakes while using git. Sorry for that.

Thanks & Regards,
Aditya Upadhyay

On Wed, Jul 5, 2017 at 1:57 PM, Corinna Vinschen <vinschen@redhat.com> wrote:
> On Jul  5 03:26, Aditya Upadhyay wrote:
>> Removed blank lines from complex.h.
>> The modified patch for fix warnings , i am attaching here. Please check it once.
>
> No, the attached patch is only fixing whitespace, the rest of the patch
> is missing.  Please make sure to send the complete patch.
>
>
> Thanks,
> Corinna
>
>> From bd596dd4125acbe7bd2922f25a44e4dbf31bc4b0 Mon Sep 17 00:00:00 2001
>> From: Aditya Upadhyay <aadit0402@gmail.com>
>> Date: Wed, 5 Jul 2017 03:20:19 +0530
>> Subject: [PATCH v2 2/2] Fixed warnings for some long double complex methods
>>
>> ---
>>  newlib/libc/include/complex.h | 4 ----
>>  1 file changed, 4 deletions(-)
>>
>> diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h
>> index af2a3ce..9ee40c0 100644
>> --- a/newlib/libc/include/complex.h
>> +++ b/newlib/libc/include/complex.h
>> @@ -130,8 +130,6 @@ float complex clog10f(float complex);
>>
>>  #if defined(__CYGWIN__)
>>  long double complex cacosl(long double complex);
>> -
>> -
>>  long double complex ccosl(long double complex);
>>  long double complex csinl(long double complex);
>>  long double complex ctanl(long double complex);
>> @@ -144,8 +142,6 @@ long double complex ctanhl(long double complex);
>>  long double complex cexpl(long double complex);
>>  long double complex clogl(long double complex);
>>  long double complex cpowl(long double complex, long double complex);
>> -
>> -
>>  long double complex conjl(long double complex);
>>  long double complex cprojl(long double complex);
>>  #if __GNU_VISIBLE
>> --
>> 2.7.4
>>
>
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat

[-- Attachment #2: 0001-Fixed-warnings-for-some-long-double-complex-methods.patch --]
[-- Type: text/x-patch, Size: 2670 bytes --]

From c5c8470b69cfefe749b51e8b7caf71fa677d70fd Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Wed, 5 Jul 2017 14:28:36 +0530
Subject: [PATCH v1] Fixed warnings for some long double complex methods

---
 newlib/libc/include/complex.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h
index 89d6162..0a3ea97 100644
--- a/newlib/libc/include/complex.h
+++ b/newlib/libc/include/complex.h
@@ -24,10 +24,12 @@ float complex cacosf(float complex);
 /* 7.3.5.2 The casin functions */
 double complex casin(double complex);
 float complex casinf(float complex);
+long double complex casinl(long double complex);
 
 /* 7.3.5.1 The catan functions */
 double complex catan(double complex);
 float complex catanf(float complex);
+long double complex catanl(long double complex);
 
 /* 7.3.5.1 The ccos functions */
 double complex ccos(double complex);
@@ -74,6 +76,7 @@ float complex cexpf(float complex);
 /* 7.3.7.2 The clog functions */
 double complex clog(double complex);
 float complex clogf(float complex);
+long double complex clogl(long double complex);
 
 /* 7.3.8 Power and absolute-value functions */
 /* 7.3.8.1 The cabs functions */
@@ -94,11 +97,13 @@ float complex cpowf(float complex, float complex);
 /* 7.3.8.3 The csqrt functions */
 double complex csqrt(double complex);
 float complex csqrtf(float complex);
+long double complex csqrtl(long double complex);
 
 /* 7.3.9 Manipulation functions */
 /* 7.3.9.1 The carg functions */ 
 double carg(double complex);
 float cargf(float complex);
+long double cargl(long double complex);
 
 /* 7.3.9.2 The cimag functions */
 double cimag(double complex);
@@ -125,8 +130,6 @@ float complex clog10f(float complex);
 
 #if defined(__CYGWIN__)
 long double complex cacosl(long double complex);
-long double complex casinl(long double complex);
-long double complex catanl(long double complex);
 long double complex ccosl(long double complex);
 long double complex csinl(long double complex);
 long double complex ctanl(long double complex);
@@ -137,10 +140,7 @@ long double complex ccoshl(long double complex);
 long double complex csinhl(long double complex);
 long double complex ctanhl(long double complex);
 long double complex cexpl(long double complex);
-long double complex clogl(long double complex);
 long double complex cpowl(long double complex, long double complex);
-long double complex csqrtl(long double complex);
-long double cargl(long double complex);
 long double complex conjl(long double complex);
 long double complex cprojl(long double complex);
 #if __GNU_VISIBLE
-- 
2.7.4


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-07-04 21:56                 ` Aditya Upadhyay
@ 2017-07-05  8:27                   ` Corinna Vinschen
  2017-07-05  9:02                     ` Aditya Upadhyay
  0 siblings, 1 reply; 19+ messages in thread
From: Corinna Vinschen @ 2017-07-05  8:27 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 1618 bytes --]

On Jul  5 03:26, Aditya Upadhyay wrote:
> Removed blank lines from complex.h.
> The modified patch for fix warnings , i am attaching here. Please check it once.

No, the attached patch is only fixing whitespace, the rest of the patch
is missing.  Please make sure to send the complete patch.


Thanks,
Corinna

> From bd596dd4125acbe7bd2922f25a44e4dbf31bc4b0 Mon Sep 17 00:00:00 2001
> From: Aditya Upadhyay <aadit0402@gmail.com>
> Date: Wed, 5 Jul 2017 03:20:19 +0530
> Subject: [PATCH v2 2/2] Fixed warnings for some long double complex methods
> 
> ---
>  newlib/libc/include/complex.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h
> index af2a3ce..9ee40c0 100644
> --- a/newlib/libc/include/complex.h
> +++ b/newlib/libc/include/complex.h
> @@ -130,8 +130,6 @@ float complex clog10f(float complex);
>  
>  #if defined(__CYGWIN__)
>  long double complex cacosl(long double complex);
> -
> -
>  long double complex ccosl(long double complex);
>  long double complex csinl(long double complex);
>  long double complex ctanl(long double complex);
> @@ -144,8 +142,6 @@ long double complex ctanhl(long double complex);
>  long double complex cexpl(long double complex);
>  long double complex clogl(long double complex);
>  long double complex cpowl(long double complex, long double complex);
> -
> -
>  long double complex conjl(long double complex);
>  long double complex cprojl(long double complex);
>  #if __GNU_VISIBLE
> -- 
> 2.7.4
> 


-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-07-04 21:31               ` Aditya Upadhyay
@ 2017-07-04 21:56                 ` Aditya Upadhyay
  2017-07-05  8:27                   ` Corinna Vinschen
  0 siblings, 1 reply; 19+ messages in thread
From: Aditya Upadhyay @ 2017-07-04 21:56 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

Removed blank lines from complex.h.
The modified patch for fix warnings , i am attaching here. Please check it once.

Thanks & Regards,
Aditya Upadhyay

On Wed, Jul 5, 2017 at 3:01 AM, Aditya Upadhyay <aadit0402@gmail.com> wrote:
> Hello Developers,
>
> I have fixed the warnings related to cacoshl, casinhl, cargl etc what
> Joel Had pointed out.. This is the patch. i am requesting you to
> please check it and tell me whether i have correctly fixed the
> warnings or not ?
>
> Thanks & Regards,
> Aditya Upadhyay
>
> On Fri, Jun 30, 2017 at 2:41 PM, Aditya Upadhyay <aadit0402@gmail.com> wrote:
>> I am tring to resolve the warnings. Thank you for pointing it out.
>>
>>
>> Regards,
>> Aditya
>>
>> On Fri, Jun 30, 2017 at 2:47 AM, Joel Sherrill
>> <joel.sherrill@oarcorp.com> wrote:
>>>
>>>
>>> On 6/29/2017 2:38 PM, Yaakov Selkowitz wrote:
>>>>
>>>> On 2017-06-29 07:04, Corinna Vinschen wrote:
>>>>>
>>>>> On Jun 29 13:53, Corinna Vinschen wrote:
>>>>>>
>>>>>> On Jun 29 12:41, Aditya Upadhyay wrote:
>>>>>>>
>>>>>>> Hello Developers,
>>>>>>>
>>>>>>> This is the modified patch for csinl.c which reflects changes in
>>>>>>> Makefile.am.
>>>>>>
>>>>>>
>>>>>> Uhm... this patch now contains *only* the Makefile.am change, but
>>>>>> not the expected csinl.c file.
>>>>>>
>>>>>> v3? ;)
>>>>>
>>>>>
>>>>> Never mind, I'm going to apply v1 and v2 of patch 18.  However, usually
>>>>> a v2 (or v3, v4, ...) of a patch is expected to replace the v1 of the
>>>>> patch entirely, not that it just contains a diff to v1.
>>>>>
>>>>> I pushed the set now and regenerated complex/Makefile.in.
>>>>
>>>>
>>>> This patchset is causing errors when building Cygwin:
>>>>
>>>> newlib/libm/complex/cargl.c: In function  cargl’:
>>>> newlib/libm/complex/cargl.c:16:25: error: implicit declaration of
>>>> function ‘imag’ [-Werror=implicit-function-declaration]
>>>>             return atan2l (imag (z), real (z));
>>>>                            ^
>>>> newlib/libm/complex/cargl.c:16:35: error: implicit declaration of
>>>> function ‘real’ [-Werror=implicit-function-declaration]
>>>>             return atan2l (imag (z), real (z));
>>>>                                      ^
>>>>
>>>
>>> It builds for RTEMS (sparc) with some new warnings:
>>>
>>> newlib/libm/complex/cacoshl.c:42:16: warning: implicit declaration of
>>> function 'csqrtl'; did you mean 'csqrtf'? [-Wimplicit-function-declaration]
>>> newlib/libm/complex/cacoshl.c:42:6: warning: implicit declaration of
>>> function 'clogl'; did you mean 'clogf'? [-Wimplicit-function-declaration]
>>> newlib/libm/complex/cacosl.c:41:6: warning: implicit declaration of function
>>> 'casinl'; did you mean 'asinl'? [-Wimplicit-function-declaration]
>>> newlib/libm/complex/casinhl.c:39:18: warning: implicit declaration of
>>> function 'casinl'; did you mean 'casinhl'? [-Wimplicit-function-declaration]
>>> newlib/libm/complex/casinl.c:112:7: warning: implicit declaration of
>>> function 'csqrtl'; did you mean 'sqrtl'? [-Wimplicit-function-declaration]
>>> newlib/libm/complex/casinl.c:115:7: warning: implicit declaration of
>>> function 'clogl'; did you mean 'logl'? [-Wimplicit-function-declaration]
>>> newlib/libm/complex/catanhl.c:39:18: warning: implicit declaration of
>>> function 'catanl'; did you mean 'catanhl'? [-Wimplicit-function-declaration]
>>> newlib/libm/complex/cpowl.c:47:9: warning: implicit declaration of function
>>> 'cargl'; did you mean 'cargf'? [-Wimplicit-function-declaration]
>>>
>>> I don't see any Cygwin ifdef's related to imag()
>>> so I built for i386-rtems to see if it was related
>>> to _LDBL_EQ_DBL. i386-rtems built with a few warnings.
>>>
>>> We have an x86_64-rtems tool target in anticipation of
>>> a port. I built a tool chain just to check this and
>>> the newlib master built cleanly on that.
>>>
>>> I am sorry but I am not duplicating this. What would
>>> be different about Cygwin in this case?
>>>
>>> --joel
>>>

[-- Attachment #2: 0002-Fixed-warnings-for-some-long-double-complex-methods.patch --]
[-- Type: text/x-patch, Size: 1139 bytes --]

From bd596dd4125acbe7bd2922f25a44e4dbf31bc4b0 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Wed, 5 Jul 2017 03:20:19 +0530
Subject: [PATCH v2 2/2] Fixed warnings for some long double complex methods

---
 newlib/libc/include/complex.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h
index af2a3ce..9ee40c0 100644
--- a/newlib/libc/include/complex.h
+++ b/newlib/libc/include/complex.h
@@ -130,8 +130,6 @@ float complex clog10f(float complex);
 
 #if defined(__CYGWIN__)
 long double complex cacosl(long double complex);
-
-
 long double complex ccosl(long double complex);
 long double complex csinl(long double complex);
 long double complex ctanl(long double complex);
@@ -144,8 +142,6 @@ long double complex ctanhl(long double complex);
 long double complex cexpl(long double complex);
 long double complex clogl(long double complex);
 long double complex cpowl(long double complex, long double complex);
-
-
 long double complex conjl(long double complex);
 long double complex cprojl(long double complex);
 #if __GNU_VISIBLE
-- 
2.7.4


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-30  9:11             ` Aditya Upadhyay
@ 2017-07-04 21:31               ` Aditya Upadhyay
  2017-07-04 21:56                 ` Aditya Upadhyay
  0 siblings, 1 reply; 19+ messages in thread
From: Aditya Upadhyay @ 2017-07-04 21:31 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 3681 bytes --]

Hello Developers,

I have fixed the warnings related to cacoshl, casinhl, cargl etc what
Joel Had pointed out.. This is the patch. i am requesting you to
please check it and tell me whether i have correctly fixed the
warnings or not ?

Thanks & Regards,
Aditya Upadhyay

On Fri, Jun 30, 2017 at 2:41 PM, Aditya Upadhyay <aadit0402@gmail.com> wrote:
> I am tring to resolve the warnings. Thank you for pointing it out.
>
>
> Regards,
> Aditya
>
> On Fri, Jun 30, 2017 at 2:47 AM, Joel Sherrill
> <joel.sherrill@oarcorp.com> wrote:
>>
>>
>> On 6/29/2017 2:38 PM, Yaakov Selkowitz wrote:
>>>
>>> On 2017-06-29 07:04, Corinna Vinschen wrote:
>>>>
>>>> On Jun 29 13:53, Corinna Vinschen wrote:
>>>>>
>>>>> On Jun 29 12:41, Aditya Upadhyay wrote:
>>>>>>
>>>>>> Hello Developers,
>>>>>>
>>>>>> This is the modified patch for csinl.c which reflects changes in
>>>>>> Makefile.am.
>>>>>
>>>>>
>>>>> Uhm... this patch now contains *only* the Makefile.am change, but
>>>>> not the expected csinl.c file.
>>>>>
>>>>> v3? ;)
>>>>
>>>>
>>>> Never mind, I'm going to apply v1 and v2 of patch 18.  However, usually
>>>> a v2 (or v3, v4, ...) of a patch is expected to replace the v1 of the
>>>> patch entirely, not that it just contains a diff to v1.
>>>>
>>>> I pushed the set now and regenerated complex/Makefile.in.
>>>
>>>
>>> This patchset is causing errors when building Cygwin:
>>>
>>> newlib/libm/complex/cargl.c: In function  cargl’:
>>> newlib/libm/complex/cargl.c:16:25: error: implicit declaration of
>>> function ‘imag’ [-Werror=implicit-function-declaration]
>>>             return atan2l (imag (z), real (z));
>>>                            ^
>>> newlib/libm/complex/cargl.c:16:35: error: implicit declaration of
>>> function ‘real’ [-Werror=implicit-function-declaration]
>>>             return atan2l (imag (z), real (z));
>>>                                      ^
>>>
>>
>> It builds for RTEMS (sparc) with some new warnings:
>>
>> newlib/libm/complex/cacoshl.c:42:16: warning: implicit declaration of
>> function 'csqrtl'; did you mean 'csqrtf'? [-Wimplicit-function-declaration]
>> newlib/libm/complex/cacoshl.c:42:6: warning: implicit declaration of
>> function 'clogl'; did you mean 'clogf'? [-Wimplicit-function-declaration]
>> newlib/libm/complex/cacosl.c:41:6: warning: implicit declaration of function
>> 'casinl'; did you mean 'asinl'? [-Wimplicit-function-declaration]
>> newlib/libm/complex/casinhl.c:39:18: warning: implicit declaration of
>> function 'casinl'; did you mean 'casinhl'? [-Wimplicit-function-declaration]
>> newlib/libm/complex/casinl.c:112:7: warning: implicit declaration of
>> function 'csqrtl'; did you mean 'sqrtl'? [-Wimplicit-function-declaration]
>> newlib/libm/complex/casinl.c:115:7: warning: implicit declaration of
>> function 'clogl'; did you mean 'logl'? [-Wimplicit-function-declaration]
>> newlib/libm/complex/catanhl.c:39:18: warning: implicit declaration of
>> function 'catanl'; did you mean 'catanhl'? [-Wimplicit-function-declaration]
>> newlib/libm/complex/cpowl.c:47:9: warning: implicit declaration of function
>> 'cargl'; did you mean 'cargf'? [-Wimplicit-function-declaration]
>>
>> I don't see any Cygwin ifdef's related to imag()
>> so I built for i386-rtems to see if it was related
>> to _LDBL_EQ_DBL. i386-rtems built with a few warnings.
>>
>> We have an x86_64-rtems tool target in anticipation of
>> a port. I built a tool chain just to check this and
>> the newlib master built cleanly on that.
>>
>> I am sorry but I am not duplicating this. What would
>> be different about Cygwin in this case?
>>
>> --joel
>>

[-- Attachment #2: 0001-Fixed-warnings-for-some-long-double-complex-methods.patch --]
[-- Type: text/x-patch, Size: 2577 bytes --]

From 292d920b1210c67684b13ad82fc56c7201c5ee59 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Wed, 5 Jul 2017 02:56:15 +0530
Subject: [PATCH] Fixed warnings for some long double complex methods

---
 newlib/libc/include/complex.h | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h
index 89d6162..af2a3ce 100644
--- a/newlib/libc/include/complex.h
+++ b/newlib/libc/include/complex.h
@@ -24,10 +24,12 @@ float complex cacosf(float complex);
 /* 7.3.5.2 The casin functions */
 double complex casin(double complex);
 float complex casinf(float complex);
+long double complex casinl(long double complex);
 
 /* 7.3.5.1 The catan functions */
 double complex catan(double complex);
 float complex catanf(float complex);
+long double complex catanl(long double complex);
 
 /* 7.3.5.1 The ccos functions */
 double complex ccos(double complex);
@@ -74,6 +76,7 @@ float complex cexpf(float complex);
 /* 7.3.7.2 The clog functions */
 double complex clog(double complex);
 float complex clogf(float complex);
+long double complex clogl(long double complex);
 
 /* 7.3.8 Power and absolute-value functions */
 /* 7.3.8.1 The cabs functions */
@@ -94,11 +97,13 @@ float complex cpowf(float complex, float complex);
 /* 7.3.8.3 The csqrt functions */
 double complex csqrt(double complex);
 float complex csqrtf(float complex);
+long double complex csqrtl(long double complex);
 
 /* 7.3.9 Manipulation functions */
 /* 7.3.9.1 The carg functions */ 
 double carg(double complex);
 float cargf(float complex);
+long double cargl(long double complex);
 
 /* 7.3.9.2 The cimag functions */
 double cimag(double complex);
@@ -125,8 +130,8 @@ float complex clog10f(float complex);
 
 #if defined(__CYGWIN__)
 long double complex cacosl(long double complex);
-long double complex casinl(long double complex);
-long double complex catanl(long double complex);
+
+
 long double complex ccosl(long double complex);
 long double complex csinl(long double complex);
 long double complex ctanl(long double complex);
@@ -139,8 +144,8 @@ long double complex ctanhl(long double complex);
 long double complex cexpl(long double complex);
 long double complex clogl(long double complex);
 long double complex cpowl(long double complex, long double complex);
-long double complex csqrtl(long double complex);
-long double cargl(long double complex);
+
+
 long double complex conjl(long double complex);
 long double complex cprojl(long double complex);
 #if __GNU_VISIBLE
-- 
2.7.4


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-29 21:17           ` Joel Sherrill
@ 2017-06-30  9:11             ` Aditya Upadhyay
  2017-07-04 21:31               ` Aditya Upadhyay
  0 siblings, 1 reply; 19+ messages in thread
From: Aditya Upadhyay @ 2017-06-30  9:11 UTC (permalink / raw)
  To: newlib

I am tring to resolve the warnings. Thank you for pointing it out.


Regards,
Aditya

On Fri, Jun 30, 2017 at 2:47 AM, Joel Sherrill
<joel.sherrill@oarcorp.com> wrote:
>
>
> On 6/29/2017 2:38 PM, Yaakov Selkowitz wrote:
>>
>> On 2017-06-29 07:04, Corinna Vinschen wrote:
>>>
>>> On Jun 29 13:53, Corinna Vinschen wrote:
>>>>
>>>> On Jun 29 12:41, Aditya Upadhyay wrote:
>>>>>
>>>>> Hello Developers,
>>>>>
>>>>> This is the modified patch for csinl.c which reflects changes in
>>>>> Makefile.am.
>>>>
>>>>
>>>> Uhm... this patch now contains *only* the Makefile.am change, but
>>>> not the expected csinl.c file.
>>>>
>>>> v3? ;)
>>>
>>>
>>> Never mind, I'm going to apply v1 and v2 of patch 18.  However, usually
>>> a v2 (or v3, v4, ...) of a patch is expected to replace the v1 of the
>>> patch entirely, not that it just contains a diff to v1.
>>>
>>> I pushed the set now and regenerated complex/Makefile.in.
>>
>>
>> This patchset is causing errors when building Cygwin:
>>
>> newlib/libm/complex/cargl.c: In function  cargl’:
>> newlib/libm/complex/cargl.c:16:25: error: implicit declaration of
>> function ‘imag’ [-Werror=implicit-function-declaration]
>>             return atan2l (imag (z), real (z));
>>                            ^
>> newlib/libm/complex/cargl.c:16:35: error: implicit declaration of
>> function ‘real’ [-Werror=implicit-function-declaration]
>>             return atan2l (imag (z), real (z));
>>                                      ^
>>
>
> It builds for RTEMS (sparc) with some new warnings:
>
> newlib/libm/complex/cacoshl.c:42:16: warning: implicit declaration of
> function 'csqrtl'; did you mean 'csqrtf'? [-Wimplicit-function-declaration]
> newlib/libm/complex/cacoshl.c:42:6: warning: implicit declaration of
> function 'clogl'; did you mean 'clogf'? [-Wimplicit-function-declaration]
> newlib/libm/complex/cacosl.c:41:6: warning: implicit declaration of function
> 'casinl'; did you mean 'asinl'? [-Wimplicit-function-declaration]
> newlib/libm/complex/casinhl.c:39:18: warning: implicit declaration of
> function 'casinl'; did you mean 'casinhl'? [-Wimplicit-function-declaration]
> newlib/libm/complex/casinl.c:112:7: warning: implicit declaration of
> function 'csqrtl'; did you mean 'sqrtl'? [-Wimplicit-function-declaration]
> newlib/libm/complex/casinl.c:115:7: warning: implicit declaration of
> function 'clogl'; did you mean 'logl'? [-Wimplicit-function-declaration]
> newlib/libm/complex/catanhl.c:39:18: warning: implicit declaration of
> function 'catanl'; did you mean 'catanhl'? [-Wimplicit-function-declaration]
> newlib/libm/complex/cpowl.c:47:9: warning: implicit declaration of function
> 'cargl'; did you mean 'cargf'? [-Wimplicit-function-declaration]
>
> I don't see any Cygwin ifdef's related to imag()
> so I built for i386-rtems to see if it was related
> to _LDBL_EQ_DBL. i386-rtems built with a few warnings.
>
> We have an x86_64-rtems tool target in anticipation of
> a port. I built a tool chain just to check this and
> the newlib master built cleanly on that.
>
> I am sorry but I am not duplicating this. What would
> be different about Cygwin in this case?
>
> --joel
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-29 19:38         ` Yaakov Selkowitz
@ 2017-06-29 21:17           ` Joel Sherrill
  2017-06-30  9:11             ` Aditya Upadhyay
  0 siblings, 1 reply; 19+ messages in thread
From: Joel Sherrill @ 2017-06-29 21:17 UTC (permalink / raw)
  To: Yaakov Selkowitz, newlib, aditya upadhyay



On 6/29/2017 2:38 PM, Yaakov Selkowitz wrote:
> On 2017-06-29 07:04, Corinna Vinschen wrote:
>> On Jun 29 13:53, Corinna Vinschen wrote:
>>> On Jun 29 12:41, Aditya Upadhyay wrote:
>>>> Hello Developers,
>>>>
>>>> This is the modified patch for csinl.c which reflects changes in Makefile.am.
>>>
>>> Uhm... this patch now contains *only* the Makefile.am change, but
>>> not the expected csinl.c file.
>>>
>>> v3? ;)
>>
>> Never mind, I'm going to apply v1 and v2 of patch 18.  However, usually
>> a v2 (or v3, v4, ...) of a patch is expected to replace the v1 of the
>> patch entirely, not that it just contains a diff to v1.
>>
>> I pushed the set now and regenerated complex/Makefile.in.
> 
> This patchset is causing errors when building Cygwin:
> 
> newlib/libm/complex/cargl.c: In function  cargl’:
> newlib/libm/complex/cargl.c:16:25: error: implicit declaration of
> function ‘imag’ [-Werror=implicit-function-declaration]
>             return atan2l (imag (z), real (z));
>                            ^
> newlib/libm/complex/cargl.c:16:35: error: implicit declaration of
> function ‘real’ [-Werror=implicit-function-declaration]
>             return atan2l (imag (z), real (z));
>                                      ^
> 

It builds for RTEMS (sparc) with some new warnings:

newlib/libm/complex/cacoshl.c:42:16: warning: implicit declaration of function 'csqrtl'; did you mean 'csqrtf'? [-Wimplicit-function-declaration]
newlib/libm/complex/cacoshl.c:42:6: warning: implicit declaration of function 'clogl'; did you mean 'clogf'? [-Wimplicit-function-declaration]
newlib/libm/complex/cacosl.c:41:6: warning: implicit declaration of function 'casinl'; did you mean 'asinl'? [-Wimplicit-function-declaration]
newlib/libm/complex/casinhl.c:39:18: warning: implicit declaration of function 'casinl'; did you mean 'casinhl'? [-Wimplicit-function-declaration]
newlib/libm/complex/casinl.c:112:7: warning: implicit declaration of function 'csqrtl'; did you mean 'sqrtl'? [-Wimplicit-function-declaration]
newlib/libm/complex/casinl.c:115:7: warning: implicit declaration of function 'clogl'; did you mean 'logl'? [-Wimplicit-function-declaration]
newlib/libm/complex/catanhl.c:39:18: warning: implicit declaration of function 'catanl'; did you mean 'catanhl'? [-Wimplicit-function-declaration]
newlib/libm/complex/cpowl.c:47:9: warning: implicit declaration of function 'cargl'; did you mean 'cargf'? [-Wimplicit-function-declaration]

I don't see any Cygwin ifdef's related to imag()
so I built for i386-rtems to see if it was related
to _LDBL_EQ_DBL. i386-rtems built with a few warnings.

We have an x86_64-rtems tool target in anticipation of
a port. I built a tool chain just to check this and
the newlib master built cleanly on that.

I am sorry but I am not duplicating this. What would
be different about Cygwin in this case?

--joel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-29 12:04       ` Corinna Vinschen
@ 2017-06-29 19:38         ` Yaakov Selkowitz
  2017-06-29 21:17           ` Joel Sherrill
  0 siblings, 1 reply; 19+ messages in thread
From: Yaakov Selkowitz @ 2017-06-29 19:38 UTC (permalink / raw)
  To: newlib

On 2017-06-29 07:04, Corinna Vinschen wrote:
> On Jun 29 13:53, Corinna Vinschen wrote:
>> On Jun 29 12:41, Aditya Upadhyay wrote:
>>> Hello Developers,
>>>
>>> This is the modified patch for csinl.c which reflects changes in Makefile.am.
>>
>> Uhm... this patch now contains *only* the Makefile.am change, but
>> not the expected csinl.c file.
>>
>> v3? ;)
> 
> Never mind, I'm going to apply v1 and v2 of patch 18.  However, usually
> a v2 (or v3, v4, ...) of a patch is expected to replace the v1 of the
> patch entirely, not that it just contains a diff to v1.
> 
> I pushed the set now and regenerated complex/Makefile.in.

This patchset is causing errors when building Cygwin:

newlib/libm/complex/cargl.c: In function  cargl’:
newlib/libm/complex/cargl.c:16:25: error: implicit declaration of 
function ‘imag’ [-Werror=implicit-function-declaration]
           return atan2l (imag (z), real (z));
                          ^
newlib/libm/complex/cargl.c:16:35: error: implicit declaration of 
function ‘real’ [-Werror=implicit-function-declaration]
           return atan2l (imag (z), real (z));
                                    ^

-- 
Yaakov

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-29 16:18     ` Joseph Myers
@ 2017-06-29 16:31       ` Joel Sherrill
  0 siblings, 0 replies; 19+ messages in thread
From: Joel Sherrill @ 2017-06-29 16:31 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Dionna Amalie Glaze, Aditya Upadhyay, newlib



On 6/29/2017 11:18 AM, Joseph Myers wrote:
> On Wed, 28 Jun 2017, Joel Sherrill wrote:
> 
>> Also, although I don't know how to run them, doesn't someone
>> run glibc tests on newlib? They likely have tests for this for
>> newlib's purposes.
> 
> It would be interesting to see results of glibc libm tests (current git
> please, there have been major changes since the last release) for a range
> of libm implementations and operating systems, but also probably a lot of
> work to get them building with other C libraries; they make plenty of use
> of glibc features, include some internal glibc headers for configuration
> of some details of the architecture, and hardcode glibc choices of goals
> for errno, exceptions and accuracy that other libm implementations may
> differ on.  An implementation/architecture-specific libm-test-ulps file
> also needs to be generated before you can expect clean results even for an
> implementation following glibc's goals.
> 

That would be interesting. In theory, we should be able to mimic the
internal glibc .h files. The devil is in the detail.

My first order problem is that I have never seen the procedure for running
glibc tests against a newlib based toolset for any newlib target -- embedded,
Cygwin, or Linux.

Heck.. as I posted earlier, I don't even know what to do to run the
tests inside the newlib tree. :(

-joel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-28 21:57   ` Joel Sherrill
@ 2017-06-29 16:18     ` Joseph Myers
  2017-06-29 16:31       ` Joel Sherrill
  0 siblings, 1 reply; 19+ messages in thread
From: Joseph Myers @ 2017-06-29 16:18 UTC (permalink / raw)
  To: Joel Sherrill; +Cc: Dionna Amalie Glaze, Aditya Upadhyay, newlib

On Wed, 28 Jun 2017, Joel Sherrill wrote:

> Also, although I don't know how to run them, doesn't someone
> run glibc tests on newlib? They likely have tests for this for
> newlib's purposes.

It would be interesting to see results of glibc libm tests (current git 
please, there have been major changes since the last release) for a range 
of libm implementations and operating systems, but also probably a lot of 
work to get them building with other C libraries; they make plenty of use 
of glibc features, include some internal glibc headers for configuration 
of some details of the architecture, and hardcode glibc choices of goals 
for errno, exceptions and accuracy that other libm implementations may 
differ on.  An implementation/architecture-specific libm-test-ulps file 
also needs to be generated before you can expect clean results even for an 
implementation following glibc's goals.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-29  6:39 ` Corinna Vinschen
  2017-06-29  7:11   ` Aditya Upadhyay
@ 2017-06-29 13:47   ` Joel Sherrill
  1 sibling, 0 replies; 19+ messages in thread
From: Joel Sherrill @ 2017-06-29 13:47 UTC (permalink / raw)
  To: newlib, aditya upadhyay



On 6/29/2017 1:39 AM, Corinna Vinschen wrote:
> Hi Aditya,
> 
> On Jun 29 02:04, Aditya Upadhyay wrote:
>> Hello Developers,
>>
>> I have ported all long double complex methods with suffix "l" from
>> NetBSD. I am attaching the patches for all the methods. I am
>> requesting you to please review these patches and point me any
>> modification needed.
>>
>> Thanks & Regards,
> [...]
> 
> Looks good, just the last patch in the series:
> 
>> Subject: [PATCH 18/18] Importing csinl.c from NetBSD.
> 
> is missing the Makefile.am change.  Care to resend a v2 of patch 18?

Aditya may not need this but it won't hurt to post a hint. git
format-patch has some interesting options. The "-v N" option
adds a version number to the subject so it is clear on mailing
lists which patches are v1 and which are subsequent versions.
Something like this:

git format-patch -o DIRECTORY -v N MY_BRANCH master

I always dump the patches into a subdirectory since the names
are so long they tend to clutter up a normal source directory.

Also it makes it easier to use git send-email to send a patch
set to a mailing list.


> Thanks,
> Corinna
> 

--joel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-29 11:53     ` Corinna Vinschen
@ 2017-06-29 12:04       ` Corinna Vinschen
  2017-06-29 19:38         ` Yaakov Selkowitz
  0 siblings, 1 reply; 19+ messages in thread
From: Corinna Vinschen @ 2017-06-29 12:04 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

On Jun 29 13:53, Corinna Vinschen wrote:
> On Jun 29 12:41, Aditya Upadhyay wrote:
> > Hello Developers,
> > 
> > This is the modified patch for csinl.c which reflects changes in Makefile.am.
> 
> Uhm... this patch now contains *only* the Makefile.am change, but
> not the expected csinl.c file.
> 
> v3? ;)

Never mind, I'm going to apply v1 and v2 of patch 18.  However, usually
a v2 (or v3, v4, ...) of a patch is expected to replace the v1 of the
patch entirely, not that it just contains a diff to v1.

I pushed the set now and regenerated complex/Makefile.in.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-29  7:11   ` Aditya Upadhyay
@ 2017-06-29 11:53     ` Corinna Vinschen
  2017-06-29 12:04       ` Corinna Vinschen
  0 siblings, 1 reply; 19+ messages in thread
From: Corinna Vinschen @ 2017-06-29 11:53 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

On Jun 29 12:41, Aditya Upadhyay wrote:
> Hello Developers,
> 
> This is the modified patch for csinl.c which reflects changes in Makefile.am.

Uhm... this patch now contains *only* the Makefile.am change, but
not the expected csinl.c file.

v3? ;)


Thanks,
Corinna


-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-29  6:39 ` Corinna Vinschen
@ 2017-06-29  7:11   ` Aditya Upadhyay
  2017-06-29 11:53     ` Corinna Vinschen
  2017-06-29 13:47   ` Joel Sherrill
  1 sibling, 1 reply; 19+ messages in thread
From: Aditya Upadhyay @ 2017-06-29  7:11 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

Hello Developers,

This is the modified patch for csinl.c which reflects changes in Makefile.am.

Thanks & Regards,
Aditya Upadhyay

On Thu, Jun 29, 2017 at 12:09 PM, Corinna Vinschen <vinschen@redhat.com> wrote:
> Hi Aditya,
>
> On Jun 29 02:04, Aditya Upadhyay wrote:
>> Hello Developers,
>>
>> I have ported all long double complex methods with suffix "l" from
>> NetBSD. I am attaching the patches for all the methods. I am
>> requesting you to please review these patches and point me any
>> modification needed.
>>
>> Thanks & Regards,
> [...]
>
> Looks good, just the last patch in the series:
>
>> Subject: [PATCH 18/18] Importing csinl.c from NetBSD.
>
> is missing the Makefile.am change.  Care to resend a v2 of patch 18?
>
>
> Thanks,
> Corinna
>
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat

[-- Attachment #2: 0018-Adding-csinl.c-in-Makefile.am.patch --]
[-- Type: text/x-patch, Size: 963 bytes --]

From 18ccb7b9ca0703b22443d87851b66e74270c1d54 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 12:36:09 +0530
Subject: [PATCH v2 18/18] Adding csinl.c in Makefile.am

Signed-off-by: Aditya Upadhyay <aadit0402@gmail.com>
---
 newlib/libm/complex/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 9f733e5..47b9662 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -14,7 +14,7 @@ lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
        catanhl.c conjl.c cpowl.c ctanhl.c ctanl.c \
-       casinhl.c csinhl.c
+       casinhl.c csinhl.c csinl.c
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
-- 
2.7.4


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-28 20:35 Aditya Upadhyay
  2017-06-28 21:36 ` Dionna Amalie Glaze via newlib
@ 2017-06-29  6:39 ` Corinna Vinschen
  2017-06-29  7:11   ` Aditya Upadhyay
  2017-06-29 13:47   ` Joel Sherrill
  1 sibling, 2 replies; 19+ messages in thread
From: Corinna Vinschen @ 2017-06-29  6:39 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

Hi Aditya,

On Jun 29 02:04, Aditya Upadhyay wrote:
> Hello Developers,
> 
> I have ported all long double complex methods with suffix "l" from
> NetBSD. I am attaching the patches for all the methods. I am
> requesting you to please review these patches and point me any
> modification needed.
> 
> Thanks & Regards,
[...]

Looks good, just the last patch in the series:

> Subject: [PATCH 18/18] Importing csinl.c from NetBSD.

is missing the Makefile.am change.  Care to resend a v2 of patch 18?


Thanks,
Corinna


-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-28 21:36 ` Dionna Amalie Glaze via newlib
@ 2017-06-28 21:57   ` Joel Sherrill
  2017-06-29 16:18     ` Joseph Myers
  0 siblings, 1 reply; 19+ messages in thread
From: Joel Sherrill @ 2017-06-28 21:57 UTC (permalink / raw)
  To: Dionna Amalie Glaze, Aditya Upadhyay; +Cc: newlib



On 6/28/2017 4:36 PM, Dionna Amalie Glaze via newlib wrote:
> Gave it a quick look-over (I'm not a core dev, but figured I'd look
> since you seem eager). It looks like everything is indeed from the
> current NetBSD codebase.
> 
> cacoshl.c has #if 0'd code that probably shouldn't be checked in? The
> #if 0 is directly from NetBSD, but still #if 0s aren't nice.
> 
> clogl.c why not use cargl(z) for rr? The compiler would inline it, and
> arg(z) is closer to the math.
> 
> cprojl.c More of a note to others: I was confused why you would use
> HUGE_VAL instead of __INFINITY, but apparently that was a conscious
> change here http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/cprojl.c?rev=1.6&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
> from http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/cprojl.c?rev=1.5&content-type=text/x-cvsweb-markup&only_with_tag=MAIN

I can't argue the rationale for any of the above except to
say that the goal is to import unmodified source from
third party sources. Newlib generally trusts that the
upstream sources are "reputable".


> 
> Would you please include additions to libm/test/ for your included
> functionality? That probably should be upstreamed to NetBSD too, since
> I see they have no tests *gasp*
> http://www.mirrorservice.org/pub/NetBSD/NetBSD-current/src/tests/lib/libm/

Agreed they need tests but that would be a NetBSD issue.

Also, although I don't know how to run them, doesn't someone
run glibc tests on newlib? They likely have tests for this for
newlib's purposes.

<hint>I would like to know how to run then</hint> :)

Aditya.. file a NetBSD ticket with the list of methods they
don't have any tests for. I may have to get a NetBSD account
so I can track the ticket.

FWIW Aditya is a Google Summer of Code student for RTEMS working
to improve POSIX compliance for newlib and by implication
RTEMS and Cygwin. Issues with upstream sources with the code
should be filed upstream.


> On Wed, Jun 28, 2017 at 1:34 PM, Aditya Upadhyay <aadit0402@gmail.com> wrote:
>> Hello Developers,
>>
>> I have ported all long double complex methods with suffix "l" from
>> NetBSD. I am attaching the patches for all the methods. I am
>> requesting you to please review these patches and point me any
>> modification needed.
>>
>> Thanks & Regards,
> 
> 
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Long double complex methods
  2017-06-28 20:35 Aditya Upadhyay
@ 2017-06-28 21:36 ` Dionna Amalie Glaze via newlib
  2017-06-28 21:57   ` Joel Sherrill
  2017-06-29  6:39 ` Corinna Vinschen
  1 sibling, 1 reply; 19+ messages in thread
From: Dionna Amalie Glaze via newlib @ 2017-06-28 21:36 UTC (permalink / raw)
  To: Aditya Upadhyay; +Cc: newlib

Gave it a quick look-over (I'm not a core dev, but figured I'd look
since you seem eager). It looks like everything is indeed from the
current NetBSD codebase.

cacoshl.c has #if 0'd code that probably shouldn't be checked in? The
#if 0 is directly from NetBSD, but still #if 0s aren't nice.

clogl.c why not use cargl(z) for rr? The compiler would inline it, and
arg(z) is closer to the math.

cprojl.c More of a note to others: I was confused why you would use
HUGE_VAL instead of __INFINITY, but apparently that was a conscious
change here http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/cprojl.c?rev=1.6&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
from http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/cprojl.c?rev=1.5&content-type=text/x-cvsweb-markup&only_with_tag=MAIN

Would you please include additions to libm/test/ for your included
functionality? That probably should be upstreamed to NetBSD too, since
I see they have no tests *gasp*
http://www.mirrorservice.org/pub/NetBSD/NetBSD-current/src/tests/lib/libm/

On Wed, Jun 28, 2017 at 1:34 PM, Aditya Upadhyay <aadit0402@gmail.com> wrote:
> Hello Developers,
>
> I have ported all long double complex methods with suffix "l" from
> NetBSD. I am attaching the patches for all the methods. I am
> requesting you to please review these patches and point me any
> modification needed.
>
> Thanks & Regards,



-- 
-Dionna Glaze, PhD (she/her)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Long double complex methods
@ 2017-06-28 20:35 Aditya Upadhyay
  2017-06-28 21:36 ` Dionna Amalie Glaze via newlib
  2017-06-29  6:39 ` Corinna Vinschen
  0 siblings, 2 replies; 19+ messages in thread
From: Aditya Upadhyay @ 2017-06-28 20:35 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

Hello Developers,

I have ported all long double complex methods with suffix "l" from
NetBSD. I am attaching the patches for all the methods. I am
requesting you to please review these patches and point me any
modification needed.

Thanks & Regards,

[-- Attachment #2: 0001-Importing-cacoshl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3084 bytes --]

From 388e5c5c7baead983de6fab7d2b72f9a408e31d1 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:25:21 +0530
Subject: [PATCH 01/18] Importing cacoshl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cacoshl.c   | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cacoshl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 402053f..f747934 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
+lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.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/cacoshl.c b/newlib/libm/complex/cacoshl.c
new file mode 100755
index 0000000..4e4e006
--- /dev/null
+++ b/newlib/libm/complex/cacoshl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: cacoshl.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>
+
+long double complex
+cacoshl(long double complex z)
+{
+	long double complex w;
+
+#if 0 /* does not give the principal value */
+	w = I * cacosl(z);
+#else
+	w = clogl(z + csqrtl(z + 1) * csqrtl(z - 1));
+#endif
+	return w;
+}
-- 
2.7.4


[-- Attachment #3: 0002-Importing-clogl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 2990 bytes --]

From d3e911206859c2703d2ff2ef3b4557db004d4dbe Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:27:48 +0530
Subject: [PATCH 02/18] Importing clogl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  1 +
 newlib/libm/complex/clogl.c     | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100755 newlib/libm/complex/clogl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index f747934..ad5d9a9 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,6 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
+       clogl.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/clogl.c b/newlib/libm/complex/clogl.c
new file mode 100755
index 0000000..3644a44
--- /dev/null
+++ b/newlib/libm/complex/clogl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: clogl.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>
+
+long double complex
+clogl(long double complex z)
+{
+	long double complex w;
+	long double p, rr;
+
+	rr = cabsl(z);
+	p = logl(rr);
+	rr = atan2l(cimagl(z), creall(z));
+	w = p + rr * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #4: 0003-Importing-csqrtl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 4774 bytes --]

From a7992ffa625e2d829a16218b34539b2a1aecb839 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:28:51 +0530
Subject: [PATCH 03/18] Importing csqrtl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |   2 +-
 newlib/libm/complex/csqrtl.c    | 112 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/csqrtl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index ad5d9a9..c70726e 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
       csin.c csinh.c csqrt.c ctan.c ctanh.c
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
-       clogl.c
+       clogl.c csqrtl.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/csqrtl.c b/newlib/libm/complex/csqrtl.c
new file mode 100755
index 0000000..c10a126
--- /dev/null
+++ b/newlib/libm/complex/csqrtl.c
@@ -0,0 +1,112 @@
+/*-
+ * Copyright (c) 2007-2008 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * 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 AUTHOR 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 AUTHOR 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 <sys/cdefs.h>
+#if 0
+__FBSDID("$FreeBSD: head/lib/msun/src/s_csqrtl.c 181402 2008-08-08 00:15:16Z das $");
+#else
+__RCSID("$NetBSD: csqrtl.c,v 1.2 2014/10/11 00:43:51 christos Exp $");
+#endif
+
+#include <complex.h>
+#include <float.h>
+#include <math.h>
+#include <stdbool.h>
+/*
+ * gcc doesn't implement complex multiplication or division correctly,
+ * so we need to handle infinities specially. We turn on this pragma to
+ * notify conforming c99 compilers that the fast-but-incorrect code that
+ * gcc generates is acceptable, since the special cases have already been
+ * handled.
+ */
+// #pragma	STDC CX_LIMITED_RANGE	ON
+
+/* We risk spurious overflow for components >= LDBL_MAX / (1 + sqrt(2)). */
+#define	THRESH	(LDBL_MAX / 2.414213562373095048801688724209698L)
+
+#define cpackl(r, i) ((r) + (i) * I)
+
+long double complex
+csqrtl(long double complex z)
+{
+	long double complex result;
+	long double a, b;
+	long double t;
+	bool scale;
+
+	a = creall(z);
+	b = cimagl(z);
+
+	/* Handle special cases. */
+	if (z == 0.0L)
+		return (cpackl(0.0L, b));
+	if (isinf(b))
+		return (cpackl(INFINITY, b));
+	if (isnan(a)) {
+		t = (b - b) / (b - b);	/* raise invalid if b is not a NaN */
+		return (cpackl(a, t));	/* return NaN + NaN i */
+	}
+	if (isinf(a)) {
+		/*
+		 * csqrt(inf + NaN i)  = inf +  NaN i
+		 * csqrt(inf + y i)    = inf +  0 i
+		 * csqrt(-inf + NaN i) = NaN +- inf i
+		 * csqrt(-inf + y i)   = 0   +  inf i
+		 */
+		if (signbit(a))
+			return (cpackl(fabsl(b - b), copysignl(a, b)));
+		else
+			return (cpackl(a, copysignl(b - b, b)));
+	}
+	/*
+	 * The remaining special case (b is NaN) is handled just fine by
+	 * the normal code path below.
+	 */
+
+	/* Scale to avoid overflow. */
+	if (fabsl(a) >= THRESH || fabsl(b) >= THRESH) {
+		a *= 0.25L;
+		b *= 0.25L;
+		scale = true;
+	} else {
+		scale = false;
+	}
+
+	/* Algorithm 312, CACM vol 10, Oct 1967. */
+	if (a >= 0L) {
+		t = sqrtl((a + hypotl(a, b)) * 0.5L);
+		result = cpackl(t, b / (2.0L * t));
+	} else {
+		t = sqrtl((-a + hypotl(a, b)) * 0.5L);
+		result = cpackl(fabsl(b) / (2.0L * t), copysignl(t, b));
+	}
+
+	/* Rescale. */
+	if (scale)
+		return (result * 2.0L);
+	else
+		return (result);
+}
-- 
2.7.4


[-- Attachment #5: 0004-Importing-cargl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 1465 bytes --]

From 0f754d0339ad356f43e5caafdb899ae4cf456fe1 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:30:47 +0530
Subject: [PATCH 04/18] Importing cargl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cargl.c     | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cargl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index c70726e..48b6d92 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.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
+       clogl.c csqrtl.c cargl.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/cargl.c b/newlib/libm/complex/cargl.c
new file mode 100755
index 0000000..d2885a4
--- /dev/null
+++ b/newlib/libm/complex/cargl.c
@@ -0,0 +1,18 @@
+/* $NetBSD: cargl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+/*
+ * Public domain.
+ */
+
+#include <complex.h>
+#include <math.h>
+
+long double
+cargl(long double complex z)
+{     
+       #ifdef _LDBL_EQ_DBL
+         return carg (z);
+       #else
+         return atan2l (imag (z), real (z));
+       #endif
+}
-- 
2.7.4


[-- Attachment #6: 0005-Importing-cprojl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3593 bytes --]

From 988137c3c30fbccd275f2cb4d1b5e6c56644e0a5 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:31:22 +0530
Subject: [PATCH 05/18] Importing cprojl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cprojl.c    | 64 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cprojl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 48b6d92..1f86709 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.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 cargl.c
+       clogl.c csqrtl.c cargl.c cprojl.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/cprojl.c b/newlib/libm/complex/cprojl.c
new file mode 100755
index 0000000..e71c773
--- /dev/null
+++ b/newlib/libm/complex/cprojl.c
@@ -0,0 +1,64 @@
+/*	$NetBSD: cprojl.c,v 1.7 2014/10/10 00:48:18 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 <sys/cdefs.h>
+__RCSID("$NetBSD: cprojl.c,v 1.7 2014/10/10 00:48:18 christos Exp $");
+
+#include <complex.h>
+#include <math.h>
+
+#include "../common/fdlibm.h"
+
+/*
+ * cprojl(long double complex z)
+ *
+ * These functions return the value of the projection (not stereographic!)
+ * onto the Riemann sphere.
+ *
+ * z projects to z, except that all complex infinities (even those with one
+ * infinite part and one NaN part) project to positive infinity on the real axis.
+ * If z has an infinite part, then cproj(z) shall be equivalent to:
+ *
+ * INFINITY + I * copysign(0.0, cimag(z))
+ */
+long double complex
+cprojl(long double complex z)
+{
+	long_double_complex w = { .z = z };
+
+	/*CONSTCOND*/
+	if (isinf(creall(z)) || isinf(cimagl(z))) {
+#ifdef __INFINITY
+		REAL_PART(w) = HUGE_VAL;
+#else
+		REAL_PART(w) = INFINITY;
+#endif
+		IMAG_PART(w) = copysignl(0.0L, cimagl(z));
+	}
+
+	return (w.z);
+}
-- 
2.7.4


[-- Attachment #7: 0006-Importing-cexpl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3082 bytes --]

From d287a9d05a834bbf5d35b764fad32a234eb8f6f2 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:32:00 +0530
Subject: [PATCH 06/18] Importing cexpl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cexpl.c     | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cexpl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 1f86709..6eaa685 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.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 cargl.c cprojl.c
+       clogl.c csqrtl.c cargl.c cprojl.c cexpl.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/cexpl.c b/newlib/libm/complex/cexpl.c
new file mode 100755
index 0000000..8b56634
--- /dev/null
+++ b/newlib/libm/complex/cexpl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: cexpl.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>
+
+long double complex
+cexpl(long double complex z)
+{
+	long double complex w;
+	long double r, x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+	r = expl(x);
+	w = r * cosl(y) + r * sinl(y) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #8: 0007-Adding-cephes_subrl.h-and-cephes_subrl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 5562 bytes --]

From a829ba6fb13522d8f361c28e65962b1e06073cf6 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:34:23 +0530
Subject: [PATCH 07/18] Adding cephes_subrl.h and cephes_subrl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am    |   5 +-
 newlib/libm/complex/cephes_subrl.c | 128 +++++++++++++++++++++++++++++++++++++
 newlib/libm/complex/cephes_subrl.h |   9 +++
 3 files changed, 140 insertions(+), 2 deletions(-)
 create mode 100755 newlib/libm/complex/cephes_subrl.c
 create mode 100755 newlib/libm/complex/cephes_subrl.h

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 6eaa685..06706ea 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -11,7 +11,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.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 cargl.c cprojl.c cexpl.c
+       clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
+       cephes_subrl.c 
 
 fsrc =	cabsf.c casinf.c ccosf.c cimagf.c cprojf.c  \
         csqrtf.c cacosf.c casinhf.c ccoshf.c clogf.c clog10f.c \
@@ -44,4 +45,4 @@ CHAPTERS = complex.tex
 
 # A partial dependency list.
 
-$(lib_a_OBJECTS): $(srcdir)/../../libc/include/complex.h $(srcdir)/cephes_subr.h $(srcdir)/cephes_subrf.h
+$(lib_a_OBJECTS): $(srcdir)/../../libc/include/complex.h $(srcdir)/cephes_subr.h $(srcdir)/cephes_subrf.h  $(srcdir)/cephes_subrl.h
diff --git a/newlib/libm/complex/cephes_subrl.c b/newlib/libm/complex/cephes_subrl.c
new file mode 100755
index 0000000..8af11df
--- /dev/null
+++ b/newlib/libm/complex/cephes_subrl.c
@@ -0,0 +1,128 @@
+/* $NetBSD: cephes_subrl.c,v 1.2 2014/10/10 14:06:40 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"
+
+/* calculate cosh and sinh */
+
+void
+_cchshl(long double x, long double *c, long double *s)
+{
+	long double e, ei;
+
+	if (fabsl(x) <= 0.5L) {
+		*c = coshl(x);
+		*s = sinhl(x);
+	} else {
+		e = expl(x);
+		ei = 0.5L / e;
+		e = 0.5L * e;
+		*s = e - ei;
+		*c = e + ei;
+	}
+}
+
+/* Program to subtract nearest integer multiple of PI */
+
+/* extended precision value of PI: */
+static const long double DP1 = 3.14159265358979323829596852490908531763125L;
+static const long double DP2 = 1.6667485837041756656403424829301998703007e-19L;
+#ifndef __vax__
+static const long double DP3 = 1.8830410776607851167459095484560349402753e-39L;
+#define MACHEPL 1.1e-38L
+#else
+static const long double DP3 = 0L;
+#define MACHEPL 1.1e-19L
+#endif
+
+long double
+_redupil(long double x)
+{
+	long double t;
+	long long i;
+
+	t = x / M_PIL;
+	if (t >= 0.0L)
+		t += 0.5L;
+	else
+		t -= 0.5L;
+
+	i = t;	/* the multiple */
+	t = i;
+	t = ((x - t * DP1) - t * DP2) - t * DP3;
+	return t;
+}
+
+/* Taylor series expansion for cosh(2y) - cos(2x) */
+
+long double
+_ctansl(long double complex z)
+{
+	long double f, x, x2, y, y2, rn, t;
+	long double d;
+
+	x = fabsl(2.0L * creall(z));
+	y = fabsl(2.0L * cimagl(z));
+
+	x = _redupil(x);
+
+	x = x * x;
+	y = y * y;
+	x2 = 1.0;
+	y2 = 1.0;
+	f = 1.0;
+	rn = 0.0;
+	d = 0.0;
+	do {
+		rn += 1.0L;
+		f *= rn;
+		rn += 1.0L;
+		f *= rn;
+		x2 *= x;
+		y2 *= y;
+		t = y2 + x2;
+		t /= f;
+		d += t;
+
+		rn += 1.0L;
+		f *= rn;
+		rn += 1.0L;
+		f *= rn;
+		x2 *= x;
+		y2 *= y;
+		t = y2 - x2;
+		t /= f;
+		d += t;
+	} while (fabsl(t/d) > MACHEPL);
+	return d;
+}
diff --git a/newlib/libm/complex/cephes_subrl.h b/newlib/libm/complex/cephes_subrl.h
new file mode 100755
index 0000000..6354b23
--- /dev/null
+++ b/newlib/libm/complex/cephes_subrl.h
@@ -0,0 +1,9 @@
+/* $NetBSD: cephes_subrl.h,v 1.1 2014/10/10 00:48:18 christos Exp $ */
+
+void _cchshl(long double, long double *, long double *);
+long double _redupil(long double);
+long double _ctansl(long double complex);
+
+#define	M_PIL	3.14159265358979323846264338327950280e+00L
+#define	M_PI_2L	1.57079632679489661923132169163975140e+00L
+
-- 
2.7.4


[-- Attachment #9: 0008-Importing-cacosl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3042 bytes --]

From cbf08ab8236883182822806423f7611bb53a9847 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:35:44 +0530
Subject: [PATCH 08/18] Importing cacosl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cacosl.c    | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cacosl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 06706ea..8f21ea7 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
-       cephes_subrl.c 
+       cephes_subrl.c cacosl.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/cacosl.c b/newlib/libm/complex/cacosl.c
new file mode 100755
index 0000000..6a05c8c
--- /dev/null
+++ b/newlib/libm/complex/cacosl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: cacosl.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
+cacosl(long double complex z)
+{
+	long double complex w;
+
+	w = casinl(z);
+	w = (M_PI_2L - creall(w)) - cimagl(w) * I;
+	return w;
+}
+
-- 
2.7.4


[-- Attachment #10: 0009-Importing-ccosl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3098 bytes --]

From f4cbe221ef00535e36eb8f2905863898d72d9def Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:36:47 +0530
Subject: [PATCH 09/18] Importing ccosl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/ccosl.c     | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/ccosl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 8f21ea7..ff651eb 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
-       cephes_subrl.c cacosl.c
+       cephes_subrl.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/ccosl.c b/newlib/libm/complex/ccosl.c
new file mode 100755
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


[-- Attachment #11: 0010-Importing-casinl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 4241 bytes --]

From d60181366fe5889f9cae9ee0d66bb889a749b531 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:38:01 +0530
Subject: [PATCH 10/18] Importing casinl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |   2 +-
 newlib/libm/complex/casinl.c    | 120 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/casinl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index ff651eb..3af9f65 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
-       cephes_subrl.c cacosl.c ccosl.c
+       cephes_subrl.c cacosl.c ccosl.c casinl.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/casinl.c b/newlib/libm/complex/casinl.c
new file mode 100755
index 0000000..4884889
--- /dev/null
+++ b/newlib/libm/complex/casinl.c
@@ -0,0 +1,120 @@
+/* $NetBSD: casinl.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>
+
+#ifdef __weak_alias
+__weak_alias(casinl, _casinl)
+#endif
+
+long double complex
+casinl(long double complex z)
+{
+	long double complex w;
+	long double complex ca, ct, zz, z2;
+	long double x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+
+#if 0 /* MD: test is incorrect, casin(>1) is defined */
+	if (y == 0.0L) {
+		if (fabsl(x) > 1.0L) {
+			w = M_PI_2L + 0.0L * I;
+#if 0
+			mtherr ("casinl", DOMAIN);
+#endif
+		} else {
+			w = asinl(x) + 0.0L * I;
+		}
+		return w;
+	}
+#endif
+
+/* Power series expansion */
+/*
+b = cabsl(z);
+if( b < 0.125L )
+{
+z2.r = (x - y) * (x + y);
+z2.i = 2.0L * x * y;
+
+cn = 1.0L;
+n = 1.0L;
+ca.r = x;
+ca.i = y;
+sum.r = x;
+sum.i = y;
+do
+	{
+	ct.r = z2.r * ca.r  -  z2.i * ca.i;
+	ct.i = z2.r * ca.i  +  z2.i * ca.r;
+	ca.r = ct.r;
+	ca.i = ct.i;
+
+	cn *= n;
+	n += 1.0;
+	cn /= n;
+	n += 1.0;
+	b = cn/n;
+
+	ct.r *= b;
+	ct.i *= b;
+	sum.r += ct.r;
+	sum.i += ct.i;
+	b = fabsl(ct.r) + fabsl(ct.i);
+	}
+while( b > MACHEPL );
+w->r = sum.r;
+w->i = sum.i;
+return;
+}
+*/
+
+
+	ca = x + y * I;
+	ct = ca * I;
+	/* sqrtl( 1 - z*z) */
+	/* cmull( &ca, &ca, &zz ) */
+	/*x * x  -  y * y */
+	zz = (x - y) * (x + y) + (2.0L * x * y) * I;
+
+	zz = 1.0L - creall(zz) - cimagl(zz) * I;
+	z2 = csqrtl(zz);
+
+	zz = ct + z2;
+	zz = clogl(zz);
+	/* multiply by 1/i = -i */
+	w = zz * (-1.0L * I);
+	return w;
+}
+
-- 
2.7.4


[-- Attachment #12: 0011-Importing-catanhl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3035 bytes --]

From 86fb75be2f4c1bd24aa2abeb649a1d8719c72e8d Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:38:54 +0530
Subject: [PATCH 11/18] Importing catanhl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  3 ++-
 newlib/libm/complex/catanhl.c   | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/catanhl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 3af9f65..cbbed57 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -12,7 +12,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
-       cephes_subrl.c cacosl.c ccosl.c casinl.c
+       cephes_subrl.c cacosl.c ccosl.c casinl.c \
+       catanhl.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/catanhl.c b/newlib/libm/complex/catanhl.c
new file mode 100755
index 0000000..8975fe8
--- /dev/null
+++ b/newlib/libm/complex/catanhl.c
@@ -0,0 +1,41 @@
+/* $NetBSD: catanhl.c,v 1.3 2014/10/10 12:43:15 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>
+
+long double complex
+catanhl(long double complex z)
+{
+	long double complex w;
+
+	w = -1.0L * I * catanl(z * I);
+	return w;
+}
-- 
2.7.4


[-- Attachment #13: 0012-Importing-conjl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3103 bytes --]

From 9ed0dff1e785b0da7991c7e2896a722f0c6069ce Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:39:48 +0530
Subject: [PATCH 12/18] Importing conjl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/conjl.c     | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/conjl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index cbbed57..736a9e0 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c
+       catanhl.c conjl.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/conjl.c b/newlib/libm/complex/conjl.c
new file mode 100755
index 0000000..35094ce
--- /dev/null
+++ b/newlib/libm/complex/conjl.c
@@ -0,0 +1,46 @@
+/*	$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 <sys/cdefs.h>
+__RCSID("$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $");
+
+#include <complex.h>
+#include "../common/fdlibm.h"
+
+/*
+ * conjl(long double complex z)
+ * This function returns the complex conjugate value of its argument, z.
+ */
+long double complex
+conjl(long double complex z)
+{
+	long_double_complex w = { .z = z };
+
+	IMAG_PART(w) = -IMAG_PART(w);
+
+	return (w.z);
+}
-- 
2.7.4


[-- Attachment #14: 0013-Importing-cpowl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3363 bytes --]

From b3eed382dff7d4703f29a5de4d9d52728faa1de6 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:40:31 +0530
Subject: [PATCH 13/18] Importing cpowl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/cpowl.c     | 56 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/cpowl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 736a9e0..a9db385 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c conjl.c
+       catanhl.c conjl.c cpowl.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/cpowl.c b/newlib/libm/complex/cpowl.c
new file mode 100755
index 0000000..85c2c20
--- /dev/null
+++ b/newlib/libm/complex/cpowl.c
@@ -0,0 +1,56 @@
+/* $NetBSD: cpowl.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>
+
+long double complex
+cpowl(long double complex a, long double complex z)
+{
+	long double complex w;
+	long double x, y, r, theta, absa, arga;
+
+	x = creall(z);
+	y = cimagl(z);
+	absa = cabsl(a);
+	if (absa == 0.0L) {
+		return (0.0L + 0.0L * I);
+	}
+	arga = cargl(a);
+	r = powl(absa, x);
+	theta = x * arga;
+	if (y != 0.0L) {
+		r = r * expl(-y * arga);
+		theta = theta + y * logl(absa);
+	}
+	w = r * cosl(theta) + (r * sinl(theta)) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #15: 0014-Importing-ctanhl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3176 bytes --]

From 16dd28c6ba167bcdd8a01cae54a905064f67989d Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:41:21 +0530
Subject: [PATCH 14/18] Importing ctanhl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/ctanhl.c    | 47 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/ctanhl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index a9db385..95066db 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c conjl.c cpowl.c
+       catanhl.c conjl.c cpowl.c ctanhl.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/ctanhl.c b/newlib/libm/complex/ctanhl.c
new file mode 100755
index 0000000..1db886f
--- /dev/null
+++ b/newlib/libm/complex/ctanhl.c
@@ -0,0 +1,47 @@
+/* $NetBSD: ctanhl.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>
+
+long double complex
+ctanhl(long double complex z)
+{
+	long double complex w;
+	long double x, y, d;
+
+	x = creall(z);
+	y = cimagl(z);
+	d = coshl(2.0L * x) + cosl(2.0L * y);
+	w = sinhl(2.0L * x) / d  +  (sinl(2.0L * y) / d) * I;
+
+	return w;
+}
-- 
2.7.4


[-- Attachment #16: 0015-Importing-ctanl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3358 bytes --]

From 70143a2a956c18b909b6555b76e8512253150e62 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:42:07 +0530
Subject: [PATCH 15/18] Importing ctanl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/ctanl.c     | 56 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100755 newlib/libm/complex/ctanl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index 95066db..f8e493b 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,7 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c conjl.c cpowl.c ctanhl.c
+       catanhl.c conjl.c cpowl.c ctanhl.c ctanl.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/ctanl.c b/newlib/libm/complex/ctanl.c
new file mode 100755
index 0000000..9255bdb
--- /dev/null
+++ b/newlib/libm/complex/ctanl.c
@@ -0,0 +1,56 @@
+/* $NetBSD: ctanl.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
+ctanl(long double complex z)
+{
+	long double complex w;
+	long double d;
+
+	d = cosl(2.0L * creall(z)) + coshl(2.0L * cimagl(z));
+
+	if (fabsl(d) < 0.25L)
+		d = _ctansl(z);
+
+	if (d == 0.0L) {
+		/* mtherr ("ctan", OVERFLOW); */
+		w = HUGE_VALF + HUGE_VALF * I;
+		return w;
+	}
+
+	w = sinl(2.0L * creall(z)) / d + (sinhl(2.0L * cimagl(z)) / d) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #17: 0016-Importing-casinhl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3088 bytes --]

From f39b91e82bde1ff5370749a939cdaf3f44784c72 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:53:34 +0530
Subject: [PATCH 16/18] Importing casinhl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  3 ++-
 newlib/libm/complex/casinhl.c   | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 newlib/libm/complex/casinhl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index f8e493b..c640ffb 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -13,7 +13,8 @@ src = cabs.c cacos.c cacosh.c carg.c casin.c casinh.c \
 lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
-       catanhl.c conjl.c cpowl.c ctanhl.c ctanl.c
+       catanhl.c conjl.c cpowl.c ctanhl.c ctanl.c \
+       casinhl.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/casinhl.c b/newlib/libm/complex/casinhl.c
new file mode 100644
index 0000000..2864791
--- /dev/null
+++ b/newlib/libm/complex/casinhl.c
@@ -0,0 +1,41 @@
+/* $NetBSD: casinhl.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>
+
+long double complex
+casinhl(long double complex z)
+{
+	long double complex w;
+
+	w = -1.0L * I * casinl(z * I);
+	return w;
+}
-- 
2.7.4


[-- Attachment #18: 0017-Importing-csinhl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 3092 bytes --]

From 60caf83af71ebef20dac9ef12d53636662c8850d Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:54:09 +0530
Subject: [PATCH 17/18] Importing csinhl.c from NetBSD.

---
 newlib/libm/complex/Makefile.am |  2 +-
 newlib/libm/complex/csinhl.c    | 45 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 newlib/libm/complex/csinhl.c

diff --git a/newlib/libm/complex/Makefile.am b/newlib/libm/complex/Makefile.am
index c640ffb..9f733e5 100644
--- a/newlib/libm/complex/Makefile.am
+++ b/newlib/libm/complex/Makefile.am
@@ -14,7 +14,7 @@ lsrc = cabsl.c creall.c cimagl.c ccoshl.c cacoshl.c \
        clogl.c csqrtl.c cargl.c cprojl.c cexpl.c \
        cephes_subrl.c cacosl.c ccosl.c casinl.c \
        catanhl.c conjl.c cpowl.c ctanhl.c ctanl.c \
-       casinhl.c
+       casinhl.c csinhl.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/csinhl.c b/newlib/libm/complex/csinhl.c
new file mode 100644
index 0000000..44ed050
--- /dev/null
+++ b/newlib/libm/complex/csinhl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: csinhl.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>
+
+long double complex
+csinhl(long double complex z)
+{
+	long double complex w;
+	long double x, y;
+
+	x = creall(z);
+	y = cimagl(z);
+	w = sinhl(x) * cosl(y) + (coshl(x) * sinl(y)) * I;
+	return w;
+}
-- 
2.7.4


[-- Attachment #19: 0018-Importing-csinl.c-from-NetBSD.patch --]
[-- Type: text/x-patch, Size: 2479 bytes --]

From b748bd150f0a8070f50de86b248eb63d1aad1f93 Mon Sep 17 00:00:00 2001
From: Aditya Upadhyay <aadit0402@gmail.com>
Date: Thu, 29 Jun 2017 01:54:32 +0530
Subject: [PATCH 18/18] Importing csinl.c from NetBSD.

---
 newlib/libm/complex/csinl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 newlib/libm/complex/csinl.c

diff --git a/newlib/libm/complex/csinl.c b/newlib/libm/complex/csinl.c
new file mode 100644
index 0000000..2b96c72
--- /dev/null
+++ b/newlib/libm/complex/csinl.c
@@ -0,0 +1,45 @@
+/* $NetBSD: csinl.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
+csinl(long double complex z)
+{
+	long double complex w;
+	long double ch, sh;
+
+	_cchshl(cimagl(z), &ch, &sh);
+	w = sinl(creall(z)) * ch + (cosl(creall(z)) * sh) * I;
+	return w;
+}
-- 
2.7.4


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-07-05 12:40 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 13:53 Long double complex methods Aditya Upadhyay
2017-06-28 20:35 Aditya Upadhyay
2017-06-28 21:36 ` Dionna Amalie Glaze via newlib
2017-06-28 21:57   ` Joel Sherrill
2017-06-29 16:18     ` Joseph Myers
2017-06-29 16:31       ` Joel Sherrill
2017-06-29  6:39 ` Corinna Vinschen
2017-06-29  7:11   ` Aditya Upadhyay
2017-06-29 11:53     ` Corinna Vinschen
2017-06-29 12:04       ` Corinna Vinschen
2017-06-29 19:38         ` Yaakov Selkowitz
2017-06-29 21:17           ` Joel Sherrill
2017-06-30  9:11             ` Aditya Upadhyay
2017-07-04 21:31               ` Aditya Upadhyay
2017-07-04 21:56                 ` Aditya Upadhyay
2017-07-05  8:27                   ` Corinna Vinschen
2017-07-05  9:02                     ` Aditya Upadhyay
2017-07-05 12:40                       ` Corinna Vinschen
2017-06-29 13:47   ` Joel Sherrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).