linux-mips
[Top] [All Lists]

set_bit() function.

To: <linux-mips@oss.sgi.com>
Subject: set_bit() function.
From: "Steven Liu" <stevenliu@psdc.com>
Date: Mon, 6 Aug 2001 11:04:38 -0700
Sender: owner-linux-mips@oss.sgi.com
Thread-index: AcEeokFaRAkLCp4hQ8eLxQFGPnYOJw==
Thread-topic: set_bit() function.
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


<Prev in Thread] Current Thread [Next in Thread>