cregit-Linux how code gets into the kernel

Release 4.7 arch/sh/include/asm/atomic.h

#ifndef __ASM_SH_ATOMIC_H

#define __ASM_SH_ATOMIC_H

/*
 * Atomic operations that C can't guarantee us.  Useful for
 * resource counting etc..
 *
 */

#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/cmpxchg.h>
#include <asm/barrier.h>


#define ATOMIC_INIT(i)	{ (i) }


#define atomic_read(v)		READ_ONCE((v)->counter)

#define atomic_set(v,i)		WRITE_ONCE((v)->counter, (i))

#if defined(CONFIG_GUSA_RB)
#include <asm/atomic-grb.h>
#elif defined(CONFIG_CPU_SH4A)
#include <asm/atomic-llsc.h>
#else
#include <asm/atomic-irq.h>
#endif


#define atomic_add_negative(a, v)	(atomic_add_return((a), (v)) < 0)

#define atomic_dec_return(v)		atomic_sub_return(1, (v))

#define atomic_inc_return(v)		atomic_add_return(1, (v))

#define atomic_inc_and_test(v)		(atomic_inc_return(v) == 0)

#define atomic_sub_and_test(i,v)	(atomic_sub_return((i), (v)) == 0)

#define atomic_dec_and_test(v)		(atomic_sub_return(1, (v)) == 0)


#define atomic_inc(v)			atomic_add(1, (v))

#define atomic_dec(v)			atomic_sub(1, (v))


#define atomic_xchg(v, new)		(xchg(&((v)->counter), new))

#define atomic_cmpxchg(v, o, n)		(cmpxchg(&((v)->counter), (o), (n)))

/**
 * __atomic_add_unless - add unless the number is a given value
 * @v: pointer of type atomic_t
 * @a: the amount to add to v...
 * @u: ...unless v is equal to u.
 *
 * Atomically adds @a to @v, so long as it was not @u.
 * Returns the old value of @v.
 */

static inline int __atomic_add_unless(atomic_t *v, int a, int u) { int c, old; c = atomic_read(v); for (;;) { if (unlikely(c == (u))) break; old = atomic_cmpxchg((v), c, c + (a)); if (likely(old == c)) break; c = old; } return c; }

Contributors

PersonTokensPropCommitsCommitProp
paul mundtpaul mundt4858.54%133.33%
nick pigginnick piggin3340.24%133.33%
arun sharmaarun sharma11.22%133.33%
Total82100.00%3100.00%

#endif /* __ASM_SH_ATOMIC_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
paul mundtpaul mundt7733.05%320.00%
pre-gitpre-git7030.04%16.67%
nick pigginnick piggin3916.74%213.33%
andrew mortonandrew morton166.87%213.33%
stuart menefystuart menefy146.01%16.67%
matthew wilcoxmatthew wilcox83.43%16.67%
peter zijlstrapeter zijlstra52.15%213.33%
arun sharmaarun sharma20.86%16.67%
david howellsdavid howells10.43%16.67%
nobuhiro iwamatsunobuhiro iwamatsu10.43%16.67%
Total233100.00%15100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}