Replace bit-twiddling hacks with a portable solution.
Handle non-existent next-higher-power-of-2 in FIFO "gracefully".