NJU-ProjectN / nemu

NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching
Other
889 stars 192 forks source link

Make BITMASK macro safer #11

Closed rapiz1 closed 3 years ago

rapiz1 commented 3 years ago

Use 1ull in shifting to avoid undefined behavior

If users call the original BITMASK(32), the result is undefined. See also https://stackoverflow.com/questions/2648764/whats-bad-about-shifting-a-32-bit-variable-32-bits