Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: fusl/src/complex/ctanhf.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/complex/ctanh.c ('k') | fusl/src/complex/ctanhl.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /* origin: FreeBSD /usr/src/lib/msun/src/s_ctanhf.c */
2 * Copyright 2003 Niels Provos <provos@citi.umich.edu> 2 /*-
3 * Copyright (c) 2011 David Schultz
3 * All rights reserved. 4 * All rights reserved.
4 * 5 *
5 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
7 * are met: 8 * are met:
8 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 10 * notice unmodified, this list of conditions, and the following
11 * disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 #include <stdint.h> 27 /*
28 * Hyperbolic tangent of a complex argument z. See s_ctanh.c for details.
29 */
28 30
29 #include <sys/param.h> 31 #include "libm.h"
30 #include <sys/types.h>
31 #include <sys/syscall.h>
32 #include <sys/epoll.h>
33 #include <unistd.h>
34 32
35 int 33 float complex ctanhf(float complex z)
36 epoll_create(int size)
37 { 34 {
38 » return (syscall(__NR_epoll_create, size)); 35 » float x, y;
36 » float t, beta, s, rho, denom;
37 » uint32_t hx, ix;
38
39 » x = crealf(z);
40 » y = cimagf(z);
41
42 » GET_FLOAT_WORD(hx, x);
43 » ix = hx & 0x7fffffff;
44
45 » if (ix >= 0x7f800000) {
46 » » if (ix & 0x7fffff)
47 » » » return CMPLXF(x, (y == 0 ? y : x * y));
48 » » SET_FLOAT_WORD(x, hx - 0x40000000);
49 » » return CMPLXF(x, copysignf(0, isinf(y) ? y : sinf(y) * cosf(y))) ;
50 » }
51
52 » if (!isfinite(y))
53 » » return CMPLXF(ix ? y - y : x, y - y);
54
55 » if (ix >= 0x41300000) { /* x >= 11 */
56 » » float exp_mx = expf(-fabsf(x));
57 » » return CMPLXF(copysignf(1, x), 4 * sinf(y) * cosf(y) * exp_mx * exp_mx);
58 » }
59
60 » t = tanf(y);
61 » beta = 1.0 + t * t;
62 » s = sinhf(x);
63 » rho = sqrtf(1 + s * s);
64 » denom = 1 + beta * s * s;
65 » return CMPLXF((beta * rho * s) / denom, t / denom);
39 } 66 }
40
41 int
42 epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
43 {
44
45 return (syscall(__NR_epoll_ctl, epfd, op, fd, event));
46 }
47
48 int
49 epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
50 {
51 return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout));
52 }
OLDNEW
« no previous file with comments | « fusl/src/complex/ctanh.c ('k') | fusl/src/complex/ctanhl.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698