bitops.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* $Id: bitops.h,v 1.67 2001/11/19 18:36:34 davem Exp $
  2. * bitops.h: Bit string operations on the Sparc.
  3. *
  4. * Copyright 1995 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright 1996 Eddie C. Dost (ecd@skynet.be)
  6. * Copyright 2001 Anton Blanchard (anton@samba.org)
  7. */
  8. #ifndef _SPARC_BITOPS_H
  9. #define _SPARC_BITOPS_H
  10. #include <linux/compiler.h>
  11. #include <asm/byteorder.h>
  12. #ifdef __KERNEL__
  13. extern unsigned long ___set_bit(unsigned long *addr, unsigned long mask);
  14. extern unsigned long ___clear_bit(unsigned long *addr, unsigned long mask);
  15. extern unsigned long ___change_bit(unsigned long *addr, unsigned long mask);
  16. /*
  17. * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
  18. * is in the highest of the four bytes and bit '31' is the high bit
  19. * within the first byte. Sparc is BIG-Endian. Unless noted otherwise
  20. * all bit-ops return 0 if bit was previously clear and != 0 otherwise.
  21. */
  22. static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr)
  23. {
  24. unsigned long *ADDR, mask;
  25. ADDR = ((unsigned long *) addr) + (nr >> 5);
  26. mask = 1 << (nr & 31);
  27. return ___set_bit(ADDR, mask) != 0;
  28. }
  29. static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
  30. {
  31. unsigned long *ADDR, mask;
  32. ADDR = ((unsigned long *) addr) + (nr >> 5);
  33. mask = 1 << (nr & 31);
  34. (void) ___set_bit(ADDR, mask);
  35. }
  36. static inline int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
  37. {
  38. unsigned long *ADDR, mask;
  39. ADDR = ((unsigned long *) addr) + (nr >> 5);
  40. mask = 1 << (nr & 31);
  41. return ___clear_bit(ADDR, mask) != 0;
  42. }
  43. static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
  44. {
  45. unsigned long *ADDR, mask;
  46. ADDR = ((unsigned long *) addr) + (nr >> 5);
  47. mask = 1 << (nr & 31);
  48. (void) ___clear_bit(ADDR, mask);
  49. }
  50. static inline int test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
  51. {
  52. unsigned long *ADDR, mask;
  53. ADDR = ((unsigned long *) addr) + (nr >> 5);
  54. mask = 1 << (nr & 31);
  55. return ___change_bit(ADDR, mask) != 0;
  56. }
  57. static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
  58. {
  59. unsigned long *ADDR, mask;
  60. ADDR = ((unsigned long *) addr) + (nr >> 5);
  61. mask = 1 << (nr & 31);
  62. (void) ___change_bit(ADDR, mask);
  63. }
  64. #include <asm-generic/bitops/non-atomic.h>
  65. #define smp_mb__before_clear_bit() do { } while(0)
  66. #define smp_mb__after_clear_bit() do { } while(0)
  67. #include <asm-generic/bitops/ffz.h>
  68. #include <asm-generic/bitops/__ffs.h>
  69. #include <asm-generic/bitops/sched.h>
  70. #include <asm-generic/bitops/ffs.h>
  71. #include <asm-generic/bitops/fls.h>
  72. #include <asm-generic/bitops/fls64.h>
  73. #include <asm-generic/bitops/hweight.h>
  74. #include <asm-generic/bitops/find.h>
  75. #include <asm-generic/bitops/ext2-non-atomic.h>
  76. #include <asm-generic/bitops/ext2-atomic.h>
  77. #include <asm-generic/bitops/minix.h>
  78. #endif /* __KERNEL__ */
  79. #endif /* defined(_SPARC_BITOPS_H) */