bitops_32.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * bitops.h: Bit string operations on the Sparc.
  4. *
  5. * Copyright 1995 David S. Miller ([email protected])
  6. * Copyright 1996 Eddie C. Dost ([email protected])
  7. * Copyright 2001 Anton Blanchard ([email protected])
  8. */
  9. #ifndef _SPARC_BITOPS_H
  10. #define _SPARC_BITOPS_H
  11. #include <linux/compiler.h>
  12. #include <asm/byteorder.h>
  13. #ifdef __KERNEL__
  14. #ifndef _LINUX_BITOPS_H
  15. #error only <linux/bitops.h> can be included directly
  16. #endif
  17. unsigned long sp32___set_bit(unsigned long *addr, unsigned long mask);
  18. unsigned long sp32___clear_bit(unsigned long *addr, unsigned long mask);
  19. unsigned long sp32___change_bit(unsigned long *addr, unsigned long mask);
  20. /*
  21. * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
  22. * is in the highest of the four bytes and bit '31' is the high bit
  23. * within the first byte. Sparc is BIG-Endian. Unless noted otherwise
  24. * all bit-ops return 0 if bit was previously clear and != 0 otherwise.
  25. */
  26. static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr)
  27. {
  28. unsigned long *ADDR, mask;
  29. ADDR = ((unsigned long *) addr) + (nr >> 5);
  30. mask = 1 << (nr & 31);
  31. return sp32___set_bit(ADDR, mask) != 0;
  32. }
  33. static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
  34. {
  35. unsigned long *ADDR, mask;
  36. ADDR = ((unsigned long *) addr) + (nr >> 5);
  37. mask = 1 << (nr & 31);
  38. (void) sp32___set_bit(ADDR, mask);
  39. }
  40. static inline int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
  41. {
  42. unsigned long *ADDR, mask;
  43. ADDR = ((unsigned long *) addr) + (nr >> 5);
  44. mask = 1 << (nr & 31);
  45. return sp32___clear_bit(ADDR, mask) != 0;
  46. }
  47. static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
  48. {
  49. unsigned long *ADDR, mask;
  50. ADDR = ((unsigned long *) addr) + (nr >> 5);
  51. mask = 1 << (nr & 31);
  52. (void) sp32___clear_bit(ADDR, mask);
  53. }
  54. static inline int test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
  55. {
  56. unsigned long *ADDR, mask;
  57. ADDR = ((unsigned long *) addr) + (nr >> 5);
  58. mask = 1 << (nr & 31);
  59. return sp32___change_bit(ADDR, mask) != 0;
  60. }
  61. static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
  62. {
  63. unsigned long *ADDR, mask;
  64. ADDR = ((unsigned long *) addr) + (nr >> 5);
  65. mask = 1 << (nr & 31);
  66. (void) sp32___change_bit(ADDR, mask);
  67. }
  68. #include <asm-generic/bitops/non-atomic.h>
  69. #include <asm-generic/bitops/ffz.h>
  70. #include <asm-generic/bitops/__ffs.h>
  71. #include <asm-generic/bitops/sched.h>
  72. #include <asm-generic/bitops/ffs.h>
  73. #include <asm-generic/bitops/fls.h>
  74. #include <asm-generic/bitops/__fls.h>
  75. #include <asm-generic/bitops/fls64.h>
  76. #include <asm-generic/bitops/hweight.h>
  77. #include <asm-generic/bitops/lock.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) */