/* For example, lets say that @old has bits 4 through 7 set, and @new has bits 12 through 15 set. This defines the mapping of bit position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other bit positions unchanged. So if say @oldbit is 5, then this routine returns 13.  */
int bitmap_bitremap(int oldbit, const unsigned long *old, const unsigned long *new, int bits)
/* For example, lets say that @old has bits 4 through 7 set, and @new has bits 12 through 15 set. This defines the mapping of bit position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other bit positions unchanged. So if say @oldbit is 5, then this routine returns 13.  */
int bitmap_bitremap(int oldbit, const unsigned long *old, const unsigned long *new, int bits)
{
	int w = bitmap_weight(new, bits);
	int n = bitmap_pos_to_ord(old, oldbit, bits);
	if (n < 0 || w == 0)
		return oldbit;
	else
		return bitmap_ord_to_pos(new, n % w, bits);
}