diff options
author | 2005-12-14 17:21:01 +0000 | |
---|---|---|
committer | 2005-12-14 17:21:01 +0000 | |
commit | a7b55ee28b419cd18a646f33b308bdd2acbef1e9 (patch) | |
tree | 9075ac045f3e59a6a5df0b6247dd9c8480a25a50 /lib/librthread | |
parent | add three mirrors, catching up w/ ftp.html r1.336 (diff) | |
download | wireguard-openbsd-a7b55ee28b419cd18a646f33b308bdd2acbef1e9.tar.xz wireguard-openbsd-a7b55ee28b419cd18a646f33b308bdd2acbef1e9.zip |
Add locking primitive for hppa. ok kettenis@
Diffstat (limited to 'lib/librthread')
-rw-r--r-- | lib/librthread/arch/hppa/_atomic_lock.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/librthread/arch/hppa/_atomic_lock.c b/lib/librthread/arch/hppa/_atomic_lock.c new file mode 100644 index 00000000000..98805c57daf --- /dev/null +++ b/lib/librthread/arch/hppa/_atomic_lock.c @@ -0,0 +1,30 @@ +/* $OpenBSD: _atomic_lock.c,v 1.1 2005/12/14 17:21:01 marco Exp $ */ +/* + * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <machine/spinlock.h> + +int +_atomic_lock(register volatile _spinlock_lock_t *lock) +{ + _spinlock_lock_t old; + + asm volatile ("ldcw %1,%0" + : "=r" (old), "=m" (*lock) + : "m" (*lock)); + + return (old == _SPINLOCK_UNLOCKED); +} |