Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24891
b: refs/heads/master
c: 2cf8d82
h: refs/heads/master
i:
  24889: c1fe4c3
  24887: 8195b20
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Mar 31, 2006
1 parent b18bc8a commit 323c10c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 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: 09ce3512dcad0ad1d07eee0dc5ebb6d037c39c16
refs/heads/master: 2cf8d82d63807c2c68adf20bb28bf502496186dd
13 changes: 10 additions & 3 deletions trunk/include/asm-generic/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
#include <asm/atomic.h>
#include <asm/types.h>

/* An unsigned long type for operations which are atomic for a single
* CPU. Usually used in combination with per-cpu variables. */
/*
* A signed long type for operations which are atomic for a single CPU.
* Usually used in combination with per-cpu variables.
*
* This is the default implementation, which uses atomic_long_t. Which is
* rather pointless. The whole point behind local_t is that some processors
* can perform atomic adds and subtracts in a manner which is atomic wrt IRQs
* running on this CPU. local_t allows exploitation of such capabilities.
*/

/* Implement in terms of atomics. */

Expand All @@ -20,7 +27,7 @@ typedef struct

#define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }

#define local_read(l) ((unsigned long)atomic_long_read(&(l)->a))
#define local_read(l) atomic_long_read(&(l)->a)
#define local_set(l,i) atomic_long_set((&(l)->a),(i))
#define local_inc(l) atomic_long_inc(&(l)->a)
#define local_dec(l) atomic_long_dec(&(l)->a)
Expand Down
6 changes: 3 additions & 3 deletions trunk/include/asm-i386/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

typedef struct
{
volatile unsigned long counter;
volatile long counter;
} local_t;

#define LOCAL_INIT(i) { (i) }
Expand All @@ -29,15 +29,15 @@ static __inline__ void local_dec(local_t *v)
:"m" (v->counter));
}

static __inline__ void local_add(unsigned long i, local_t *v)
static __inline__ void local_add(long i, local_t *v)
{
__asm__ __volatile__(
"addl %1,%0"
:"=m" (v->counter)
:"ir" (i), "m" (v->counter));
}

static __inline__ void local_sub(unsigned long i, local_t *v)
static __inline__ void local_sub(long i, local_t *v)
{
__asm__ __volatile__(
"subl %1,%0"
Expand Down
10 changes: 5 additions & 5 deletions trunk/include/asm-x86_64/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@

typedef struct
{
volatile unsigned long counter;
volatile long counter;
} local_t;

#define LOCAL_INIT(i) { (i) }

#define local_read(v) ((v)->counter)
#define local_set(v,i) (((v)->counter) = (i))

static __inline__ void local_inc(local_t *v)
static inline void local_inc(local_t *v)
{
__asm__ __volatile__(
"incq %0"
:"=m" (v->counter)
:"m" (v->counter));
}

static __inline__ void local_dec(local_t *v)
static inline void local_dec(local_t *v)
{
__asm__ __volatile__(
"decq %0"
:"=m" (v->counter)
:"m" (v->counter));
}

static __inline__ void local_add(unsigned int i, local_t *v)
static inline void local_add(long i, local_t *v)
{
__asm__ __volatile__(
"addq %1,%0"
:"=m" (v->counter)
:"ir" (i), "m" (v->counter));
}

static __inline__ void local_sub(unsigned int i, local_t *v)
static inline void local_sub(long i, local_t *v)
{
__asm__ __volatile__(
"subq %1,%0"
Expand Down

0 comments on commit 323c10c

Please sign in to comment.