2003-04-22 21:02:15 +02:00
|
|
|
#ifndef SMP_ATOMIC_H
|
|
|
|
#define SMP_ATOMIC_H
|
|
|
|
|
Clean up #ifs
Replace #if CONFIG_FOO==1 with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1[[:space:]]*\$,#if \1," {} +
Replace #if (CONFIG_FOO==1) with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1)[[:space:]]*\$,#if \1," {} +
Replace #if CONFIG_FOO==0 with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0[[:space:]]*\$,#if \!\1," {} +
Replace #if (CONFIG_FOO==0) with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0)[[:space:]]*\$,#if \!\1," {} +
(and some manual changes to fix false positives)
Change-Id: Iac6ca7605a5f99885258cf1a9a2473a92de27c42
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/1004
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Martin Roth <martin@se-eng.com>
2012-05-05 15:29:32 +02:00
|
|
|
#if CONFIG_SMP
|
2003-04-22 21:02:15 +02:00
|
|
|
#include <arch/smp/atomic.h>
|
|
|
|
#else
|
|
|
|
|
|
|
|
typedef struct { int counter; } atomic_t;
|
|
|
|
#define ATOMIC_INIT(i) { (i) }
|
|
|
|
|
2014-12-30 06:36:06 +01:00
|
|
|
/**
|
|
|
|
* @file include/smp/atomic.h
|
|
|
|
*/
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
/**
|
|
|
|
* atomic_read - read atomic variable
|
2014-12-30 06:36:06 +01:00
|
|
|
* @param v: pointer of type atomic_t
|
2010-04-27 08:56:47 +02:00
|
|
|
*
|
2014-12-30 06:36:06 +01:00
|
|
|
* Atomically reads the value of v. Note that the guaranteed
|
2003-04-22 21:02:15 +02:00
|
|
|
* useful range of an atomic_t is only 24 bits.
|
2010-04-27 08:56:47 +02:00
|
|
|
*/
|
2003-04-22 21:02:15 +02:00
|
|
|
#define atomic_read(v) ((v)->counter)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* atomic_set - set atomic variable
|
2014-12-30 06:36:06 +01:00
|
|
|
* @param v: pointer of type atomic_t
|
|
|
|
* @param i: required value
|
2010-04-27 08:56:47 +02:00
|
|
|
*
|
2014-12-30 06:36:06 +01:00
|
|
|
* Atomically sets the value of v to i. Note that the guaranteed
|
2003-04-22 21:02:15 +02:00
|
|
|
* useful range of an atomic_t is only 24 bits.
|
2010-04-27 08:56:47 +02:00
|
|
|
*/
|
2003-04-22 21:02:15 +02:00
|
|
|
#define atomic_set(v,i) (((v)->counter) = (i))
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* atomic_inc - increment atomic variable
|
2014-12-30 06:36:06 +01:00
|
|
|
* @param v: pointer of type atomic_t
|
2010-04-27 08:56:47 +02:00
|
|
|
*
|
2014-12-30 06:36:06 +01:00
|
|
|
* Atomically increments v by 1. Note that the guaranteed
|
2003-04-22 21:02:15 +02:00
|
|
|
* useful range of an atomic_t is only 24 bits.
|
2010-04-27 08:56:47 +02:00
|
|
|
*/
|
2003-04-22 21:02:15 +02:00
|
|
|
#define atomic_inc(v) (((v)->counter)++)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* atomic_dec - decrement atomic variable
|
2014-12-30 06:36:06 +01:00
|
|
|
* @param v: pointer of type atomic_t
|
2010-04-27 08:56:47 +02:00
|
|
|
*
|
2014-12-30 06:36:06 +01:00
|
|
|
* Atomically decrements v by 1. Note that the guaranteed
|
2003-04-22 21:02:15 +02:00
|
|
|
* useful range of an atomic_t is only 24 bits.
|
2010-04-27 08:56:47 +02:00
|
|
|
*/
|
2003-04-22 21:02:15 +02:00
|
|
|
#define atomic_dec(v) (((v)->counter)--)
|
|
|
|
|
|
|
|
|
2003-07-21 22:13:45 +02:00
|
|
|
#endif /* CONFIG_SMP */
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
#endif /* SMP_ATOMIC_H */
|