Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d53d42f1
Commit
d53d42f1
authored
Aug 05, 2020
by
Piotr Caban
Committed by
Alexandre Julliard
Aug 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Import acosf from musl.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a5189756
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
9 deletions
+54
-9
math.c
dlls/msvcrt/math.c
+54
-9
No files found.
dlls/msvcrt/math.c
View file @
d53d42f1
...
...
@@ -219,18 +219,63 @@ INT CDECL MSVCRT__isnanf( float num )
/*********************************************************************
* MSVCRT_acosf (MSVCRT.@)
*
* Copied from musl: src/math/acosf.c
*/
static
float
acosf_R
(
float
z
)
{
static
const
float
pS0
=
1.6666586697e-01
,
pS1
=
-
4.2743422091e-02
,
pS2
=
-
8.6563630030e-03
,
qS1
=
-
7.0662963390e-01
;
float
p
,
q
;
p
=
z
*
(
pS0
+
z
*
(
pS1
+
z
*
pS2
));
q
=
1
.
0
f
+
z
*
qS1
;
return
p
/
q
;
}
float
CDECL
MSVCRT_acosf
(
float
x
)
{
/* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
* asin() uses a similar construction. This is bad because as x gets nearer to
* 1 the error in the expression "1 - x^2" can get relatively large due to
* cancellation. The sqrt() makes things worse. A safer way to calculate
* acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
float
ret
=
atan2f
(
sqrtf
((
1
-
x
)
*
(
1
+
x
)),
x
);
if
(
x
<
-
1
.
0
||
x
>
1
.
0
||
!
finitef
(
x
))
return
math_error
(
_DOMAIN
,
"acosf"
,
x
,
0
,
ret
);
return
ret
;
static
const
float
pio2_hi
=
1.5707962513e+00
,
pio2_lo
=
7.5497894159e-08
;
float
z
,
w
,
s
,
c
,
df
;
unsigned
int
hx
,
ix
;
hx
=
*
(
unsigned
int
*
)
&
x
;
ix
=
hx
&
0x7fffffff
;
/* |x| >= 1 or nan */
if
(
ix
>=
0x3f800000
)
{
if
(
ix
==
0x3f800000
)
{
if
(
hx
>>
31
)
return
2
*
pio2_hi
+
7.5231638453e-37
;
return
0
;
}
if
(
MSVCRT__isnanf
(
x
))
return
x
;
return
math_error
(
_DOMAIN
,
"acosf"
,
x
,
0
,
0
/
(
x
-
x
));
}
/* |x| < 0.5 */
if
(
ix
<
0x3f000000
)
{
if
(
ix
<=
0x32800000
)
/* |x| < 2**-26 */
return
pio2_hi
+
7.5231638453e-37
;
return
pio2_hi
-
(
x
-
(
pio2_lo
-
x
*
acosf_R
(
x
*
x
)));
}
/* x < -0.5 */
if
(
hx
>>
31
)
{
z
=
(
1
+
x
)
*
0
.
5
f
;
s
=
sqrtf
(
z
);
w
=
acosf_R
(
z
)
*
s
-
pio2_lo
;
return
2
*
(
pio2_hi
-
(
s
+
w
));
}
/* x > 0.5 */
z
=
(
1
-
x
)
*
0
.
5
f
;
s
=
sqrtf
(
z
);
hx
=
*
(
unsigned
int
*
)
&
s
&
0xfffff000
;
df
=
*
(
float
*
)
&
hx
;
c
=
(
z
-
df
*
df
)
/
(
s
+
df
);
w
=
acosf_R
(
z
)
*
s
+
c
;
return
2
*
(
df
+
w
);
}
/*********************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment