Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
aba61fe
Fuse xfcosh.cpp into xcosh.cpp.
StephanTLavavej Dec 11, 2025
85ca579
Fuse xfsinh.cpp into xsinh.cpp.
StephanTLavavej Dec 11, 2025
273a6e3
`_CSTD _Cosh(_Left, _Right)` => `_STD cosh(_Left) * _Right`
StephanTLavavej Dec 11, 2025
e1a89bd
`_CSTD _Sinh(_Left, _Right)` => `_STD sinh(_Left) * _Right`
StephanTLavavej Dec 11, 2025
92fc841
Remove non-dllexported `_Xbig`, `_FXbig`.
StephanTLavavej Dec 11, 2025
239063b
Remove non-dllexported _Feraise() and its macros.
StephanTLavavej Dec 11, 2025
7a1618e
Remove now-unused DSIGN, FSIGN macros.
StephanTLavavej Dec 11, 2025
50dd871
Fuse xfdtest.cpp into xdtest.cpp.
StephanTLavavej Dec 11, 2025
2d929dc
Preserve `_Dtest`, `_LDtest`, `_FDtest` for bincompat.
StephanTLavavej Dec 11, 2025
b1c90af
Implement `_Dtest` with `fpclassify`.
StephanTLavavej Dec 11, 2025
7d68c05
Fuse xfexp.cpp into xexp.cpp.
StephanTLavavej Dec 11, 2025
d3fdf99
Preserve `_Exp`, `_FExp`, `_LExp` for bincompat.
StephanTLavavej Dec 11, 2025
ba064e5
Remove non-dllexported `_FDnorm`, `_FDscale`, `_Xfe_overflow`, `_Xfe_…
StephanTLavavej Dec 11, 2025
9588388
Delete xmath.hpp, replace with `<cmath>`.
StephanTLavavej Dec 11, 2025
f97b4ad
Delete internal but user-visible `<ymath.h>`, fuse remnants into `<co…
StephanTLavavej Dec 11, 2025
2ef76e0
Restore special case for zero to the `_Exp` codepaths. Enable passing…
StephanTLavavej Dec 11, 2025
858b3b3
Overhaul GH_001059_hyperbolic_truncation to expect more accurate resu…
StephanTLavavej Dec 11, 2025
3a6a997
x86 actually behaves correctly.
StephanTLavavej Dec 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/inc/xtr1common
${CMAKE_CURRENT_LIST_DIR}/inc/xtree
${CMAKE_CURRENT_LIST_DIR}/inc/xutility
${CMAKE_CURRENT_LIST_DIR}/inc/ymath.h
${CMAKE_CURRENT_LIST_DIR}/inc/yvals.h
${CMAKE_CURRENT_LIST_DIR}/inc/yvals_core.h
)
Expand Down Expand Up @@ -284,13 +283,6 @@ set(SOURCES
${CMAKE_CURRENT_LIST_DIR}/src/xdateord.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xdtest.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xexp.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xfcosh.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xfdnorm.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xfdscale.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xfdtest.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xferaise.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xfexp.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xfsinh.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xgetwctype.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xlgamma.cpp
${CMAKE_CURRENT_LIST_DIR}/src/xlocale.cpp
Expand Down
65 changes: 28 additions & 37 deletions stl/inc/complex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <sstream>
#include <type_traits>
#include <xutility>
#include <ymath.h>

#ifdef _M_CEE_PURE
// no intrinsics for /clr:pure
Expand Down Expand Up @@ -57,6 +56,12 @@ struct _C_ldouble_complex {
#define _RE 0
#define _IM 1

#if defined(__LDBL_DIG__) && __LDBL_DIG__ == 18
_EXTERN_C_UNLESS_PURE
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double*) noexcept;
Comment thread
StephanTLavavej marked this conversation as resolved.
_END_EXTERN_C_UNLESS_PURE
#endif // ^^^ 80-bit long double (not supported by MSVC in general, see GH-1316) ^^^

_STD_BEGIN
// TRANSITION, workaround x86 ABI
// On x86 ABI, floating-point by-value arguments and return values are passed in 80-bit x87 registers.
Expand Down Expand Up @@ -390,20 +395,13 @@ public:
}

