Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155220
b: refs/heads/master
c: a79f0da
h: refs/heads/master
v: v3
  • Loading branch information
Eric Dumazet authored and Ingo Molnar committed Jul 4, 2009
1 parent 3e47ef3 commit f238fcf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 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: ddf9a003d32f720805ac30bcc15755e9289073de
refs/heads/master: a79f0da80a508448434476b77f9d3d1a469eab67
22 changes: 22 additions & 0 deletions trunk/arch/x86/include/asm/atomic_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,28 @@ extern void atomic64_set(atomic64_t *ptr, u64 new_val);
*
* Atomically reads the value of @ptr and returns it.
*/
static inline u64 atomic64_read(atomic64_t *ptr)
{
u64 res;

/*
* Note, we inline this atomic64_t primitive because
* it only clobbers EAX/EDX and leaves the others
* untouched. We also (somewhat subtly) rely on the
* fact that cmpxchg8b returns the current 64-bit value
* of the memory location we are touching:
*/
asm volatile(
"mov %%ebx, %%eax\n\t"
"mov %%ecx, %%edx\n\t"
LOCK_PREFIX "cmpxchg8b %1\n"
: "=&A" (res)
: "m" (*ptr)
);

return res;
}

extern u64 atomic64_read(atomic64_t *ptr);

/**
Expand Down
23 changes: 1 addition & 22 deletions trunk/arch/x86/lib/atomic64_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,10 @@ void atomic64_set(atomic64_t *ptr, u64 new_val)
{
atomic64_xchg(ptr, new_val);
}
EXPORT_SYMBOL(atomic64_read);
EXPORT_SYMBOL(atomic64_set);

/**
* atomic64_read - read atomic64 variable
* @ptr: pointer to type atomic64_t
*
* Atomically reads the value of @ptr and returns it.
*/
u64 atomic64_read(atomic64_t *ptr)
{
u64 res;

asm volatile(
"mov %%ebx, %%eax\n\t"
"mov %%ecx, %%edx\n\t"
LOCK_PREFIX "cmpxchg8b %1\n"
: "+A" (res)
: "m" (*ptr)
);

return res;
}
EXPORT_SYMBOL(atomic64_read);

/**
* atomic64_add_return - add and return
* @delta: integer value to add
* @ptr: pointer to type atomic64_t
Expand Down

0 comments on commit f238fcf

Please sign in to comment.