diff options
| author | Chris Metcalf <cmetcalf@tilera.com> | 2010-11-24 13:30:28 -0500 |
|---|---|---|
| committer | Chris Metcalf <cmetcalf@tilera.com> | 2010-11-24 13:30:28 -0500 |
| commit | b03a6c4c7d8ebd8118d668eafdb85f5f76b5437f (patch) | |
| tree | f6ca7059e9c1bc1aac9a6741316f8e07ba349f7f /include/linux/atomic.h | |
| parent | 24f3f6b5eff92608a62449e33bfac0eed1447d02 (diff) | |
| parent | 3561d43fd289f590fdae672e5eb831b8d5cf0bf6 (diff) | |
| download | cachepc-linux-b03a6c4c7d8ebd8118d668eafdb85f5f76b5437f.tar.gz cachepc-linux-b03a6c4c7d8ebd8118d668eafdb85f5f76b5437f.zip | |
Merge branch 'master' into for-linus
Diffstat (limited to 'include/linux/atomic.h')
| -rw-r--r-- | include/linux/atomic.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/atomic.h b/include/linux/atomic.h new file mode 100644 index 000000000000..96c038e43d66 --- /dev/null +++ b/include/linux/atomic.h @@ -0,0 +1,37 @@ +#ifndef _LINUX_ATOMIC_H +#define _LINUX_ATOMIC_H +#include <asm/atomic.h> + +/** + * atomic_inc_not_zero_hint - increment if not null + * @v: pointer of type atomic_t + * @hint: probable value of the atomic before the increment + * + * This version of atomic_inc_not_zero() gives a hint of probable + * value of the atomic. This helps processor to not read the memory + * before doing the atomic read/modify/write cycle, lowering + * number of bus transactions on some arches. + * + * Returns: 0 if increment was not done, 1 otherwise. + */ +#ifndef atomic_inc_not_zero_hint +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint) +{ + int val, c = hint; + + /* sanity test, should be removed by compiler if hint is a constant */ + if (!hint) + return atomic_inc_not_zero(v); + + do { + val = atomic_cmpxchg(v, c, c + 1); + if (val == c) + return 1; + c = val; + } while (c); + + return 0; +} +#endif + +#endif /* _LINUX_ATOMIC_H */ |
