Index: fusl/src/complex/ctanhf.c |
diff --git a/third_party/libevent/epoll_sub.c b/fusl/src/complex/ctanhf.c |
similarity index 54% |
copy from third_party/libevent/epoll_sub.c |
copy to fusl/src/complex/ctanhf.c |
index 431970c73a6dbe5ff900ac9962f3d3dcc8ddf16f..72b76da075cf83f26a3ea7297af2d0e5e052b039 100644 |
--- a/third_party/libevent/epoll_sub.c |
+++ b/fusl/src/complex/ctanhf.c |
@@ -1,17 +1,17 @@ |
-/* |
- * Copyright 2003 Niels Provos <provos@citi.umich.edu> |
+/* origin: FreeBSD /usr/src/lib/msun/src/s_ctanhf.c */ |
+/*- |
+ * Copyright (c) 2011 David Schultz |
* 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. |
+ * notice unmodified, 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. |
- * 3. The name of the author may not be used to endorse or promote products |
- * derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
@@ -24,29 +24,43 @@ |
* (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 <stdint.h> |
+/* |
+ * Hyperbolic tangent of a complex argument z. See s_ctanh.c for details. |
+ */ |
-#include <sys/param.h> |
-#include <sys/types.h> |
-#include <sys/syscall.h> |
-#include <sys/epoll.h> |
-#include <unistd.h> |
+#include "libm.h" |
-int |
-epoll_create(int size) |
+float complex ctanhf(float complex z) |
{ |
- return (syscall(__NR_epoll_create, size)); |
-} |
+ float x, y; |
+ float t, beta, s, rho, denom; |
+ uint32_t hx, ix; |
-int |
-epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) |
-{ |
+ x = crealf(z); |
+ y = cimagf(z); |
- return (syscall(__NR_epoll_ctl, epfd, op, fd, event)); |
-} |
+ GET_FLOAT_WORD(hx, x); |
+ ix = hx & 0x7fffffff; |
-int |
-epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) |
-{ |
- return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout)); |
+ if (ix >= 0x7f800000) { |
+ if (ix & 0x7fffff) |
+ return CMPLXF(x, (y == 0 ? y : x * y)); |
+ SET_FLOAT_WORD(x, hx - 0x40000000); |
+ return CMPLXF(x, copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))); |
+ } |
+ |
+ if (!isfinite(y)) |
+ return CMPLXF(ix ? y - y : x, y - y); |
+ |
+ if (ix >= 0x41300000) { /* x >= 11 */ |
+ float exp_mx = expf(-fabsf(x)); |
+ return CMPLXF(copysignf(1, x), 4 * sinf(y) * cosf(y) * exp_mx * exp_mx); |
+ } |
+ |
+ t = tanf(y); |
+ beta = 1.0 + t * t; |
+ s = sinhf(x); |
+ rho = sqrtf(1 + s * s); |
+ denom = 1 + beta * s * s; |
+ return CMPLXF((beta * rho * s) / denom, t / denom); |
} |