/Ethereal-msm8939-beta9/arch/metag/include/asm/cmpxchg_irq.h

https://bitbucket.org/MilosStamenkovic95/etherealos · C Header · 42 lines · 34 code · 8 blank · 0 comment · 2 complexity · d235188d257bdb5e2ccb719f7e9e2b12 MD5 · raw file

  1. #ifndef __ASM_METAG_CMPXCHG_IRQ_H
  2. #define __ASM_METAG_CMPXCHG_IRQ_H
  3. #include <linux/irqflags.h>
  4. static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
  5. {
  6. unsigned long flags, retval;
  7. local_irq_save(flags);
  8. retval = *m;
  9. *m = val;
  10. local_irq_restore(flags);
  11. return retval;
  12. }
  13. static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
  14. {
  15. unsigned long flags, retval;
  16. local_irq_save(flags);
  17. retval = *m;
  18. *m = val & 0xff;
  19. local_irq_restore(flags);
  20. return retval;
  21. }
  22. static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
  23. unsigned long new)
  24. {
  25. __u32 retval;
  26. unsigned long flags;
  27. local_irq_save(flags);
  28. retval = *m;
  29. if (retval == old)
  30. *m = new;
  31. local_irq_restore(flags); /* implies memory barrier */
  32. return retval;
  33. }
  34. #endif /* __ASM_METAG_CMPXCHG_IRQ_H */