···1919#endif20202121#include <arch/bitops.h>2222-#include <linux/atomic.h>2322#include <linux/compiler.h>2423#include <asm/barrier.h>25242626-/*2727- * set_bit - Atomically set a bit in memory2828- * @nr: the bit to set2929- * @addr: the address to start counting from3030- *3131- * This function is atomic and may not be reordered. See __set_bit()3232- * if you do not require the atomic guarantees.3333- * Note that @nr may be almost arbitrarily large; this function is not3434- * restricted to acting on a single-word quantity.3535- */3636-3737-#define set_bit(nr, addr) (void)test_and_set_bit(nr, addr)3838-3939-/*4040- * clear_bit - Clears a bit in memory4141- * @nr: Bit to clear4242- * @addr: Address to start counting from4343- *4444- * clear_bit() is atomic and may not be reordered. However, it does4545- * not contain a memory barrier, so if it is used for locking purposes,4646- * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic()4747- * in order to ensure changes are visible on other processors.4848- */4949-5050-#define clear_bit(nr, addr) (void)test_and_clear_bit(nr, addr)5151-5252-/*5353- * change_bit - Toggle a bit in memory5454- * @nr: Bit to change5555- * @addr: Address to start counting from5656- *5757- * change_bit() is atomic and may not be reordered.5858- * Note that @nr may be almost arbitrarily large; this function is not5959- * restricted to acting on a single-word quantity.6060- */6161-6262-#define change_bit(nr, addr) (void)test_and_change_bit(nr, addr)6363-6464-/**6565- * test_and_set_bit - Set a bit and return its old value6666- * @nr: Bit to set6767- * @addr: Address to count from6868- *6969- * This operation is atomic and cannot be reordered. 7070- * It also implies a memory barrier.7171- */7272-7373-static inline int test_and_set_bit(int nr, volatile unsigned long *addr)7474-{7575- unsigned int mask, retval;7676- unsigned long flags;7777- unsigned int *adr = (unsigned int *)addr;7878-7979- adr += nr >> 5;8080- mask = 1 << (nr & 0x1f);8181- cris_atomic_save(addr, flags);8282- retval = (mask & *adr) != 0;8383- *adr |= mask;8484- cris_atomic_restore(addr, flags);8585- return retval;8686-}8787-8888-/**8989- * test_and_clear_bit - Clear a bit and return its old value9090- * @nr: Bit to clear9191- * @addr: Address to count from9292- *9393- * This operation is atomic and cannot be reordered. 9494- * It also implies a memory barrier.9595- */9696-9797-static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)9898-{9999- unsigned int mask, retval;100100- unsigned long flags;101101- unsigned int *adr = (unsigned int *)addr;102102-103103- adr += nr >> 5;104104- mask = 1 << (nr & 0x1f);105105- cris_atomic_save(addr, flags);106106- retval = (mask & *adr) != 0;107107- *adr &= ~mask;108108- cris_atomic_restore(addr, flags);109109- return retval;110110-}111111-112112-/**113113- * test_and_change_bit - Change a bit and return its old value114114- * @nr: Bit to change115115- * @addr: Address to count from116116- *117117- * This operation is atomic and cannot be reordered. 118118- * It also implies a memory barrier.119119- */120120-121121-static inline int test_and_change_bit(int nr, volatile unsigned long *addr)122122-{123123- unsigned int mask, retval;124124- unsigned long flags;125125- unsigned int *adr = (unsigned int *)addr;126126- adr += nr >> 5;127127- mask = 1 << (nr & 0x1f);128128- cris_atomic_save(addr, flags);129129- retval = (mask & *adr) != 0;130130- *adr ^= mask;131131- cris_atomic_restore(addr, flags);132132- return retval;133133-}134134-2525+#include <asm-generic/bitops/atomic.h>13526#include <asm-generic/bitops/non-atomic.h>1362713728/*