set_bit() function.

From: Steven Liu <hidden>
Date: 2001-08-06 18:06:37

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
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help