diff options
author | David Leonard <d@cvs.openbsd.org> | 1998-11-20 11:15:39 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 1998-11-20 11:15:39 +0000 |
commit | 394c7a9821726b84f284c0c4385b1a9198afa0b0 (patch) | |
tree | e3fcaf31862eb53986f206217f7986fe433c6ce7 /lib/libc_r/arch/m68k | |
parent | d2d530d679e5709dfdaa5ea40bea4a4d25694930 (diff) |
Move atomic_lock code from asm to C with inline asm;
Add m68k, mips and sparc. (needs more careful checking)
Add 'slow_atomic_lock' for crippled archs.
Diffstat (limited to 'lib/libc_r/arch/m68k')
-rw-r--r-- | lib/libc_r/arch/m68k/_atomic_lock.c | 27 | ||||
-rw-r--r-- | lib/libc_r/arch/m68k/uthread_machdep.h | 38 |
2 files changed, 65 insertions, 0 deletions
diff --git a/lib/libc_r/arch/m68k/_atomic_lock.c b/lib/libc_r/arch/m68k/_atomic_lock.c new file mode 100644 index 00000000000..be874ad2892 --- /dev/null +++ b/lib/libc_r/arch/m68k/_atomic_lock.c @@ -0,0 +1,27 @@ +/* $OpenBSD: _atomic_lock.c,v 1.1 1998/11/20 11:15:36 d Exp $ */ +/* + * Atomic lock for m68k + */ +#include "spinlock.h" + +register_t +_atomic_lock(volatile register_t *lock) +{ + register_t old; + + /* + * The Compare And Swap instruction (mc68020 and above) + * compares its first operand with the memory addressed by + * the third. If they are the same value, the second operand + * is stored at the address. Otherwise the 1st operand (register) + * is loaded with the contents of the 3rd operand. + * + * old = 0; + * CAS(old, 1, *lock); + * return old; + */ + old = 0; + __asm__("casl %0, %2, %1" : "=d"(old), "=m"(*lock) + : "d"(1), "0"(old)); + return old; +} diff --git a/lib/libc_r/arch/m68k/uthread_machdep.h b/lib/libc_r/arch/m68k/uthread_machdep.h new file mode 100644 index 00000000000..3df12262e28 --- /dev/null +++ b/lib/libc_r/arch/m68k/uthread_machdep.h @@ -0,0 +1,38 @@ +/* + * OpenBSD/m68k machine-dependent thread macros + * + * $OpenBSD: uthread_machdep.h,v 1.1 1998/11/20 11:15:36 d Exp $ + */ + +/* save the floating point state of a thread */ +#define _thread_machdep_save_float_state(thr) \ + { \ + /* fsave privileged instr */ \ + } + +/* restore the floating point state of a thread */ +#define _thread_machdep_restore_float_state(thr) \ + { \ + /* frestore privileged instr */ \ + } + +/* initialise the jmpbuf stack frame so it continues from entry */ + +#define _thread_machdep_thread_create(thr, entry, pattr) \ + { \ + /* entry */ \ + (thr)->saved_jmp_buf[5] = (long) entry; \ + /* stack */ \ + (thr)->saved_jmp_buf[2] = (long) (thr)->stack \ + + (pattr)->stacksize_attr \ + - sizeof(double); \ + } + +#define _thread_machdep_longjmp(a,v) _longjmp(a,v) +#define _thread_machdep_setjmp(a) _setjmp(a) + +struct _machdep_struct { + /* char saved_fp[108]; */ + int dummy; +}; + |