set_bit() function.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, ALL:

I have a question regarding the function set_bit() in
linux/include/asm-mips/bitops.h for MIPS 1(R3000).

extern __inline__ void set_bit(int nr, void * addr)
{
	int	mask;
	int	*a = addr;
	__bi_flags;

	a += nr >> 5;                        // <---- why shits right 5
bits? 
	mask = 1 << (nr & 0x1f);
	__bi_save_flags(flags);
	__bi_cli();
	*a |= mask;
	__bi_restore_flags(flags);
}

In

extern __inline__ int test_bit(int nr, const void *addr)
{
	return ((1UL << (nr & 31)) & (((const unsigned int *) addr)[nr
>> 5])) != 0;
}

addr is always passed in as a pointer to an integer. Why does it use
array [nr >>5]?

Any help is greatly appreciated.

Thanks.

Steven Liu



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux