]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/container/hashfunc.h
libs: remove deprecated non-replaced “register“ storage class
[xonotic/netradiant.git] / libs / container / hashfunc.h
index 6d2166971488b65e7601395d47a533c8aefe9d4e..fa796e5e6efa7ab7ea325d713101ee72c8f07df7 100644 (file)
@@ -182,7 +182,7 @@ inline ub4 hash(
        const UB1Traits& ub1traits,
        const UB4x1Traits& ub4x1traits
        ){
-       register ub4 a,b,c,len;
+       ub4 a,b,c,len;
 
        /* Set up the internal state */
        len = length;
@@ -203,18 +203,33 @@ inline ub4 hash(
        c += length;
        switch ( len )          /* all the case statements fall through */
        {
-       case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 );
-       case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 );
-       case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 );
+#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 );
-       case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 );
-       case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 );
-       case 5: b += UB1Traits::as_ub1( k[4] );
-       case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 );
-       case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 );
-       case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 );
+       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));
+       /* the first byte of c is reserved for the length */
+       case 8: b += ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 ); __attribute((fallthrough));
+       case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 ); __attribute((fallthrough));
+       case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 ); __attribute((fallthrough));
+       case 5: b += UB1Traits::as_ub1( k[4] );  __attribute((fallthrough));
+       case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 ); __attribute((fallthrough));
+       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 );
@@ -240,7 +255,7 @@ inline ub4 hash2(
        ub4 initval, /* the previous hash, or an arbitrary value */
        const UB4Traits& ub4traits
        ){
-       register ub4 a,b,c,len;
+       ub4 a,b,c,len;
 
        /* Set up the internal state */
        len = length;