mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8150617: nth_bit and friends are broken
Reviewed-by: shade, tschatzl, vlivanov
This commit is contained in:
parent
a8672f2267
commit
d15936bdc0
2 changed files with 16 additions and 2 deletions
|
@ -1083,9 +1083,9 @@ const intptr_t OneBit = 1; // only right_most bit set in a word
|
|||
|
||||
// get a word with the n.th or the right-most or left-most n bits set
|
||||
// (note: #define used only so that they can be used in enum constant definitions)
|
||||
#define nth_bit(n) (n >= BitsPerWord ? 0 : OneBit << (n))
|
||||
#define nth_bit(n) (((n) >= BitsPerWord) ? 0 : (OneBit << (n)))
|
||||
#define right_n_bits(n) (nth_bit(n) - 1)
|
||||
#define left_n_bits(n) (right_n_bits(n) << (n >= BitsPerWord ? 0 : (BitsPerWord - n)))
|
||||
#define left_n_bits(n) (right_n_bits(n) << (((n) >= BitsPerWord) ? 0 : (BitsPerWord - (n))))
|
||||
|
||||
// bit-operations using a mask m
|
||||
inline void set_bits (intptr_t& x, intptr_t m) { x |= m; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue