aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1995-05-11 07:24:35 +0000
committerBruce Evans <bde@FreeBSD.org>1995-05-11 07:24:35 +0000
commit0ee893eb3268f88a59e5cdb85d9395fd8d845fbb (patch)
tree24af9852d5a39bfeb996cd7f588e0bd786d35375 /sys
parent336d17595a2b630756f0690f57edc94842046f71 (diff)
downloadsrc-0ee893eb3268f88a59e5cdb85d9395fd8d845fbb.tar.gz
src-0ee893eb3268f88a59e5cdb85d9395fd8d845fbb.zip
Add loadandclear(). It atomically loads a value from memory, clears the
value in memory and returns the original value.
Notes
Notes: svn path=/head/; revision=8446
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/include/cpufunc.h13
-rw-r--r--sys/i386/include/cpufunc.h13
2 files changed, 24 insertions, 2 deletions
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index 5ea6be2f7bbe..3e60a08e10d5 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cpufunc.h,v 1.33 1995/02/16 13:21:47 bde Exp $
+ * $Id: cpufunc.h,v 1.34 1995/03/03 22:14:42 davidg Exp $
*/
/*
@@ -189,6 +189,16 @@ inw(u_int port)
return (data);
}
+static __inline unsigned
+loadandclear(u_int *addr)
+{
+ u_int result;
+
+ __asm __volatile("xorl %0,%0; xchgl %1,%0"
+ : "=r" (result) : "m" (*addr));
+ return (result);
+}
+
static __inline void
outbv(u_int port, u_char data)
{
@@ -319,6 +329,7 @@ void insb __P((u_int port, void *addr, size_t cnt));
void insl __P((u_int port, void *addr, size_t cnt));
void insw __P((u_int port, void *addr, size_t cnt));
u_short inw __P((u_int port));
+u_int loadandclear __P((u_int *addr));
void outb __P((u_int port, u_char data));
void outl __P((u_int port, u_long data));
void outsb __P((u_int port, void *addr, size_t cnt));
diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h
index 5ea6be2f7bbe..3e60a08e10d5 100644
--- a/sys/i386/include/cpufunc.h
+++ b/sys/i386/include/cpufunc.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cpufunc.h,v 1.33 1995/02/16 13:21:47 bde Exp $
+ * $Id: cpufunc.h,v 1.34 1995/03/03 22:14:42 davidg Exp $
*/
/*
@@ -189,6 +189,16 @@ inw(u_int port)
return (data);
}
+static __inline unsigned
+loadandclear(u_int *addr)
+{
+ u_int result;
+
+ __asm __volatile("xorl %0,%0; xchgl %1,%0"
+ : "=r" (result) : "m" (*addr));
+ return (result);
+}
+
static __inline void
outbv(u_int port, u_char data)
{
@@ -319,6 +329,7 @@ void insb __P((u_int port, void *addr, size_t cnt));
void insl __P((u_int port, void *addr, size_t cnt));
void insw __P((u_int port, void *addr, size_t cnt));
u_short inw __P((u_int port));
+u_int loadandclear __P((u_int *addr));
void outb __P((u_int port, u_char data));
void outl __P((u_int port, u_long data));
void outsb __P((u_int port, void *addr, size_t cnt));