-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 8982 b: refs/heads/master c: fea2efe h: refs/heads/master v: v3
- Loading branch information
Russell King
authored and
Russell King
committed
Sep 15, 2005
1 parent
56bc44e
commit 5cd2502
Showing
60 changed files
with
614 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: bc9a5154a24d16d41cc79dbf1442de34454bc7db | ||
refs/heads/master: fea2efe3bba15f0aa8f840fbe052699808187cb6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* x86 version of "atomic_dec_and_lock()" using | ||
* the atomic "cmpxchg" instruction. | ||
* | ||
* (For CPU's lacking cmpxchg, we use the slow | ||
* generic version, and this one never even gets | ||
* compiled). | ||
*/ | ||
|
||
#include <linux/spinlock.h> | ||
#include <linux/module.h> | ||
#include <asm/atomic.h> | ||
|
||
int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) | ||
{ | ||
int counter; | ||
int newcount; | ||
|
||
repeat: | ||
counter = atomic_read(atomic); | ||
newcount = counter-1; | ||
|
||
if (!newcount) | ||
goto slow_path; | ||
|
||
asm volatile("lock; cmpxchgl %1,%2" | ||
:"=a" (newcount) | ||
:"r" (newcount), "m" (atomic->counter), "0" (counter)); | ||
|
||
/* If the above failed, "eax" will have changed */ | ||
if (newcount != counter) | ||
goto repeat; | ||
return 0; | ||
|
||
slow_path: | ||
spin_lock(lock); | ||
if (atomic_dec_and_test(atomic)) | ||
return 1; | ||
spin_unlock(lock); | ||
return 0; | ||
} | ||
EXPORT_SYMBOL(_atomic_dec_and_lock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2003 Jerome Marchand, Bull S.A. | ||
* Cleaned up by David Mosberger-Tang <davidm@hpl.hp.com> | ||
* | ||
* This file is released under the GPLv2, or at your option any later version. | ||
* | ||
* ia64 version of "atomic_dec_and_lock()" using the atomic "cmpxchg" instruction. This | ||
* code is an adaptation of the x86 version of "atomic_dec_and_lock()". | ||
*/ | ||
|
||
#include <linux/compiler.h> | ||
#include <linux/module.h> | ||
#include <linux/spinlock.h> | ||
#include <asm/atomic.h> | ||
|
||
/* | ||
* Decrement REFCOUNT and if the count reaches zero, acquire the spinlock. Both of these | ||
* operations have to be done atomically, so that the count doesn't drop to zero without | ||
* acquiring the spinlock first. | ||
*/ | ||
int | ||
_atomic_dec_and_lock (atomic_t *refcount, spinlock_t *lock) | ||
{ | ||
int old, new; | ||
|
||
do { | ||
old = atomic_read(refcount); | ||
new = old - 1; | ||
|
||
if (unlikely (old == 1)) { | ||
/* oops, we may be decrementing to zero, do it the slow way... */ | ||
spin_lock(lock); | ||
if (atomic_dec_and_test(refcount)) | ||
return 1; | ||
spin_unlock(lock); | ||
return 0; | ||
} | ||
} while (cmpxchg(&refcount->counter, old, new) != old); | ||
return 0; | ||
} | ||
|
||
EXPORT_SYMBOL(_atomic_dec_and_lock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* MIPS version of atomic_dec_and_lock() using cmpxchg | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version | ||
* 2 of the License, or (at your option) any later version. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/spinlock.h> | ||
#include <asm/atomic.h> | ||
#include <asm/system.h> | ||
|
||
/* | ||
* This is an implementation of the notion of "decrement a | ||
* reference count, and return locked if it decremented to zero". | ||
* | ||
* This implementation can be used on any architecture that | ||
* has a cmpxchg, and where atomic->value is an int holding | ||
* the value of the atomic (i.e. the high bits aren't used | ||
* for a lock or anything like that). | ||
*/ | ||
int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) | ||
{ | ||
int counter; | ||
int newcount; | ||
|
||
for (;;) { | ||
counter = atomic_read(atomic); | ||
newcount = counter - 1; | ||
if (!newcount) | ||
break; /* do it the slow way */ | ||
|
||
newcount = cmpxchg(&atomic->counter, counter, newcount); | ||
if (newcount == counter) | ||
return 0; | ||
} | ||
|
||
spin_lock(lock); | ||
if (atomic_dec_and_test(atomic)) | ||
return 1; | ||
spin_unlock(lock); | ||
return 0; | ||
} | ||
|
||
EXPORT_SYMBOL(_atomic_dec_and_lock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <linux/module.h> | ||
#include <linux/spinlock.h> | ||
#include <asm/atomic.h> | ||
#include <asm/system.h> | ||
|
||
/* | ||
* This is an implementation of the notion of "decrement a | ||
* reference count, and return locked if it decremented to zero". | ||
* | ||
* This implementation can be used on any architecture that | ||
* has a cmpxchg, and where atomic->value is an int holding | ||
* the value of the atomic (i.e. the high bits aren't used | ||
* for a lock or anything like that). | ||
*/ | ||
int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) | ||
{ | ||
int counter; | ||
int newcount; | ||
|
||
for (;;) { | ||
counter = atomic_read(atomic); | ||
newcount = counter - 1; | ||
if (!newcount) | ||
break; /* do it the slow way */ | ||
|
||
newcount = cmpxchg(&atomic->counter, counter, newcount); | ||
if (newcount == counter) | ||
return 0; | ||
} | ||
|
||
spin_lock(lock); | ||
if (atomic_dec_and_test(atomic)) | ||
return 1; | ||
spin_unlock(lock); | ||
return 0; | ||
} | ||
|
||
EXPORT_SYMBOL(_atomic_dec_and_lock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* ppc64 version of atomic_dec_and_lock() using cmpxchg | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version | ||
* 2 of the License, or (at your option) any later version. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/spinlock.h> | ||
#include <asm/atomic.h> | ||
#include <asm/system.h> | ||
|
||
/* | ||
* This is an implementation of the notion of "decrement a | ||
* reference count, and return locked if it decremented to zero". | ||
* | ||
* This implementation can be used on any architecture that | ||
* has a cmpxchg, and where atomic->value is an int holding | ||
* the value of the atomic (i.e. the high bits aren't used | ||
* for a lock or anything like that). | ||
*/ | ||
int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) | ||
{ | ||
int counter; | ||
int newcount; | ||
|
||
for (;;) { | ||
counter = atomic_read(atomic); | ||
newcount = counter - 1; | ||
if (!newcount) | ||
break; /* do it the slow way */ | ||
|
||
newcount = cmpxchg(&atomic->counter, counter, newcount); | ||
if (newcount == counter) | ||
return 0; | ||
} | ||
|
||
spin_lock(lock); | ||
if (atomic_dec_and_test(atomic)) | ||
return 1; | ||
spin_unlock(lock); | ||
return 0; | ||
} | ||
|
||
EXPORT_SYMBOL(_atomic_dec_and_lock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.