Add missing <complex.h> functions.
FreeBSD doesn't seem interested in having low-quality implementations of
these functions:
cacoshl, cacosl, casinhl, casinl, catanhl, catanl, ccoshl, ccosl, cexpl,
clog, clogf, clogl, cpow, cpowf, cpowl, csinhl, csinl, ctanhl, ctanl.
And they still haven't got round to writing good implementations, so for
now let's just take the NetBSD ones so we have the full set.
Bug: http://b/27555792
Change-Id: I6b72003cf749b1043f006377a01fffe5e1d659bc
diff --git a/libm/Android.mk b/libm/Android.mk
index 5dd140b..7200e5f 100644
--- a/libm/Android.mk
+++ b/libm/Android.mk
@@ -180,6 +180,31 @@
upstream-freebsd/lib/msun/src/w_drem.c \
upstream-freebsd/lib/msun/src/w_dremf.c \
+# The FreeBSD complex functions appear to be better, but they're incomplete.
+# We take the FreeBSD implementations when they exist, but fill out the rest
+# of <complex.h> from NetBSD...
+LOCAL_SRC_FILES += \
+ upstream-netbsd/lib/libm/complex/cacoshl.c \
+ upstream-netbsd/lib/libm/complex/cacosl.c \
+ upstream-netbsd/lib/libm/complex/casinhl.c \
+ upstream-netbsd/lib/libm/complex/casinl.c \
+ upstream-netbsd/lib/libm/complex/catanhl.c \
+ upstream-netbsd/lib/libm/complex/catanl.c \
+ upstream-netbsd/lib/libm/complex/ccoshl.c \
+ upstream-netbsd/lib/libm/complex/ccosl.c \
+ upstream-netbsd/lib/libm/complex/cephes_subrl.c \
+ upstream-netbsd/lib/libm/complex/cexpl.c \
+ upstream-netbsd/lib/libm/complex/clog.c \
+ upstream-netbsd/lib/libm/complex/clogf.c \
+ upstream-netbsd/lib/libm/complex/clogl.c \
+ upstream-netbsd/lib/libm/complex/cpow.c \
+ upstream-netbsd/lib/libm/complex/cpowf.c \
+ upstream-netbsd/lib/libm/complex/cpowl.c \
+ upstream-netbsd/lib/libm/complex/csinhl.c \
+ upstream-netbsd/lib/libm/complex/csinl.c \
+ upstream-netbsd/lib/libm/complex/ctanhl.c \
+ upstream-netbsd/lib/libm/complex/ctanl.c \
+
LOCAL_SRC_FILES_32 += \
fake_long_double.c \
@@ -498,6 +523,9 @@
-Wno-unknown-pragmas \
-fvisibility=hidden \
+LOCAL_CONLYFLAGS := \
+ -std=gnu11 \
+
LOCAL_ASFLAGS := \
-Ibionic/libc \
diff --git a/libm/include/complex.h b/libm/include/complex.h
index ff6b166..b54d2fc 100644
--- a/libm/include/complex.h
+++ b/libm/include/complex.h
@@ -32,9 +32,6 @@
#include <sys/cdefs.h>
#ifdef __GNUC__
-#if __STDC_VERSION__ < 199901
-#define _Complex __complex__
-#endif
#define _Complex_I ((float _Complex)1.0i)
#endif
@@ -51,7 +48,7 @@
#define CMPLX(x, y) ((double complex){ x, y })
#define CMPLXF(x, y) ((float complex){ x, y })
#define CMPLXL(x, y) ((long double complex){ x, y })
-#elif __GNUC_PREREQ__(4, 7)
+#else
#define CMPLX(x, y) __builtin_complex((double)(x), (double)(y))
#define CMPLXF(x, y) __builtin_complex((float)(x), (float)(y))
#define CMPLXL(x, y) __builtin_complex((long double)(x), (long double)(y))
@@ -61,56 +58,103 @@
__BEGIN_DECLS
#pragma GCC visibility push(default)
-double cabs(double complex);
-float cabsf(float complex);
-long double cabsl(long double complex);
-double complex cacos(double complex);
-float complex cacosf(float complex);
-double complex cacosh(double complex);
-float complex cacoshf(float complex);
-double carg(double complex);
-float cargf(float complex);
-long double cargl(long double complex);
-double complex casin(double complex);
-float complex casinf(float complex);
-double complex casinh(double complex);
-float complex casinhf(float complex);
-double complex catan(double complex);
-float complex catanf(float complex);
-double complex catanh(double complex);
-float complex catanhf(float complex);
-double complex ccos(double complex);
-float complex ccosf(float complex);
-double complex ccosh(double complex);
-float complex ccoshf(float complex);
-double complex cexp(double complex);
-float complex cexpf(float complex);
-double cimag(double complex) __pure2;
-float cimagf(float complex) __pure2;
-long double cimagl(long double complex) __pure2;
-double complex conj(double complex) __pure2;
-float complex conjf(float complex) __pure2;
-long double complex
- conjl(long double complex) __pure2;
-float complex cprojf(float complex) __pure2;
-double complex cproj(double complex) __pure2;
-long double complex
- cprojl(long double complex) __pure2;
-double creal(double complex) __pure2;
-float crealf(float complex) __pure2;
-long double creall(long double complex) __pure2;
-double complex csin(double complex);
-float complex csinf(float complex);
-double complex csinh(double complex);
-float complex csinhf(float complex);
-double complex csqrt(double complex);
-float complex csqrtf(float complex);
-long double complex
- csqrtl(long double complex);
-double complex ctan(double complex);
-float complex ctanf(float complex);
-double complex ctanh(double complex);
-float complex ctanhf(float complex);
+/* 7.3.5 Trigonometric functions */
+/* 7.3.5.1 The cacos functions */
+double complex cacos(double complex);
+float complex cacosf(float complex);
+long double complex cacosl(long double 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);
+float complex ccosf(float complex);
+long double complex ccosl(long double complex);
+/* 7.3.5.1 The csin functions */
+double complex csin(double complex);
+float complex csinf(float complex);
+long double complex csinl(long double complex);
+/* 7.3.5.1 The ctan functions */
+double complex ctan(double complex);
+float complex ctanf(float complex);
+long double complex ctanl(long double complex);
+
+/* 7.3.6 Hyperbolic functions */
+/* 7.3.6.1 The cacosh functions */
+double complex cacosh(double complex);
+float complex cacoshf(float complex);
+long double complex cacoshl(long double complex);
+/* 7.3.6.2 The casinh functions */
+double complex casinh(double complex);
+float complex casinhf(float complex);
+long double complex casinhl(long double complex);
+/* 7.3.6.3 The catanh functions */
+double complex catanh(double complex);
+float complex catanhf(float complex);
+long double complex catanhl(long double complex);
+/* 7.3.6.4 The ccosh functions */
+double complex ccosh(double complex);
+float complex ccoshf(float complex);
+long double complex ccoshl(long double complex);
+/* 7.3.6.5 The csinh functions */
+double complex csinh(double complex);
+float complex csinhf(float complex);
+long double complex csinhl(long double complex);
+/* 7.3.6.6 The ctanh functions */
+double complex ctanh(double complex);
+float complex ctanhf(float complex);
+long double complex ctanhl(long double complex);
+
+/* 7.3.7 Exponential and logarithmic functions */
+/* 7.3.7.1 The cexp functions */
+double complex cexp(double complex);
+float complex cexpf(float complex);
+long double complex cexpl(long double 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 */
+double cabs(double complex);
+float cabsf(float complex);
+long double cabsl(long double complex);
+/* 7.3.8.2 The cpow functions */
+double complex cpow(double complex, double complex);
+float complex cpowf(float complex, float complex);
+long double complex cpowl(long double complex, long double 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);
+float cimagf(float complex);
+long double cimagl(long double complex);
+/* 7.3.9.3 The conj functions */
+double complex conj(double complex);
+float complex conjf(float complex);
+long double complex conjl(long double complex);
+/* 7.3.9.4 The cproj functions */
+double complex cproj(double complex);
+float complex cprojf(float complex);
+long double complex cprojl(long double complex);
+/* 7.3.9.5 The creal functions */
+double creal(double complex);
+float crealf(float complex);
+long double creall(long double complex);
#pragma GCC visibility pop
__END_DECLS
diff --git a/libm/include/math.h b/libm/include/math.h
index ce8e3b2..8e193cb 100644
--- a/libm/include/math.h
+++ b/libm/include/math.h
@@ -108,6 +108,22 @@
extern int signgam;
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
+#if __USE_GNU
+#define M_El 2.718281828459045235360287471352662498L /* e */
+#define M_LOG2El 1.442695040888963407359924681001892137L /* log 2e */
+#define M_LOG10El 0.434294481903251827651128918916605082L /* log 10e */
+#define M_LN2l 0.693147180559945309417232121458176568L /* log e2 */
+#define M_LN10l 2.302585092994045684017991454684364208L /* log e10 */
+#define M_PIl 3.141592653589793238462643383279502884L /* pi */
+#define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
+#define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
+#define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
+#define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
+#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
+#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
+#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
+#endif
+
#if __BSD_VISIBLE
#if 0
/* Old value from 4.4BSD-Lite math.h; this is probably better. */
diff --git a/libm/libm.arm.map b/libm/libm.arm.map
index 842f46c..8d786c5 100644
--- a/libm/libm.arm.map
+++ b/libm/libm.arm.map
@@ -272,6 +272,29 @@
*;
};
+LIBC_O {
+ global:
+ cacoshl;
+ cacosl;
+ casinhl;
+ casinl;
+ catanhl;
+ catanl;
+ ccoshl;
+ ccosl;
+ cexpl;
+ clog;
+ clogf;
+ clogl;
+ cpow;
+ cpowf;
+ cpowl;
+ csinhl;
+ csinl;
+ ctanhl;
+ ctanl;
+} LIBC;
+
LIBC_DEPRECATED { # arm mips
global: # arm mips
___Unwind_Backtrace; # arm
@@ -375,4 +398,4 @@
_Unwind_VRS_Pop; # arm
_Unwind_VRS_Set; # arm
restore_core_regs; # arm
-} LIBC; # arm mips
+} LIBC_O; # arm mips
diff --git a/libm/libm.arm64.map b/libm/libm.arm64.map
index 1623ea0..e610a23 100644
--- a/libm/libm.arm64.map
+++ b/libm/libm.arm64.map
@@ -272,3 +272,26 @@
*;
};
+LIBC_O {
+ global:
+ cacoshl;
+ cacosl;
+ casinhl;
+ casinl;
+ catanhl;
+ catanl;
+ ccoshl;
+ ccosl;
+ cexpl;
+ clog;
+ clogf;
+ clogl;
+ cpow;
+ cpowf;
+ cpowl;
+ csinhl;
+ csinl;
+ ctanhl;
+ ctanl;
+} LIBC;
+
diff --git a/libm/libm.map.txt b/libm/libm.map.txt
index d273603..66dfd19 100644
--- a/libm/libm.map.txt
+++ b/libm/libm.map.txt
@@ -271,6 +271,29 @@
*;
};
+LIBC_O {
+ global:
+ cacoshl;
+ cacosl;
+ casinhl;
+ casinl;
+ catanhl;
+ catanl;
+ ccoshl;
+ ccosl;
+ cexpl;
+ clog;
+ clogf;
+ clogl;
+ cpow;
+ cpowf;
+ cpowl;
+ csinhl;
+ csinl;
+ ctanhl;
+ ctanl;
+} LIBC;
+
LIBC_DEPRECATED { # arm mips
global: # arm mips
___Unwind_Backtrace; # arm
@@ -374,4 +397,4 @@
_Unwind_VRS_Pop; # arm
_Unwind_VRS_Set; # arm
restore_core_regs; # arm
-} LIBC; # arm mips
+} LIBC_O; # arm mips
diff --git a/libm/libm.mips.map b/libm/libm.mips.map
index 2429dba..44bf167 100644
--- a/libm/libm.mips.map
+++ b/libm/libm.mips.map
@@ -272,10 +272,33 @@
*;
};
+LIBC_O {
+ global:
+ cacoshl;
+ cacosl;
+ casinhl;
+ casinl;
+ catanhl;
+ catanl;
+ ccoshl;
+ ccosl;
+ cexpl;
+ clog;
+ clogf;
+ clogl;
+ cpow;
+ cpowf;
+ cpowl;
+ csinhl;
+ csinl;
+ ctanhl;
+ ctanl;
+} LIBC;
+
LIBC_DEPRECATED { # arm mips
global: # arm mips
__fixdfdi; # arm mips
__fixsfdi; # arm mips
__fixunsdfdi; # arm mips
__fixunssfdi; # arm mips
-} LIBC; # arm mips
+} LIBC_O; # arm mips
diff --git a/libm/libm.mips64.map b/libm/libm.mips64.map
index 1623ea0..e610a23 100644
--- a/libm/libm.mips64.map
+++ b/libm/libm.mips64.map
@@ -272,3 +272,26 @@
*;
};
+LIBC_O {
+ global:
+ cacoshl;
+ cacosl;
+ casinhl;
+ casinl;
+ catanhl;
+ catanl;
+ ccoshl;
+ ccosl;
+ cexpl;
+ clog;
+ clogf;
+ clogl;
+ cpow;
+ cpowf;
+ cpowl;
+ csinhl;
+ csinl;
+ ctanhl;
+ ctanl;
+} LIBC;
+
diff --git a/libm/libm.x86.map b/libm/libm.x86.map
index 1623ea0..e610a23 100644
--- a/libm/libm.x86.map
+++ b/libm/libm.x86.map
@@ -272,3 +272,26 @@
*;
};
+LIBC_O {
+ global:
+ cacoshl;
+ cacosl;
+ casinhl;
+ casinl;
+ catanhl;
+ catanl;
+ ccoshl;
+ ccosl;
+ cexpl;
+ clog;
+ clogf;
+ clogl;
+ cpow;
+ cpowf;
+ cpowl;
+ csinhl;
+ csinl;
+ ctanhl;
+ ctanl;
+} LIBC;
+
diff --git a/libm/libm.x86_64.map b/libm/libm.x86_64.map
index 1623ea0..e610a23 100644
--- a/libm/libm.x86_64.map
+++ b/libm/libm.x86_64.map
@@ -272,3 +272,26 @@
*;
};
+LIBC_O {
+ global:
+ cacoshl;
+ cacosl;
+ casinhl;
+ casinl;
+ catanhl;
+ catanl;
+ ccoshl;
+ ccosl;
+ cexpl;
+ clog;
+ clogf;
+ clogl;
+ cpow;
+ cpowf;
+ cpowl;
+ csinhl;
+ csinl;
+ ctanhl;
+ ctanl;
+} LIBC;
+
diff --git a/libm/upstream-netbsd/lib/libm/complex/cacoshl.c b/libm/upstream-netbsd/lib/libm/complex/cacoshl.c
new file mode 100644
index 0000000..4e4e006
--- /dev/null
+++ b/libm/upstream-netbsd/lib/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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cacosl.c b/libm/upstream-netbsd/lib/libm/complex/cacosl.c
new file mode 100644
index 0000000..e481158
--- /dev/null
+++ b/libm/upstream-netbsd/lib/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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/casinhl.c b/libm/upstream-netbsd/lib/libm/complex/casinhl.c
new file mode 100644
index 0000000..9f74ee9
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/casinhl.c
@@ -0,0 +1,42 @@
+/* $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 "../src/namespace.h"
+#include <complex.h>
+
+long double complex
+casinhl(long double complex z)
+{
+ long double complex w;
+
+ w = -1.0L * I * casinl(z * I);
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/casinl.c b/libm/upstream-netbsd/lib/libm/complex/casinl.c
new file mode 100644
index 0000000..986a8c0
--- /dev/null
+++ b/libm/upstream-netbsd/lib/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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/catanhl.c b/libm/upstream-netbsd/lib/libm/complex/catanhl.c
new file mode 100644
index 0000000..4969b70
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/catanhl.c
@@ -0,0 +1,42 @@
+/* $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 "../src/namespace.h"
+#include <complex.h>
+
+long double complex
+catanhl(long double complex z)
+{
+ long double complex w;
+
+ w = -1.0L * I * catanl(z * I);
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/catanl.c b/libm/upstream-netbsd/lib/libm/complex/catanl.c
new file mode 100644
index 0000000..bdff23f
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/catanl.c
@@ -0,0 +1,80 @@
+/* $NetBSD: catanl.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 "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+#include <float.h>
+#include "cephes_subrl.h"
+
+#ifdef __weak_alias
+__weak_alias(catanl, _catanl)
+#endif
+
+#define MAXNUM LDBL_MAX
+
+long double complex
+catanl(long double complex z)
+{
+ long double complex w;
+ long double a, t, x, x2, y;
+
+ x = creall(z);
+ y = cimagl(z);
+
+ if ((x == 0.0L) && (y > 1.0L))
+ goto ovrf;
+
+ x2 = x * x;
+ a = 1.0L - x2 - (y * y);
+ if (a == 0.0)
+ goto ovrf;
+
+ t = 0.5L * atan2l(2.0L * x, a);
+ w = _redupil(t);
+
+ t = y - 1.0L;
+ a = x2 + (t * t);
+ if (a == 0.0L)
+ goto ovrf;
+
+ t = y + 1.0L;
+ a = (x2 + (t * t))/a;
+ w = w + (0.25L * logl(a)) * I;
+ return w;
+
+ovrf:
+#if 0
+ mtherr ("catanl", OVERFLOW);
+#endif
+ w = MAXNUM + MAXNUM * I;
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/ccoshl.c b/libm/upstream-netbsd/lib/libm/complex/ccoshl.c
new file mode 100644
index 0000000..4c33f9d
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/ccoshl.c
@@ -0,0 +1,46 @@
+/* $NetBSD: ccoshl.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 "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+long double complex
+ccoshl(long double complex z)
+{
+ long double complex w;
+ long double x, y;
+
+ x = creall(z);
+ y = cimagl(z);
+ w = coshl(x) * cosl(y) + (sinhl(x) * sinl(y)) * I;
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/ccosl.c b/libm/upstream-netbsd/lib/libm/complex/ccosl.c
new file mode 100644
index 0000000..6ce5661
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/ccosl.c
@@ -0,0 +1,46 @@
+/* $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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.c b/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.c
new file mode 100644
index 0000000..90dbd86
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.c
@@ -0,0 +1,129 @@
+/* $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 "../src/namespace.h"
+#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/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.h b/libm/upstream-netbsd/lib/libm/complex/cephes_subrl.h
new file mode 100644
index 0000000..6354b23
--- /dev/null
+++ b/libm/upstream-netbsd/lib/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
+
diff --git a/libm/upstream-netbsd/lib/libm/complex/cexpl.c b/libm/upstream-netbsd/lib/libm/complex/cexpl.c
new file mode 100644
index 0000000..a1e2235
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cexpl.c
@@ -0,0 +1,47 @@
+/* $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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/clog.c b/libm/upstream-netbsd/lib/libm/complex/clog.c
new file mode 100644
index 0000000..6362c44
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/clog.c
@@ -0,0 +1,47 @@
+/* $NetBSD: clog.c,v 1.1 2007/08/20 16:01:35 drochner 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 "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+double complex
+clog(double complex z)
+{
+ double complex w;
+ double p, rr;
+
+ rr = cabs(z);
+ p = log(rr);
+ rr = atan2(cimag(z), creal(z));
+ w = p + rr * I;
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/clogf.c b/libm/upstream-netbsd/lib/libm/complex/clogf.c
new file mode 100644
index 0000000..c3cdad0
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/clogf.c
@@ -0,0 +1,47 @@
+/* $NetBSD: clogf.c,v 1.1 2007/08/20 16:01:35 drochner 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 "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+float complex
+clogf(float complex z)
+{
+ float complex w;
+ float p, rr;
+
+ rr = cabsf(z);
+ p = logf(rr);
+ rr = atan2f(cimagf(z), crealf(z));
+ w = p + rr * I;
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/clogl.c b/libm/upstream-netbsd/lib/libm/complex/clogl.c
new file mode 100644
index 0000000..11e7a15
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/clogl.c
@@ -0,0 +1,47 @@
+/* $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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cpow.c b/libm/upstream-netbsd/lib/libm/complex/cpow.c
new file mode 100644
index 0000000..5bc8d3f
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cpow.c
@@ -0,0 +1,57 @@
+/* $NetBSD: cpow.c,v 1.1 2007/08/20 16:01:35 drochner 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 "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+double complex
+cpow(double complex a, double complex z)
+{
+ double complex w;
+ double x, y, r, theta, absa, arga;
+
+ x = creal(z);
+ y = cimag(z);
+ absa = cabs(a);
+ if (absa == 0.0) {
+ return (0.0 + 0.0 * I);
+ }
+ arga = carg(a);
+ r = pow(absa, x);
+ theta = x * arga;
+ if (y != 0.0) {
+ r = r * exp(-y * arga);
+ theta = theta + y * log(absa);
+ }
+ w = r * cos(theta) + (r * sin(theta)) * I;
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cpowf.c b/libm/upstream-netbsd/lib/libm/complex/cpowf.c
new file mode 100644
index 0000000..f7af10a
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cpowf.c
@@ -0,0 +1,57 @@
+/* $NetBSD: cpowf.c,v 1.1 2007/08/20 16:01:36 drochner 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 "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+
+float complex
+cpowf(float complex a, float complex z)
+{
+ float complex w;
+ float x, y, r, theta, absa, arga;
+
+ x = crealf(z);
+ y = cimagf(z);
+ absa = cabsf(a);
+ if (absa == 0.0f) {
+ return (0.0f + 0.0f * I);
+ }
+ arga = cargf(a);
+ r = powf(absa, x);
+ theta = x * arga;
+ if (y != 0.0f) {
+ r = r * expf(-y * arga);
+ theta = theta + y * logf(absa);
+ }
+ w = r * cosf(theta) + (r * sinf(theta)) * I;
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/cpowl.c b/libm/upstream-netbsd/lib/libm/complex/cpowl.c
new file mode 100644
index 0000000..39336ea
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/cpowl.c
@@ -0,0 +1,57 @@
+/* $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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/csinhl.c b/libm/upstream-netbsd/lib/libm/complex/csinhl.c
new file mode 100644
index 0000000..b78f7f1
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/csinhl.c
@@ -0,0 +1,46 @@
+/* $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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/csinl.c b/libm/upstream-netbsd/lib/libm/complex/csinl.c
new file mode 100644
index 0000000..c86847b
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/csinl.c
@@ -0,0 +1,46 @@
+/* $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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/ctanhl.c b/libm/upstream-netbsd/lib/libm/complex/ctanhl.c
new file mode 100644
index 0000000..0894dd0
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/ctanhl.c
@@ -0,0 +1,48 @@
+/* $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 "../src/namespace.h"
+#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;
+}
diff --git a/libm/upstream-netbsd/lib/libm/complex/ctanl.c b/libm/upstream-netbsd/lib/libm/complex/ctanl.c
new file mode 100644
index 0000000..7932aef
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/complex/ctanl.c
@@ -0,0 +1,59 @@
+/* $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 "../src/namespace.h"
+#include <complex.h>
+#include <math.h>
+#include <float.h>
+#include "cephes_subrl.h"
+
+#define MAXNUM LDBL_MAX
+
+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 = MAXNUM + MAXNUM * I;
+ return w;
+ }
+
+ w = sinl(2.0L * creall(z)) / d + (sinhl(2.0L * cimagl(z)) / d) * I;
+ return w;
+}
diff --git a/libm/upstream-netbsd/lib/libm/src/namespace.h b/libm/upstream-netbsd/lib/libm/src/namespace.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libm/upstream-netbsd/lib/libm/src/namespace.h