Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 67215
b: refs/heads/master
c: 9f0cbea
h: refs/heads/master
i:
  67213: 14e2b4b
  67211: cdf03fb
  67207: 107a078
  67199: 3577b2f
v: v3
  • Loading branch information
Segher Boessenkool authored and Paul Mackerras committed Aug 17, 2007
1 parent 74b61c5 commit 826ed89
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 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: c6d4267eced79775399f256fbb4adb671e9b597e
refs/heads/master: 9f0cbea0d8cc47801b853d3c61d0e17475b0cc89
34 changes: 28 additions & 6 deletions trunk/include/asm-powerpc/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* PowerPC atomic operations
*/

typedef struct { volatile int counter; } atomic_t;
typedef struct { int counter; } atomic_t;

#ifdef __KERNEL__
#include <linux/compiler.h>
Expand All @@ -15,8 +15,19 @@ typedef struct { volatile int counter; } atomic_t;

#define ATOMIC_INIT(i) { (i) }

#define atomic_read(v) ((v)->counter)
#define atomic_set(v,i) (((v)->counter) = (i))
static __inline__ int atomic_read(const atomic_t *v)
{
int t;

__asm__ __volatile__("lwz%U1%X1 %0,%1" : "=r"(t) : "m"(v->counter));

return t;
}

static __inline__ void atomic_set(atomic_t *v, int i)
{
__asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
}

static __inline__ void atomic_add(int a, atomic_t *v)
{
Expand Down Expand Up @@ -240,12 +251,23 @@ static __inline__ int atomic_dec_if_positive(atomic_t *v)

#ifdef __powerpc64__

typedef struct { volatile long counter; } atomic64_t;
typedef struct { long counter; } atomic64_t;

#define ATOMIC64_INIT(i) { (i) }

#define atomic64_read(v) ((v)->counter)
#define atomic64_set(v,i) (((v)->counter) = (i))
static __inline__ long atomic64_read(const atomic64_t *v)
{
long t;

__asm__ __volatile__("ld%U1%X1 %0,%1" : "=r"(t) : "m"(v->counter));

return t;
}

static __inline__ void atomic64_set(atomic64_t *v, long i)
{
__asm__ __volatile__("std%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
}

static __inline__ void atomic64_add(long a, atomic64_t *v)
{
Expand Down

0 comments on commit 826ed89

Please sign in to comment.