atomic.h 474 B

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