The following commit has been merged in the master branch: commit b6b57ce2e1bb7ba20eef65ee853d77bc331f85ab Author: Sven Eckelmann sven.eckelmann@gmx.de Date: Sun Dec 12 20:33:17 2010 +0000
batman-adv: Use kernel facilities for bit operations
set_bit and test_bit provide an efficient way to set and test bits of an unsigned long.
This also fixes the problem that a very old ogm got not recorded as received due to the missing constant definition "1" as unsigned long inside the bit_mark operation - also known as "1UL".
Reported-by: David Miller davem@davemloft.net Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de
diff --git a/bitarray.c b/bitarray.c index 814274f..14606fc 100644 --- a/bitarray.c +++ b/bitarray.c @@ -40,7 +40,7 @@ uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno, /* which position in the selected word */ word_offset = (last_seqno - curr_seqno) % WORD_BIT_SIZE;
- if (seq_bits[word_num] & 1 << word_offset) + if (test_bit(word_offset, &seq_bits[word_num])) return 1; else return 0; @@ -61,7 +61,7 @@ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n) /* which position in the selected word */ word_offset = n % WORD_BIT_SIZE;
- seq_bits[word_num] |= 1 << word_offset; /* turn the position on */ + set_bit(word_offset, &seq_bits[word_num]); /* turn the position on */ }
/* shift the packet array by n places. */ diff --git a/bitarray.h b/bitarray.h index 77b1e61..2635d67 100644 --- a/bitarray.h +++ b/bitarray.h @@ -24,6 +24,10 @@
/* you should choose something big, if you don't want to waste cpu * and keep the type in sync with bit_packet_count */ + +/* don't change 'unsigned long' as test_bit()/set_bit()/hweight_long() + * expect this length + */ #define TYPE_OF_WORD unsigned long #define WORD_BIT_SIZE (sizeof(TYPE_OF_WORD) * 8)