atomic.h 508 B

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