Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 20963
b: refs/heads/master
c: 7b61fcd
h: refs/heads/master
i:
  20961: 3931e57
  20959: 5017ca3
v: v3
  • Loading branch information
Roman Zippel authored and Linus Torvalds committed Mar 10, 2006
1 parent ea9b5b0 commit 17dde04
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b707dbe6c52e143a9afea06aa8f84103135ca873
refs/heads/master: 7b61fcda8a640bb87be23f9f09c1f24357b5c6e1
35 changes: 32 additions & 3 deletions trunk/include/asm-m68k/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static inline int atomic_inc_and_test(atomic_t *v)
}

#ifdef CONFIG_RMW_INSNS

static inline int atomic_add_return(int i, atomic_t *v)
{
int t, tmp;
Expand Down Expand Up @@ -82,7 +83,12 @@ static inline int atomic_sub_return(int i, atomic_t *v)
: "g" (i), "2" (atomic_read(v)));
return t;
}

#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
#define atomic_xchg(v, new) (xchg(&((v)->counter), new))

#else /* !CONFIG_RMW_INSNS */

static inline int atomic_add_return(int i, atomic_t * v)
{
unsigned long flags;
Expand Down Expand Up @@ -110,6 +116,32 @@ static inline int atomic_sub_return(int i, atomic_t * v)

return t;
}

static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
{
unsigned long flags;
int prev;

local_irq_save(flags);
prev = atomic_read(v);
if (prev == old)
atomic_set(v, new);
local_irq_restore(flags);
return prev;
}

static inline int atomic_xchg(atomic_t *v, int new)
{
unsigned long flags;
int prev;

local_irq_save(flags);
prev = atomic_read(v);
atomic_set(v, new);
local_irq_restore(flags);
return prev;
}

#endif /* !CONFIG_RMW_INSNS */

#define atomic_dec_return(v) atomic_sub_return(1, (v))
Expand Down Expand Up @@ -139,9 +171,6 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
__asm__ __volatile__("orl %1,%0" : "+m" (*v) : "id" (mask));
}

#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
#define atomic_xchg(v, new) (xchg(&((v)->counter), new))

#define atomic_add_unless(v, a, u) \
({ \
int c, old; \
Expand Down

0 comments on commit 17dde04

Please sign in to comment.