hiddenDangerAnalysis.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef _M68K_BITOPS_H
  2. #define _M68K_BITOPS_H
  3. /*
  4. * Copyright 1992, Linus Torvalds.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive
  8. * for more details.
  9. */
  10. #ifndef _LINUX_BITOPS_H
  11. #error only <linux/bitops.h> can be included directly
  12. #endif
  13. #include <linux/compiler.h>
  14. /*
  15. * Bit access functions vary across the ColdFire and 68k families.
  16. * So we will break them out here, and then macro in the ones we want.
  17. *
  18. * ColdFire - supports standard bset/bclr/bchg with register operand only
  19. * 68000 - supports standard bset/bclr/bchg with memory operand
  20. * >= 68020 - also supports the bfset/bfclr/bfchg instructions
  21. *
  22. * Although it is possible to use only the bset/bclr/bchg with register
  23. * operands on all platforms you end up with larger generated code.
  24. * So we use the best form possible on a given platform.
  25. */
  26. static inline void bset_reg_set_bit(int nr, volatile unsigned long *vaddr)
  27. {
  28. char *p = (char *)vaddr + (nr ^ 31) / 8;
  29. __asm__ __volatile__ ("bset %1,(%0)"
  30. :
  31. : "a" (p), "di" (nr & 7)
  32. : "memory");
  33. }
  34. static inline void bset_mem_set_bit(int nr, volatile unsigned long *vaddr)
  35. {
  36. char *p = (char *)vaddr + (nr ^ 31) / 8;
  37. __asm__ __volatile__ ("bset %1,%0"
  38. : "+m" (*p)
  39. : "di" (nr & 7));
  40. }
  41. static inline void bfset_mem_set_bit(int nr, volatile unsigned long *vaddr)
  42. {
  43. __asm__ __volatile__ ("bfset %1{%0:#1}"
  44. :
  45. : "d" (nr ^ 31), "o" (*vaddr)
  46. : "memory");
  47. }
  48. #if defined(CONFIG_COLDFIRE)
  49. #define set_bit(nr, vaddr) bset_reg_set_bit(nr, vaddr)
  50. #elif defined(CONFIG_CPU_HAS_NO_BITFIELDS)
  51. #define set_bit(nr, vaddr) bset_mem_set_bit(nr, vaddr)
  52. #else
  53. #define set_bit(nr, vaddr) (__builtin_constant_p(nr) ? \
  54. bset_mem_set_bit(nr, vaddr) : \
  55. bfset_mem_set_bit(nr, vaddr))
  56. #endif
  57. #define __set_bit(nr, vaddr) set_bit(nr, vaddr)
  58. /*
  59. * clear_bit() doesn't provide any barrier for the compiler.
  60. */
  61. #define smp_mb__before_clear_bit() barrier()
  62. #define smp_mb__after_clear_bit() barrier()
  63. static inline void bclr_reg_clear_bit(int nr, volatile unsigned long *vaddr)
  64. {