Skip to content

Commit

Permalink
Reapply adding default switch cases to half.hpp to make compiler happy
Browse files Browse the repository at this point in the history
  • Loading branch information
lightvector committed Feb 18, 2023
1 parent 2f7a95f commit a5cd339
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cpp/external/half-2.2.0/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
NOTE: This version is also locally modified for KataGo to fix some g++
compiler warnings about default switch cases.

Release Notes {#changelog}
=============

Expand Down
9 changes: 9 additions & 0 deletions cpp/external/half-2.2.0/include/half.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// MODIFIED by lightvector to fix some g++ compiler warnings about default switch cases.

// Version 2.2.0

/// \file
Expand Down Expand Up @@ -3093,6 +3095,7 @@ namespace half_float
case 0x5640: return half(detail::binary, 0x4000);
case 0x63D0: return half(detail::binary, 0x4200);
case 0x70E2: return half(detail::binary, 0x4400);
default: break;
}
for(; abs<0x400; abs<<=1,--exp) ;
exp += abs >> 10;
Expand Down Expand Up @@ -3450,6 +3453,7 @@ namespace half_float
case 0x3C00: return half(detail::binary, detail::check_underflow(x.data_));
case 0x4000: return x * x;
case 0xBC00: return half(detail::binary, 0x3C00) / x;
default: break;
}
for(; absx<0x400; absx<<=1,--exp) ;
detail::uint32 ilog = exp + (absx>>10), msign = detail::sign_mask(ilog), f, m =
Expand Down Expand Up @@ -3530,6 +3534,7 @@ namespace half_float
*sin = half(detail::binary, detail::rounded<half::round_style,true>((arg.data_&0x8000)|0x0FE6, 1, 1));
*cos = half(detail::binary, detail::rounded<half::round_style,true>(0x3BFF, 1, 1));
return;
default: break;
}
}
std::pair<detail::uint32,detail::uint32> sc = detail::sincos(detail::angle_arg(abs, k), 28);
Expand All @@ -3538,6 +3543,7 @@ namespace half_float
case 1: sc = std::make_pair(sc.second, -sc.first); break;
case 2: sc = std::make_pair(-sc.first, -sc.second); break;
case 3: sc = std::make_pair(-sc.second, sc.first); break;
default: break;
}
*sin = half(detail::binary, detail::fixed2half<half::round_style,30,true,true,true>((sc.first^-static_cast<detail::uint32>(sign))+sign));
*cos = half(detail::binary, detail::fixed2half<half::round_style,30,true,true,true>(sc.second));
Expand Down Expand Up @@ -3571,6 +3577,7 @@ namespace half_float
case 0x48B7: return half(detail::binary, detail::rounded<half::round_style,true>((~arg.data_&0x8000)|0x1D07, 1, 1));
case 0x6A64: return half(detail::binary, detail::rounded<half::round_style,true>((~arg.data_&0x8000)|0x3BFE, 1, 1));
case 0x6D8C: return half(detail::binary, detail::rounded<half::round_style,true>((arg.data_&0x8000)|0x0FE6, 1, 1));
default: break;
}
std::pair<detail::uint32,detail::uint32> sc = detail::sincos(detail::angle_arg(abs, k), 28);
detail::uint32 sign = -static_cast<detail::uint32>(((k>>1)&1)^(arg.data_>>15));
Expand Down Expand Up @@ -3631,6 +3638,7 @@ namespace half_float
{
case 0x658C: return half(detail::binary, detail::rounded<half::round_style,true>((arg.data_&0x8000)|0x07E6, 1, 1));
case 0x7330: return half(detail::binary, detail::rounded<half::round_style,true>((~arg.data_&0x8000)|0x4B62, 1, 1));
default: break;
}
std::pair<detail::uint32,detail::uint32> sc = detail::sincos(detail::angle_arg(abs, k), 30);
if(k & 1)
Expand Down Expand Up @@ -3892,6 +3900,7 @@ namespace half_float
{
case 0x32D4: return half(detail::binary, detail::rounded<half::round_style,true>(arg.data_-13, 1, 1));
case 0x3B5B: return half(detail::binary, detail::rounded<half::round_style,true>(arg.data_-197, 1, 1));
default: break;
}
return half(detail::binary, detail::area<half::round_style,true>(arg.data_));
#endif
Expand Down

0 comments on commit a5cd339

Please sign in to comment.