code: cleanup lint and extra compile warnings

This commit is contained in:
Nick Peng
2022-07-10 10:32:01 +08:00
parent 4e2161c6fc
commit a83818c094
22 changed files with 695 additions and 574 deletions

View File

@@ -20,6 +20,11 @@
#ifndef _GENERIC_ATOMIC_H
#define _GENERIC_ATOMIC_H
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
#define READ_ONCE(x) \
({ typeof(x) ___x = ACCESS_ONCE(x); ___x; })
/**
* Atomic type.
*/
@@ -35,14 +40,20 @@ typedef struct {
*
* Atomically reads the value of @v.
*/
#define atomic_read(v) ((v)->counter)
static inline int atomic_read(const atomic_t *v)
{
return READ_ONCE((v)->counter);
}
/**
* Set atomic variable
* @param v pointer of type atomic_t
* @param i required value
*/
#define atomic_set(v,i) (((v)->counter) = (i))
static inline void atomic_set(atomic_t *v, int i)
{
v->counter = i;
}
/**
* Add to the atomic variable