update code

This commit is contained in:
Nick Peng
2018-05-21 08:09:03 +08:00
parent 9584d1d082
commit 72dd4e6cd3
11 changed files with 1257 additions and 164 deletions

View File

@@ -91,6 +91,29 @@ static inline void atomic_dec( atomic_t *v )
(void)__sync_fetch_and_sub(&v->counter, 1);
}
/**
* Increment atomic variable
* @param v pointer of type atomic_t
*
* Atomically increments @v by 1.
*/
static inline int atomic_inc_return( atomic_t *v )
{
return __sync_fetch_and_add(&v->counter, 1);
}
/**
* @brief decrement atomic variable
* @param v: pointer of type atomic_t
*
* Atomically decrements @v by 1. Note that the guaranteed
* useful range of an atomic_t is only 24 bits.
*/
static inline int atomic_dec_return( atomic_t *v )
{
return __sync_fetch_and_sub(&v->counter, 1);
}
/**
* @brief Decrement and test
* @param v pointer of type atomic_t