diff options
Diffstat (limited to 'lib/libc_r/arch')
-rw-r--r-- | lib/libc_r/arch/i386/uthread_machdep.h | 5 | ||||
-rw-r--r-- | lib/libc_r/arch/mips/_atomic_lock.S | 35 | ||||
-rw-r--r-- | lib/libc_r/arch/mips/uthread_machdep.h | 36 |
3 files changed, 75 insertions, 1 deletions
diff --git a/lib/libc_r/arch/i386/uthread_machdep.h b/lib/libc_r/arch/i386/uthread_machdep.h index 2a296d3ae25..088ff200509 100644 --- a/lib/libc_r/arch/i386/uthread_machdep.h +++ b/lib/libc_r/arch/i386/uthread_machdep.h @@ -1,7 +1,7 @@ /* * OpenBSD/i386 machine-dependent thread macros * - * $OpenBSD: uthread_machdep.h,v 1.1 1998/08/28 01:54:58 d Exp $ + * $OpenBSD: uthread_machdep.h,v 1.2 1998/11/09 03:13:13 d Exp $ */ /* save the floating point state of a thread */ @@ -29,6 +29,9 @@ - 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]; }; diff --git a/lib/libc_r/arch/mips/_atomic_lock.S b/lib/libc_r/arch/mips/_atomic_lock.S new file mode 100644 index 00000000000..169852b9c75 --- /dev/null +++ b/lib/libc_r/arch/mips/_atomic_lock.S @@ -0,0 +1,35 @@ +/* + * $OpenBSD: _atomic_lock.S,v 1.1 1998/11/09 03:13:14 d Exp $ + */ + +#include "SYS.h" + +/* + * Atomicly lock a location with an identifier provided the location + * is not currently locked. + * + * long _atomic_lock(long *a0); + * v0 will contain the return value (zero if lock obtained). + */ + +/* + * XXXXXX THIS IS LOCK FUNCTION IS TOTALLY BOGUS XXXXXXXXX + * pefo@ says that for R4000 processors, there is a way to do this + * atomically, but for R3000 you will need to context switch. + * Specifically he says the 'll' and 'sc' instructions can be used for mips2. + */ +LEAF(_atomic_lock) + .set noreorder + .set nomacro + + /* Get the existing lock value and lock memory: */ + ori t0,zero,1 + lw v0,0(a0) + sw t0,0(a0) + j ra + nop + + .set macro + .set reorder +END(_atomic_lock) + diff --git a/lib/libc_r/arch/mips/uthread_machdep.h b/lib/libc_r/arch/mips/uthread_machdep.h new file mode 100644 index 00000000000..605b900f8a7 --- /dev/null +++ b/lib/libc_r/arch/mips/uthread_machdep.h @@ -0,0 +1,36 @@ +/* + * OpenBSD/mips machine-dependent thread macros + * + * $OpenBSD: uthread_machdep.h,v 1.1 1998/11/09 03:13:14 d Exp $ + */ + +#include <machine/regnum.h> +#include <machine/signal.h> + +/* floating point state is saved by setjmp/longjmp */ + +#define _thread_machdep_save_float_state(thr) /* no need */ +#define _thread_machdep_restore_float_state(thr) /* no need */ + +/* initialise the jmpbuf stack frame so it continues from entry */ +#define _thread_machdep_thread_create(thr, entry, pattr) \ + { \ + struct sigcontext *j = &(thr)->saved_jmp_buf; \ + \ + /* initialise to sane values */ \ + _thread_machdep_setjmp(j); \ + /* entry */ \ + j->sc_regs[RA] = j->sc_pc; /* for gdb */ \ + j->sc_pc = (int)entry; \ + /* stack */ \ + j->sc_regs[SP] = (int) (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 { + /* nothing needed */ +}; |