static _Ty _Cosh(_Ty _Left, _Ty _Right) { // return cosh(_Left) * _Right
return static_cast<_Ty>(_CSTD _Cosh(static_cast<double>(_Left), static_cast<double>(_Right)));
return static_cast<_Ty>(_STD cosh(static_cast<double>(_Left)) * static_cast<double>(_Right));
}

static _Ty _Copysign(_Ty _Magnitude, _Ty _Sign) {
return static_cast<_Ty>(_Signbit(_Sign) ? -_Abs(_Magnitude) : _Abs(_Magnitude));
}

static short _Exp(_Ty* _Pleft, _Ty _Right, short _Exponent) { // compute exp(*_Pleft) * _Right * 2 ^ _Exponent
double _Tmp = static_cast<double>(*_Pleft);
short _Ans = _CSTD _Exp(&_Tmp, static_cast<double>(_Right), _Exponent);
*_Pleft = static_cast<_Ty>(_Tmp);
return _Ans;
}

static constexpr _Ty _Infv() { // return infinity
return numeric_limits<_Ty>::infinity();
}
Expand All @@ -429,7 +427,7 @@ public:
}

static _Ty _Sinh(_Ty _Left, _Ty _Right) { // return sinh(_Left) * _Right
return static_cast<_Ty>(_CSTD _Sinh(static_cast<double>(_Left), static_cast<double>(_Right)));
return static_cast<_Ty>(_STD sinh(static_cast<double>(_Left)) * static_cast<double>(_Right));
}

static _Ty asinh(_Ty _Left) {
Expand Down Expand Up @@ -528,26 +526,21 @@ public:
}

static _Ty _Cosh(_Ty _Left, _Ty _Right) noexcept { // return cosh(_Left) * _Right
return _CSTD _LCosh(_Left, _Right);
return _STD cosh(_Left) * _Right;
}

static _Ty _Copysign(_Ty _Magnitude, _Ty _Sign) noexcept {
// testing _Sign < 0 would be incorrect when _Sign is -0.0
return _CSTD copysignl(_Magnitude, _Sign);
}

static short _Exp(_Ty* _Pleft, _Ty _Right, short _Exponent) noexcept {
// compute exp(*_Pleft) * _Right * 2 ^ _Exponent
return _CSTD _LExp(_Pleft, _Right, _Exponent);
}

static constexpr _Ty _Infv() noexcept { // return infinity
return numeric_limits<long double>::infinity();
}

static bool _Isinf(_Ty _Left) noexcept { // test for infinity
#if defined(__LDBL_DIG__) && __LDBL_DIG__ == 18
return _CSTD _LDtest(&_Left) == _INFCODE;
return _CSTD _LDtest(&_Left) == 1; // _INFCODE
#else // ^^^ 80-bit long double (not supported by MSVC in general, see GH-1316) / 64-bit long double vvv
const auto _Uint = _Bit_cast<uint64_t>(_Left);
return (_Uint & 0x7fffffffffffffffU) == 0x7ff0000000000000U;
Expand All @@ -556,7 +549,7 @@ public:

static _CONSTEXPR20 bool _Isnan(_Ty _Left) noexcept {
#if defined(__LDBL_DIG__) && __LDBL_DIG__ == 18
return _CSTD _LDtest(&_Left) == _NANCODE;
return _CSTD _LDtest(&_Left) == 2; // _NANCODE
#else // ^^^ 80-bit long double (not supported by MSVC in general, see GH-1316) / 64-bit long double vvv
const auto _Uint = _Bit_cast<uint64_t>(_Left);
return (_Uint & 0x7fffffffffffffffU) > 0x7ff0000000000000U;
Expand All @@ -573,7 +566,7 @@ public:
}

static _Ty _Sinh(_Ty _Left, _Ty _Right) noexcept { // return sinh(_Left) * _Right
return _CSTD _LSinh(_Left, _Right);
return _STD sinh(_Left) * _Right;
}

static _Ty asinh(_Ty _Left) noexcept {
Expand Down Expand Up @@ -672,19 +665,14 @@ public:
}

static _Ty _Cosh(_Ty _Left, _Ty _Right) noexcept { // return cosh(_Left) * _Right
return _CSTD _Cosh(_Left, _Right);
return _STD cosh(_Left) * _Right;
}

static _Ty _Copysign(_Ty _Magnitude, _Ty _Sign) noexcept {
// testing _Sign < 0 would be incorrect when _Sign is -0.0
return _CSTD copysign(_Magnitude, _Sign);
}

static short _Exp(_Ty* _Pleft, _Ty _Right, short _Exponent) noexcept {
// compute exp(*_Pleft) * _Right * 2 ^ _Exponent
return _CSTD _Exp(_Pleft, _Right, _Exponent);
}

static constexpr _Ty _Infv() noexcept { // return infinity
return numeric_limits<double>::infinity();
}
Expand All @@ -709,7 +697,7 @@ public:
}

