atomic.h 587 B

123456789101112131415161718192021222324252627
  1. #ifndef _ASM_MICROBLAZE_ATOMIC_H
  2. #define _ASM_MICROBLAZE_ATOMIC_H
  3. #include <asm/cmpxchg.h>
  4. #include <asm-generic/atomic.h>
  5. #include <asm-generic/atomic64.h>
  6. /*
  7. * Atomically test *v and decrement if it is greater than 0.
  8. * The function returns the old value of *v minus 1.
  9. */
  10. static inline int atomic_dec_if_positive(atomic_t *v)
  11. {
  12. unsigned long flags;
  13. int res;
  14. local_irq_save(flags);
  15. res = v->counter - 1;
  16. if (res >= 0)
  17. v->counter = res;
  18. local_irq_restore(flags);
  19. return res;
  20. }
  21. #define atomic_dec_if_positive atomic_dec_if_positive
  22. #endif /* _ASM_MICROBLAZE_ATOMIC_H */