Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
0cd71776
Commit
0cd71776
authored
Feb 05, 2021
by
Piotr Caban
Committed by
Alexandre Julliard
Feb 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Set mxcsr denormal flag in sqrtf if needed.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
08dc5b92
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
32 deletions
+53
-32
math.c
dlls/msvcrt/math.c
+53
-32
No files found.
dlls/msvcrt/math.c
View file @
0cd71776
...
...
@@ -82,6 +82,13 @@ static inline float fp_barrierf(float x)
return
y
;
}
static
inline
double
CDECL
ret_nan
(
BOOL
update_sw
)
{
double
x
=
1
.
0
;
if
(
!
update_sw
)
return
-
NAN
;
return
(
x
-
x
)
/
(
x
-
x
);
}
/*********************************************************************
* _matherr (CRTDLL.@)
*/
...
...
@@ -613,6 +620,28 @@ float CDECL sinhf( float x )
return
ret
;
}
static
BOOL
sqrtf_validate
(
float
*
x
)
{
short
c
=
_fdclass
(
*
x
);
if
(
c
==
FP_ZERO
)
return
FALSE
;
if
(
c
==
FP_NAN
)
return
FALSE
;
if
(
signbit
(
*
x
))
{
*
x
=
math_error
(
_DOMAIN
,
"sqrtf"
,
*
x
,
0
,
ret_nan
(
TRUE
));
return
FALSE
;
}
if
(
c
==
FP_INFINITE
)
return
FALSE
;
return
TRUE
;
}
#if defined(__x86_64__) || defined(__i386__)
float
CDECL
sse2_sqrtf
(
float
);
__ASM_GLOBAL_FUNC
(
sse2_sqrtf
,
"sqrtss %xmm0, %xmm0
\n\t
"
"ret"
)
#endif
/*********************************************************************
* sqrtf (MSVCRT.@)
*
...
...
@@ -620,25 +649,23 @@ float CDECL sinhf( float x )
*/
float
CDECL
sqrtf
(
float
x
)
{
#ifdef __x86_64__
if
(
!
sqrtf_validate
(
&
x
))
return
x
;
return
sse2_sqrtf
(
x
);
#else
static
const
float
tiny
=
1.0e-30
;
float
z
;
int
sign
=
0x80000000
;
int
ix
,
s
,
q
,
m
,
t
,
i
;
unsigned
int
r
;
ix
=
*
(
int
*
)
&
x
;
/* take care of Inf and NaN */
if
((
ix
&
0x7f800000
)
==
0x7f800000
&&
(
ix
==
0x7f800000
||
ix
&
0x7fffff
))
if
(
!
sqrtf_validate
(
&
x
))
return
x
;
/* take care of zero */
if
(
ix
<=
0
)
{
if
((
ix
&
~
sign
)
==
0
)
return
x
;
/* sqrt(+-0) = +-0 */
return
math_error
(
_DOMAIN
,
"sqrtf"
,
x
,
0
,
(
x
-
x
)
/
(
x
-
x
));
/* sqrt(-ve) = sNaN */
}
/* normalize x */
m
=
ix
>>
23
;
if
(
m
==
0
)
{
/* subnormal x */
...
...
@@ -683,6 +710,7 @@ float CDECL sqrtf( float x )
r
=
ix
+
((
unsigned
int
)
m
<<
23
);
z
=
*
(
float
*
)
&
r
;
return
z
;
#endif
}
/*********************************************************************
...
...
@@ -1165,14 +1193,7 @@ double CDECL sinh( double x )
return
ret
;
}
static
inline
double
CDECL
ret_nan
(
BOOL
update_sw
)
{
double
x
=
1
.
0
;
if
(
!
update_sw
)
return
-
NAN
;
return
(
x
-
x
)
/
(
x
-
x
);
}
BOOL
sqrt_validate
(
double
*
x
,
BOOL
update_sw
)
static
BOOL
sqrt_validate
(
double
*
x
,
BOOL
update_sw
)
{
short
c
=
_dclass
(
*
x
);
...
...
@@ -3512,6 +3533,21 @@ __int64 CDECL llrintf(float x)
}
/*********************************************************************
* _fdclass (MSVCR120.@)
*
* Copied from musl: src/math/__fpclassifyf.c
*/
short
CDECL
_fdclass
(
float
x
)
{
union
{
float
f
;
UINT32
i
;
}
u
=
{
x
};
int
e
=
u
.
i
>>
23
&
0xff
;
if
(
!
e
)
return
u
.
i
<<
1
?
FP_SUBNORMAL
:
FP_ZERO
;
if
(
e
==
0xff
)
return
u
.
i
<<
9
?
FP_NAN
:
FP_INFINITE
;
return
FP_NORMAL
;
}
/*********************************************************************
* _dclass (MSVCR120.@)
*
* Copied from musl: src/math/__fpclassify.c
...
...
@@ -3593,21 +3629,6 @@ float CDECL truncf(float x)
}
/*********************************************************************
* _fdclass (MSVCR120.@)
*
* Copied from musl: src/math/__fpclassifyf.c
*/
short
CDECL
_fdclass
(
float
x
)
{
union
{
float
f
;
UINT32
i
;
}
u
=
{
x
};
int
e
=
u
.
i
>>
23
&
0xff
;
if
(
!
e
)
return
u
.
i
<<
1
?
FP_SUBNORMAL
:
FP_ZERO
;
if
(
e
==
0xff
)
return
u
.
i
<<
9
?
FP_NAN
:
FP_INFINITE
;
return
FP_NORMAL
;
}
/*********************************************************************
* _dtest (MSVCR120.@)
*/
short
CDECL
_dtest
(
double
*
x
)
...
...
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