diff --git a/bitbtest.c b/bitbtest.c index 6bc6307..b65d743 100644 --- a/bitbtest.c +++ b/bitbtest.c @@ -221,9 +221,9 @@ static const unsigned int high_flip[56] = { #endif #define bbFlips_Right_high(pos, mask) \ - contig = right_contiguous[(opp_bits_high >> (pos + 1)) & mask]; \ - fl = right_flip[contig] << (pos + 1); \ - t = -(int)(my_bits_high & fl) >> 31; \ + contig = right_contiguous[(opp_bits_high >> (pos + 1u)) & mask]; \ + fl = right_flip[contig] << (pos + 1u); \ + t = ((int)(-(unsigned int)(my_bits_high & fl))) >> 31u; \ my_bits_high |= fl & t; \ flipped = contig & t @@ -544,22 +544,22 @@ static const unsigned int high_flip[56] = { #define bbFlips_Down_2_3(pos, vec, maskh) \ - if (opp_bits_low & (1 << (pos + vec))) { \ - if (opp_bits_low & (1 << (pos + vec * 2))) { \ - t = (opp_bits_high >> (pos + vec * 3 - 32)) & 1; \ - contig = 2 + t; \ - t &= (opp_bits_high >> (pos + vec * 4 - 32)); \ + if (opp_bits_low & (1u << (pos + vec))) { \ + if (opp_bits_low & (1u << (pos + vec * 2u))) { \ + t = (opp_bits_high >> (pos + vec * 3u - 32u)) & 1u; \ + contig = 2u + t; \ + t &= (opp_bits_high >> (pos + vec * 4u - 32u)); \ contig += t; \ - t &= (opp_bits_high >> (pos + vec * 5 - 32)); \ + t &= (opp_bits_high >> (pos + vec * 5u - 32u)); \ contig += t; \ t = lsb_mask[contig - 2] & maskh; \ if (my_bits_high & t) { \ my_bits_high |= t; \ - my_bits_low |= (1 << (pos + vec)) | (1 << (pos + vec * 2)); \ + my_bits_low |= (1u << (pos + vec)) | (1u << (pos + vec * 2u)); \ flipped += contig; \ } \ } else { \ - t = (my_bits_low >> (pos + vec * 2)) & 1; \ + t = (my_bits_low >> (pos + vec * 2u)) & 1u; \ my_bits_low |= t << (pos + vec); \ flipped += t; \ } \ @@ -679,17 +679,17 @@ static const unsigned int high_flip[56] = { #define bbFlips_Down_1_3(pos, vec, maskh) \ - if (opp_bits_low & (1 << (pos + vec))) { \ - t = (opp_bits_high >> (pos + vec * 2 - 32)) & 1; \ + if (opp_bits_low & (1u << (pos + vec))) { \ + t = (opp_bits_high >> (pos + vec * 2u - 32u)) & 1u; \ contig = 1 + t; \ - t &= (opp_bits_high >> (pos + vec * 3 - 32)); \ + t &= (opp_bits_high >> (pos + vec * 3u - 32u)); \ contig += t; \ - t &= (opp_bits_high >> (pos + vec * 4 - 32)); \ + t &= (opp_bits_high >> (pos + vec * 4u - 32u)); \ contig += t; \ - t = lsb_mask[contig - 1] & maskh; \ + t = lsb_mask[contig - 1u] & maskh; \ if (my_bits_high & t) { \ my_bits_high |= t; \ - my_bits_low |= 1 << (pos + vec); \ + my_bits_low |= 1u << (pos + vec); \ flipped += contig; \ } \ } @@ -795,10 +795,10 @@ static const unsigned int high_flip[56] = { #endif #define bbFlips_Up_0_3(pos, vec, mask) \ - if (opp_bits_low & (1 << (pos + 32 - vec))) { \ - t = (opp_bits_low >> (pos + 32 - vec * 2)) & 1; \ + if (opp_bits_low & (1u << (pos + 32u - vec))) { \ + t = (opp_bits_low >> (pos + 32u - vec * 2u)) & 1u; \ contig = 1 + t; \ - t &= (opp_bits_low >> (pos + 32 - vec * 3)); \ + t &= (opp_bits_low >> (pos + 32u - vec * 3u)); \ contig += t; \ fl = msb_mask[contig] & mask; \ t = -(int)(my_bits_low & fl) >> 31; \ @@ -1021,7 +1021,7 @@ TestFlips_bitboard_a8( unsigned int my_bits_high, unsigned int my_bits_low, unsi unsigned int t, fl; /* Right */ - bbFlips_Right_high(24, 0x3F); + bbFlips_Right_high(24u, 0x3Fu); /* Up right */ bbFlips_Up_3_3(24, 7, 0x00020408u, 0x10204080u); /* Up */ @@ -1115,7 +1115,7 @@ TestFlips_bitboard_h2( unsigned int my_bits_high, unsigned int my_bits_low, unsi /* Down left */ bbFlips_Down_2_3(15, 7, 0x02040810u); /* Down */ - bbFlips_Down_2_3(15, 8, 0x80808080u); + bbFlips_Down_2_3(15u, 8u, 0x80808080u); my_bits_low |= 0x00008000u; bb_flips.high = my_bits_high; @@ -1339,7 +1339,7 @@ TestFlips_bitboard_h3( unsigned int my_bits_high, unsigned int my_bits_low, unsi /* Down left */ bbFlips_Down_1_3(23, 7, 0x04081020u); /* Down */ - bbFlips_Down_1_3(23, 8, 0x80808080u); + bbFlips_Down_1_3(23u, 8u, 0x80808080u); /* Up */ bbFlips_Up_1_low(23, 8); /* Up left */ @@ -1553,7 +1553,7 @@ TestFlips_bitboard_h5( unsigned int my_bits_high, unsigned int my_bits_low, unsi /* Down */ bbFlips_Down_2_high(7, 8, 0x00808000u); /* Up */ - bbFlips_Up_0_3(7, 8, 0x80808080u); + bbFlips_Up_0_3(7u, 8u, 0x80808080u); /* Up left */ bbFlips_Up_0_3(7, 9, 0x40201008u); diff --git a/end.c b/end.c index cdc92bc..fc23ccf 100644 --- a/end.c +++ b/end.c @@ -2409,7 +2409,7 @@ setup_end( void ) { if ( dir_mask[pos] & (1 << k) ) { unsigned int neighbor = shift + dir_shift[k]; if ( neighbor < 32 ) - neighborhood_mask[pos].low |= (1 << neighbor); + neighborhood_mask[pos].low |= ((unsigned int)1 << ((unsigned int)neighbor)); else neighborhood_mask[pos].high |= (1 << (neighbor - 32)); } diff --git a/myrandom.c b/myrandom.c index 30c2c1c..bc1f63c 100644 --- a/myrandom.c +++ b/myrandom.c @@ -190,7 +190,7 @@ my_srandom(int x) my_state[ 0 ] = x; for (i = 1; i < my_rand_deg; i++) { - my_state[i] = 1103515245*my_state[i - 1] + 12345; + my_state[i] = ((unsigned int)1103515245)*((unsigned int)my_state[i - 1]) + ((unsigned int )12345); } my_fptr = &my_state[my_rand_sep]; my_rptr = &my_state[0]; @@ -348,7 +348,7 @@ my_random(void) } else { - *my_fptr += *my_rptr; + *my_fptr = ((unsigned int)*my_fptr) + ((unsigned int)*my_rptr); i = (*my_fptr >> 1)&0x7fffffff; /* chucking least random bit */ if (++my_fptr >= my_end_ptr ) { diff --git a/patterns.c b/patterns.c index c14f821..585a4b2 100644 --- a/patterns.c +++ b/patterns.c @@ -97,7 +97,7 @@ transformation_setup( void ) { static void add_single( int mask, int pos ) { if ( mask < 32 ) - depend_lo[pos] |= 1 << mask; + depend_lo[pos] |= ((unsigned int )1) << ((unsigned int)mask); else depend_hi[pos] |= 1 << (mask - 32); } diff --git a/stable.c b/stable.c index f4ad810..e5b828f 100644 --- a/stable.c +++ b/stable.c @@ -281,7 +281,7 @@ count_stable( int color, common_stable.low = edge_stable[edge_a1h1]; - common_stable.high = (edge_stable[edge_a8h8] << 24); + common_stable.high = (((unsigned int)edge_stable[edge_a8h8]) << (unsigned int)24); t = edge_stable[edge_a1a8]; common_stable.low |= ((t & 0x0F) * 0x00204081) & 0x01010101; diff --git a/thordb.c b/thordb.c index be91124..017d4ec 100644 --- a/thordb.c +++ b/thordb.c @@ -2522,18 +2522,18 @@ init_move_masks( void ) { for ( i = 0; i < 4; i++ ) for ( j = 0, pos = 10 * i + 11; j < 8; j++, pos++ ) { index = 8 * i + j; - move_mask_lo[pos] = (1 << index); + move_mask_lo[pos] = (((unsigned int)1) << ((unsigned int)index)); move_mask_hi[pos] = 0; - unmove_mask_lo[pos] = ~(1 << index); + unmove_mask_lo[pos] = ~(((unsigned int)1) << ((unsigned int)index)); unmove_mask_hi[pos] = ~0; } for ( i = 0; i < 4; i++ ) for ( j = 0, pos = 10 * i + 51; j < 8; j++, pos++ ) { index = 8 * i + j; move_mask_lo[pos] = 0; - move_mask_hi[pos] = (1 << index); + move_mask_hi[pos] = (((unsigned int)1) << ((unsigned int)index)); unmove_mask_lo[pos] = ~0; - unmove_mask_hi[pos] = ~(1 << index); + unmove_mask_hi[pos] = ~(((unsigned int)1) << ((unsigned int)index)); } }