diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2012-04-13 14:38:23 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2012-04-13 14:38:23 +0000 |
commit | 14d855a1753a83d71f13f91a7fa0bc82a5a3943f (patch) | |
tree | 7708173a92347328453716876fa499a9b2c07bd1 /lib/librthread/arch | |
parent | 3a132b7262cf2ec8659079c6bbefc0ed7228aaa3 (diff) |
Provide _atomic_lock() and __cerror() for hppa64. Makes hppa64 build again.
Diffstat (limited to 'lib/librthread/arch')
-rw-r--r-- | lib/librthread/arch/hppa64/_atomic_lock.c | 41 | ||||
-rw-r--r-- | lib/librthread/arch/hppa64/cerror.S | 33 |
2 files changed, 74 insertions, 0 deletions
diff --git a/lib/librthread/arch/hppa64/_atomic_lock.c b/lib/librthread/arch/hppa64/_atomic_lock.c new file mode 100644 index 00000000000..756af207428 --- /dev/null +++ b/lib/librthread/arch/hppa64/_atomic_lock.c @@ -0,0 +1,41 @@ +/* $OpenBSD: _atomic_lock.c,v 1.1 2012/04/13 14:38:22 jsing 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 <spinlock.h> +#ifdef DIAGNOSTIC +#include <stdio.h> +#include <stdlib.h> +#endif + +int +_atomic_lock(volatile _spinlock_lock_t *lock) +{ + volatile _spinlock_lock_t old; + +#ifdef DIAGNOSTIC + if ((unsigned long)lock & 0xf) { + printf("lock not 16 byte aligned\n"); + abort(); + } +#endif + + asm volatile ("ldcw 0(%2), %0" + : "=&r" (old), "+m" (lock) + : "r" (lock)); + + return (old == _SPINLOCK_LOCKED); +} diff --git a/lib/librthread/arch/hppa64/cerror.S b/lib/librthread/arch/hppa64/cerror.S new file mode 100644 index 00000000000..6beb25b8627 --- /dev/null +++ b/lib/librthread/arch/hppa64/cerror.S @@ -0,0 +1,33 @@ +/* $OpenBSD: cerror.S,v 1.1 2012/04/13 14:38:22 jsing Exp $ */ + +/* + * Copyright (c) 2011 Mark Kettenis + * + * 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 "SYS.h" + +#define ERRNOPTR_OFFSET 16 + +ENTRY(__cerror,0) + mfctl %cr27, %r1 + ldw 4(%r1), %r1 + ldw ERRNOPTR_OFFSET(%r1), %r1 + stw %t1, 0(%r1) + ldi -1, %ret0 + bv %r0(%rp) + ldi -1, %ret1 +EXIT(__cerror) + + .end |