参照元†
- アトミック値から指定した値を減算し、減算後の値を返す。
- 演算がアトミックに行われるのは、
24bit に収まる範囲内の値までである。
- 汎用処理は SMP 有効時に安全ではないため、
SMP を有効にする場合、各アーキテクチャで定義された関数が使用される。
返り値†
#ifdef CONFIG_SMP
#error not SMP safe
- SMP に対して安全ではないためコンパイルエラーにする。
#endif
/**
* atomic_sub_return - subtract integer from atomic variable
* @i: integer value to subtract
* @v: pointer of type atomic_t
*
* Atomically subtracts @i from @v and returns the result
* Note that the guaranteed useful range of an atomic_t is only 24 bits.
*/
static inline int atomic_sub_return(int i, atomic_t *v)
{
unsigned long flags;
int temp;
local_irq_save(flags);
temp = v->counter;
temp -= i;
v->counter = temp;
local_irq_restore(flags);
return temp;
}
コメント†