bitops_32.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  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. #ifndef _LINUX_BITOPS_H
  14. #error only <linux/bitops.h> can be included directly
  15. #endif
  16. unsigned long ___set_bit(unsigned long *addr, unsigned long mask);
  17. unsigned long ___clear_bit(unsigned long *addr, unsigned long mask);
  18. unsigned long ___change_bit(unsigned long *addr, unsigned long mask);
  19. /*
  20. * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
  21. * is in the highest of the four bytes and bit '31' is the high bit
  22. * within the first byte. Sparc is BIG-Endian. Unless noted otherwise
  23. * all bit-ops return 0 if bit was previously clear and != 0 otherwise.
  24. */
  25. static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr)
  26. {
  27. unsigned long *ADDR, mask;
  28. ADDR = ((unsigned long *) addr) + (nr >> 5);
  29. mask = 1 << (nr & 31);
  30. return ___set_bit(ADDR, mask) != 0;
  31. }
  32. static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
  33. {
  34. unsigned long *ADDR, mask;
  35. ADDR = ((unsigned long *) addr) + (nr >> 5);
  36. mask = 1 << (nr & 31);
  37. (void) ___set_bit(ADDR, mask);
  38. }
  39. static inline int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
  40. {
  41. unsigned long *ADDR, mask;
  42. ADDR = ((unsigned long *) addr) + (nr >> 5);
  43. mask = 1 << (nr & 31);
  44. return ___clear_bit(ADDR, mask) != 0;
  45. }
  46. static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
  47. {
  48. unsigned long *ADDR, mask;
  49. ADDR = ((unsigned long *) addr) + (nr >> 5);
  50. mask = 1 << (nr & 31);
  51. (void) ___clear_bit(ADDR, mask);
  52. }
  53. static inline int test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
  54. {
  55. unsigned long *ADDR, mask;
  56. ADDR = ((unsigned long *) addr) + (nr >> 5);
  57. mask = 1 << (nr & 31);
  58. return ___change_bit(ADDR, mask) != 0;
  59. }
  60. static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
  61. {
  62. unsigned long *ADDR, mask;
  63. ADDR = ((unsigned long *) addr) + (nr >> 5);
  64. mask = 1 << (nr & 31);
  65. (void) ___change_bit(ADDR, mask);
  66. }
  67. #include <asm-generic/bitops/non-atomic.h>
  68. #include <asm-generic/bitops/ffz.h>
  69. #include <asm-generic/bitops/__ffs.h>
  70. #include <asm-generic/bitops/sched.h>
  71. #include <asm-generic/bitops/ffs.h>
  72. #include <asm-generic/bitops/fls.h>
  73. #include <asm-generic/bitops/__fls.h>
  74. #include <asm-generic/bitops/fls64.h>
  75. #include <asm-generic/bitops/hweight.h>
  76. #include <asm-generic/bitops/lock.h>
  77. #include <asm-generic/bitops/find.h>
  78. #include <asm-generic/bitops/le.h>
  79. #include <asm-generic/bitops/ext2-atomic.h>
  80. #endif /* __KERNEL__ */
  81. #endif /* defined(_SPARC_BITOPS_H) */