static _Ty _Sinh(_Ty _Left, _Ty _Right) noexcept { // return sinh(_Left) * _Right
return _CSTD _Sinh(_Left, _Right);
return _STD sinh(_Left) * _Right;
}

static _Ty asinh(_Ty _Left) noexcept {
Expand Down Expand Up @@ -811,19 +799,14 @@ public:
}

static _Ty _Cosh(_Ty _Left, _Ty _Right) noexcept { // return cosh(_Left) * _Right
return _CSTD _FCosh(_Left, _Right);
return _STD cosh(_Left) * _Right;
}

static _Ty _Copysign(_Ty _Magnitude, _Ty _Sign) noexcept {
// testing _Sign < 0 would be incorrect when _Sign is -0.0
return _CSTD copysignf(_Magnitude, _Sign);
}

static short _Exp(_Ty* _Pleft, _Ty _Right, short _Exponent) noexcept {
// compute exp(*_Pleft) * _Right * 2 ^ _Exponent
return _CSTD _FExp(_Pleft, _Right, _Exponent);
}

static constexpr _Ty _Infv() noexcept { // return infinity
return numeric_limits<float>::infinity();
}
Expand All @@ -848,7 +831,7 @@ public:
}

static _Ty _Sinh(_Ty _Left, _Ty _Right) noexcept { // return sinh(_Left) * _Right
return _CSTD _FSinh(_Left, _Right);
return _STD sinh(_Left) * _Right;
}

