Fix number of compile errors and warnings with GCC 14
[lsnes.git] / bsnes-patches / v085 / 0024-Build-fixes-for-GCC-5.X.patch
blob8f2d046b757b4d226f210a96102e33eed4636222
1 From f2bbef8a4e12e05190a68dfe410cff3e4b1eb13f Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Sat, 8 Aug 2015 11:09:41 +0300
4 Subject: [PATCH 24/27] Build fixes for GCC 5.X
6 ---
7 nall/bit.hpp | 21 +++++++++++++++------
8 1 file changed, 15 insertions(+), 6 deletions(-)
10 diff --git a/nall/bit.hpp b/nall/bit.hpp
11 index 67a35ad6..11d9d8de 100755
12 --- a/nall/bit.hpp
13 +++ b/nall/bit.hpp
14 @@ -8,18 +8,27 @@ namespace nall {
17 template<int bits> constexpr inline unsigned uclip(const unsigned x) {
18 - enum { m = (1U << (bits - 1)) + ((1U << (bits - 1)) - 1) };
19 - return (x & m);
20 + return x & ((1U << (bits - 1)) + ((1U << (bits - 1)) - 1));
21 + }
23 + template<int bits> constexpr inline signed sclamp_b() {
24 + return 1U << (bits - 1);
25 + }
27 + template<int bits> constexpr inline signed sclamp_m() {
28 + return (1U << (bits - 1)) - 1;
31 template<int bits> constexpr inline signed sclamp(const signed x) {
32 - enum { b = 1U << (bits - 1), m = (1U << (bits - 1)) - 1 };
33 - return (x > m) ? m : (x < -b) ? -b : x;
34 + return (x > sclamp_m<bits>()) ? sclamp_m<bits>() : (x < -sclamp_b<bits>()) ? -sclamp_b<bits>() : x;
35 + }
37 + template<int bits> constexpr inline signed sclip_m() {
38 + return (1U << (bits)) - 1;
41 template<int bits> constexpr inline signed sclip(const signed x) {
42 - enum { b = 1U << (bits - 1), m = (1U << bits) - 1 };
43 - return ((x & m) ^ b) - b;
44 + return ((x & sclip_m<bits>()) ^ sclamp_b<bits>()) - sclamp_b<bits>();
47 namespace bit {
48 --
49 2.15.0.rc1