Path: blob/master/arch/sparc/include/asm/bitops_32.h
17356 views
/*1* bitops.h: Bit string operations on the Sparc.2*3* Copyright 1995 David S. Miller ([email protected])4* Copyright 1996 Eddie C. Dost ([email protected])5* Copyright 2001 Anton Blanchard ([email protected])6*/78#ifndef _SPARC_BITOPS_H9#define _SPARC_BITOPS_H1011#include <linux/compiler.h>12#include <asm/byteorder.h>1314#ifdef __KERNEL__1516#ifndef _LINUX_BITOPS_H17#error only <linux/bitops.h> can be included directly18#endif1920extern unsigned long ___set_bit(unsigned long *addr, unsigned long mask);21extern unsigned long ___clear_bit(unsigned long *addr, unsigned long mask);22extern unsigned long ___change_bit(unsigned long *addr, unsigned long mask);2324/*25* Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'26* is in the highest of the four bytes and bit '31' is the high bit27* within the first byte. Sparc is BIG-Endian. Unless noted otherwise28* all bit-ops return 0 if bit was previously clear and != 0 otherwise.29*/30static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr)31{32unsigned long *ADDR, mask;3334ADDR = ((unsigned long *) addr) + (nr >> 5);35mask = 1 << (nr & 31);3637return ___set_bit(ADDR, mask) != 0;38}3940static inline void set_bit(unsigned long nr, volatile unsigned long *addr)41{42unsigned long *ADDR, mask;4344ADDR = ((unsigned long *) addr) + (nr >> 5);45mask = 1 << (nr & 31);4647(void) ___set_bit(ADDR, mask);48}4950static inline int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)51{52unsigned long *ADDR, mask;5354ADDR = ((unsigned long *) addr) + (nr >> 5);55mask = 1 << (nr & 31);5657return ___clear_bit(ADDR, mask) != 0;58}5960static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)61{62unsigned long *ADDR, mask;6364ADDR = ((unsigned long *) addr) + (nr >> 5);65mask = 1 << (nr & 31);6667(void) ___clear_bit(ADDR, mask);68}6970static inline int test_and_change_bit(unsigned long nr, volatile unsigned long *addr)71{72unsigned long *ADDR, mask;7374ADDR = ((unsigned long *) addr) + (nr >> 5);75mask = 1 << (nr & 31);7677return ___change_bit(ADDR, mask) != 0;78}7980static inline void change_bit(unsigned long nr, volatile unsigned long *addr)81{82unsigned long *ADDR, mask;8384ADDR = ((unsigned long *) addr) + (nr >> 5);85mask = 1 << (nr & 31);8687(void) ___change_bit(ADDR, mask);88}8990#include <asm-generic/bitops/non-atomic.h>9192#define smp_mb__before_clear_bit() do { } while(0)93#define smp_mb__after_clear_bit() do { } while(0)9495#include <asm-generic/bitops/ffz.h>96#include <asm-generic/bitops/__ffs.h>97#include <asm-generic/bitops/sched.h>98#include <asm-generic/bitops/ffs.h>99#include <asm-generic/bitops/fls.h>100#include <asm-generic/bitops/__fls.h>101#include <asm-generic/bitops/fls64.h>102#include <asm-generic/bitops/hweight.h>103#include <asm-generic/bitops/lock.h>104#include <asm-generic/bitops/find.h>105#include <asm-generic/bitops/le.h>106#include <asm-generic/bitops/ext2-atomic.h>107108#endif /* __KERNEL__ */109110#endif /* defined(_SPARC_BITOPS_H) */111112113