static _Ty asinh(_Ty _Left) noexcept {
Expand Down Expand Up @@ -1875,10 +1858,18 @@ _NODISCARD complex<_Ty> exp(const complex<_Ty>& _Left) noexcept(_Is_unqual_fp<_T
const _Ty _Theta = _STD imag(_Left);

if (!_Ctraits<_Ty>::_Isnan(_Log_rho) && !_Ctraits<_Ty>::_Isinf(_Log_rho)) { // real component is finite
_Ty _Real = _Log_rho;
_Ty _Imag = _Log_rho;
_Ctraits<_Ty>::_Exp(&_Real, _Ctraits<_Ty>::cos(_Theta), 0);
_Ctraits<_Ty>::_Exp(&_Imag, _Ctraits<_Ty>::sin(_Theta), 0);
const _Ty _Exp_log_rho = _Ctraits<_Ty>::exp(_Log_rho);
_Ty _Real = _Ctraits<_Ty>::cos(_Theta);
_Ty _Imag = _Ctraits<_Ty>::sin(_Theta);

if (_Real != _Ty{0}) {
_Real = _Exp_log_rho * _Real;
}

if (_Imag != _Ty{0}) {
_Imag = _Exp_log_rho * _Imag;
}

return complex<_Ty>(_Real, _Imag);
}

Expand Down
3 changes: 1 addition & 2 deletions stl/inc/header-units.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@
"xtimec.h",
"xtr1common",
"xtree",
"xutility",
"ymath.h"
"xutility"
// "yvals.h", // internal header, provides macros that control header inclusion
// "yvals_core.h" // internal header, provides macros that control header inclusion
]
Expand Down
43 changes: 0 additions & 43 deletions stl/inc/ymath.h

This file was deleted.

7 changes: 0 additions & 7 deletions stl/msbuild/stl_base/stl.files.settings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
<ClCompile Include="$(CrtRoot)\github\stl\src\xdateord.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xdtest.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xexp.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xfcosh.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xfdnorm.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xfdscale.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xfdtest.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xferaise.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xfexp.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xfsinh.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xgetwctype.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xlgamma.cpp" />
<ClCompile Include="$(CrtRoot)\github\stl\src\xlocale.cpp" />
Expand Down
42 changes: 11 additions & 31 deletions stl/src/xcosh.cpp
Original file line number Diff line number Diff line change
@@ -1,43 +1,23 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "xmath.hpp"
#include <cmath>

_EXTERN_C_UNLESS_PURE

_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Cosh(double x, double y) noexcept { // compute y * cosh(x), |y| <= 1
switch (_Dtest(&x)) { // test for special codes
case _NANCODE:
case _INFCODE:
return x;
case 0:
return y;
default: // finite
if (y == 0.0) {
return y;
}

if (x < 0.0) {
x = -x;
}

if (x < _Xbig) { // worth adding in exp(-x)
_Exp(&x, 1.0, -1);
return y * (x + 0.25 / x);
}
switch (_Exp(&x, y, -1)) { // report over/underflow
case 0:
_Feraise(_FE_UNDERFLOW);
break;
case _INFCODE:
_Feraise(_FE_OVERFLOW);
}
return x;
}
// TRANSITION, ABI: preserved for binary compatibility
_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Cosh(double x, double y) noexcept {
return _STD cosh(x) * y;
}

// TRANSITION, ABI: preserved for binary compatibility
_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LCosh(long double x, long double y) noexcept {
return _Cosh(static_cast<double>(x), static_cast<double>(y));
return _STD cosh(x) * y;
}

// TRANSITION, ABI: preserved for binary compatibility
_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FCosh(float x, float y) noexcept {
return _STD cosh(x) * y;
}

_END_EXTERN_C_UNLESS_PURE
26 changes: 11 additions & 15 deletions stl/src/xdtest.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// _Dtest function -- IEEE 754 version

#include "xmath.hpp"
#include <cmath>

_EXTERN_C_UNLESS_PURE

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) noexcept { // categorize *px
const auto ps = reinterpret_cast<_Dval*>(px);
// TRANSITION, ABI: preserved for binary compatibility
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) noexcept {
return static_cast<short>(_STD fpclassify(*px));
}

if ((ps->_Sh[_D0] & _DMASK) == _DMAX << _DOFF) {
return (ps->_Sh[_D0] & _DFRAC) != 0 || ps->_Sh[_D1] != 0 || ps->_Sh[_D2] != 0 || ps->_Sh[_D3] != 0 ? _NANCODE
: _INFCODE;
} else if ((ps->_Sh[_D0] & ~_DSIGN) != 0 || ps->_Sh[_D1] != 0 || ps->_Sh[_D2] != 0 || ps->_Sh[_D3] != 0) {
return (ps->_Sh[_D0] & _DMASK) == 0 ? _DENORM : _FINITE;
} else {
return 0;
}
// TRANSITION, ABI: preserved for binary compatibility
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double* px) noexcept {
return static_cast<short>(_STD fpclassify(*px));
}

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double* px) noexcept { // categorize *px -- 64-bit
return _Dtest(reinterpret_cast<double*>(px));
// TRANSITION, ABI: preserved for binary compatibility
_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FDtest(float* px) noexcept {
return static_cast<short>(_STD fpclassify(*px));
}

_END_EXTERN_C_UNLESS_PURE
Loading
Loading