Path: blob/master/arch/sh/include/asm/atomic-irq.h
15125 views
#ifndef __ASM_SH_ATOMIC_IRQ_H1#define __ASM_SH_ATOMIC_IRQ_H23/*4* To get proper branch prediction for the main line, we must branch5* forward to code at the end of this object's .text section, then6* branch back to restart the operation.7*/8static inline void atomic_add(int i, atomic_t *v)9{10unsigned long flags;1112raw_local_irq_save(flags);13v->counter += i;14raw_local_irq_restore(flags);15}1617static inline void atomic_sub(int i, atomic_t *v)18{19unsigned long flags;2021raw_local_irq_save(flags);22v->counter -= i;23raw_local_irq_restore(flags);24}2526static inline int atomic_add_return(int i, atomic_t *v)27{28unsigned long temp, flags;2930raw_local_irq_save(flags);31temp = v->counter;32temp += i;33v->counter = temp;34raw_local_irq_restore(flags);3536return temp;37}3839static inline int atomic_sub_return(int i, atomic_t *v)40{41unsigned long temp, flags;4243raw_local_irq_save(flags);44temp = v->counter;45temp -= i;46v->counter = temp;47raw_local_irq_restore(flags);4849return temp;50}5152static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)53{54unsigned long flags;5556raw_local_irq_save(flags);57v->counter &= ~mask;58raw_local_irq_restore(flags);59}6061static inline void atomic_set_mask(unsigned int mask, atomic_t *v)62{63unsigned long flags;6465raw_local_irq_save(flags);66v->counter |= mask;67raw_local_irq_restore(flags);68}6970#endif /* __ASM_SH_ATOMIC_IRQ_H */717273