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