From 6895cb108b8158507bd55d372ab60ca702b8afdc Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Wed, 25 Dec 2019 04:07:10 +0100 Subject: [PATCH] Fix compiling using GCC older than 7, obsolete !143, fix #122, <3 @zturtleman, bananovenc --- libs/container/hashfunc.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/container/hashfunc.h b/libs/container/hashfunc.h index 305202d0..95724ea4 100644 --- a/libs/container/hashfunc.h +++ b/libs/container/hashfunc.h @@ -203,6 +203,20 @@ inline ub4 hash( c += length; switch ( len ) /* all the case statements fall through */ { +#if defined(__GNUC__) && __GNUC__ < 7 + case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 ); /* fall through */ + case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 ); /* fall through */ + case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 ); /* fall through */ + /* the first byte of c is reserved for the length */ + case 8: b += ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 ); /* fall through */ + case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 ); /* fall through */ + case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 ); /* fall through */ + case 5: b += UB1Traits::as_ub1( k[4] ); /* fall through */ + case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 ); /* fall through */ + case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 ); /* fall through */ + case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 ); /* fall through */ + case 1: a += UB1Traits::as_ub1( k[0] ); +#else case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 ); __attribute((fallthrough)); case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 ); __attribute((fallthrough)); case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 ); __attribute((fallthrough)); @@ -215,6 +229,7 @@ inline ub4 hash( case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 ); __attribute((fallthrough)); case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 ); __attribute((fallthrough)); case 1: a += UB1Traits::as_ub1( k[0] ); +#endif /* case 0: nothing left to add */ } mix( a,b,c ); -- 2.39.2