diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-10-04 05:55:36 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-10-04 05:55:36 +0000 |
commit | 8e95e2f842b2fdd99c416cc00a8d321656fea5af (patch) | |
tree | ae270251a663e179dd260f976e6b3ecb477678cf /lib/libc_r/arch | |
parent | 367c0082943cc6fa224d021a045222f13f86cfe4 (diff) |
switch to _machdep_switch() instead of setjmp/longjmp. For some reason this fixes sparc threads.
Diffstat (limited to 'lib/libc_r/arch')
-rw-r--r-- | lib/libc_r/arch/alpha/uthread_machdep.h | 70 | ||||
-rw-r--r-- | lib/libc_r/arch/hppa/uthread_machdep.h | 41 | ||||
-rw-r--r-- | lib/libc_r/arch/i386/uthread_machdep.h | 89 | ||||
-rw-r--r-- | lib/libc_r/arch/m68k/uthread_machdep.h | 42 | ||||
-rw-r--r-- | lib/libc_r/arch/m88k/uthread_machdep.h | 41 | ||||
-rw-r--r-- | lib/libc_r/arch/mips/uthread_machdep.h | 40 | ||||
-rw-r--r-- | lib/libc_r/arch/powerpc/uthread_machdep.h | 46 | ||||
-rw-r--r-- | lib/libc_r/arch/sparc/uthread_machdep.S | 35 | ||||
-rw-r--r-- | lib/libc_r/arch/sparc/uthread_machdep.h | 42 |
9 files changed, 28 insertions, 418 deletions
diff --git a/lib/libc_r/arch/alpha/uthread_machdep.h b/lib/libc_r/arch/alpha/uthread_machdep.h index 9a7c52da977..3c159c84b99 100644 --- a/lib/libc_r/arch/alpha/uthread_machdep.h +++ b/lib/libc_r/arch/alpha/uthread_machdep.h @@ -1,68 +1,6 @@ -/* - * OpenBSD/alpha machine-dependent thread macros - * - * $OpenBSD: uthread_machdep.h,v 1.5 1999/11/25 07:01:27 d Exp $ - */ +/* $OpenBSD: uthread_machdep.h,v 1.6 2000/10/04 05:55:33 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ -/* save the floating point state of a thread */ -#define _thread_machdep_save_float_state(thr) \ -do { \ - __asm__( \ - "stt $f8, ( 0 * 8) + %0\n\tstt $f9, ( 1 * 8) + %0\n\t" \ - "stt $f10, ( 2 * 8) + %0\n\tstt $f11, ( 3 * 8) + %0\n\t" \ - "stt $f12, ( 4 * 8) + %0\n\tstt $f13, ( 5 * 8) + %0\n\t" \ - "stt $f14, ( 6 * 8) + %0\n\tstt $f15, ( 7 * 8) + %0\n\t" \ - "stt $f16, ( 8 * 8) + %0\n\tstt $f17, ( 9 * 8) + %0\n\t" \ - "stt $f18, (10 * 8) + %0\n\tstt $f19, (11 * 8) + %0\n\t" \ - "stt $f20, (12 * 8) + %0\n\tstt $f21, (13 * 8) + %0\n\t" \ - "stt $f22, (14 * 8) + %0\n\tstt $f23, (15 * 8) + %0\n\t" \ - "stt $f24, (16 * 8) + %0\n\tstt $f25, (17 * 8) + %0\n\t" \ - "stt $f26, (18 * 8) + %0\n\tstt $f27, (19 * 8) + %0\n\t" \ - "stt $f28, (20 * 8) + %0\n\tstt $f29, (21 * 8) + %0\n\t" \ - "stt $f30, (22 * 8) + %0" \ - : : "o" ((thr)->_machdep.saved_fp) : "memory"); \ -} while(0) - -/* restore the floating point state of a thread */ -#define _thread_machdep_restore_float_state(thr) \ -do { \ - __asm__( \ - "ldt $f8, ( 0 * 8) + %0\n\tldt $f9, ( 1 * 8) + %0\n\t" \ - "ldt $f10, ( 2 * 8) + %0\n\tldt $f11, ( 3 * 8) + %0\n\t" \ - "ldt $f12, ( 4 * 8) + %0\n\tldt $f13, ( 5 * 8) + %0\n\t" \ - "ldt $f14, ( 6 * 8) + %0\n\tldt $f15, ( 7 * 8) + %0\n\t" \ - "ldt $f16, ( 8 * 8) + %0\n\tldt $f17, ( 9 * 8) + %0\n\t" \ - "ldt $f18, (10 * 8) + %0\n\tldt $f19, (11 * 8) + %0\n\t" \ - "ldt $f20, (12 * 8) + %0\n\tldt $f21, (13 * 8) + %0\n\t" \ - "ldt $f22, (14 * 8) + %0\n\tldt $f23, (15 * 8) + %0\n\t" \ - "ldt $f24, (16 * 8) + %0\n\tldt $f25, (17 * 8) + %0\n\t" \ - "ldt $f26, (18 * 8) + %0\n\tldt $f27, (19 * 8) + %0\n\t" \ - "ldt $f28, (20 * 8) + %0\n\tldt $f29, (21 * 8) + %0\n\t" \ - "ldt $f30, (22 * 8) + %0\n\t" \ - : : "o" (thr->_machdep.saved_fp) : \ - "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", \ - "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", \ - "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30"); \ -} while(0) - -/* initialise the jmpbuf stack frame so it continues from entry */ -#define _thread_machdep_thread_create(thr, entry, pattr) \ - { \ - /* entry */ \ - (thr)->saved_jmp_buf[2] = (long) entry; \ - (thr)->saved_jmp_buf[4 + R_RA] = 0; \ - (thr)->saved_jmp_buf[4 + R_T12] = (long) entry; \ - /* stack */ \ - (thr)->saved_jmp_buf[4 + R_SP] = (long) (thr)->stack->base \ - + (thr)->stack->size \ - - sizeof(double); \ - } - -#define _thread_machdep_longjmp(a,v) _longjmp(a,v) -#define _thread_machdep_setjmp(a) _setjmp(a) - -typedef jmp_buf _machdep_jmp_buf; - -struct _machdep_struct { - char saved_fp[23 * 8]; +struct _machdep_state { + int fp; }; diff --git a/lib/libc_r/arch/hppa/uthread_machdep.h b/lib/libc_r/arch/hppa/uthread_machdep.h index 0d80d718ded..a1d8eeb4913 100644 --- a/lib/libc_r/arch/hppa/uthread_machdep.h +++ b/lib/libc_r/arch/hppa/uthread_machdep.h @@ -1,40 +1 @@ -/* - * OpenBSD/hppa machine-dependent thread macros - * - * $OpenBSD: uthread_machdep.h,v 1.3 1999/11/25 07:01:27 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->base \ - + (thr)->stack->size \ - - sizeof(double); \ - } - -#define _thread_machdep_longjmp(a,v) _longjmp(a,v) -#define _thread_machdep_setjmp(a) _setjmp(a) - -typedef jmp_buf _machdep_jmp_buf; - -struct _machdep_struct { - /* char saved_fp[108]; */ - int dummy; -}; - +/* $OpenBSD: uthread_machdep.h,v 1.4 2000/10/04 05:55:33 d Exp $ */ diff --git a/lib/libc_r/arch/i386/uthread_machdep.h b/lib/libc_r/arch/i386/uthread_machdep.h index dab5c413932..22d48624d0d 100644 --- a/lib/libc_r/arch/i386/uthread_machdep.h +++ b/lib/libc_r/arch/i386/uthread_machdep.h @@ -1,89 +1,10 @@ -/* - * OpenBSD/i386 machine-dependent thread macros - * - * $OpenBSD: uthread_machdep.h,v 1.6 1999/11/25 07:01:28 d Exp $ - */ +/* $OpenBSD: uthread_machdep.h,v 1.7 2000/10/04 05:55:34 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ #include <machine/reg.h> -/* - * We need to extend jmp_buf to hold extended segment registers - * for WINE. - */ -typedef struct _machdep_jmp_buf { - union { - jmp_buf jb; - struct { - int eip; - int ebx; - int esp; - int ebp; - int esi; - int edi; - } jbs; - } u; -#define mjb_eip u.jbs.eip -#define mjb_ebx u.jbs.ebx -#define mjb_esp u.jbs.esp -#define mjb_ebp u.jbs.ebp -#define mjb_esi u.jbs.esi -#define mjb_edi u.jbs.edi - int mjb_ds; /* informational only - not restored */ - int mjb_es; /* informational only - not restored */ - int mjb_fs; - int mjb_gs; -} _machdep_jmp_buf; - -/* Extra machine-dependent information */ -struct _machdep_struct { - struct fpreg saved_fp; /* only saved with on signals */ +struct _machdep_state { + int esp; + struct fpreg fpreg; }; -/* Save the floating point state of a thread: */ -#define _thread_machdep_save_float_state(thr) \ - { \ - char *fdata = (char*)(&(thr)->_machdep.saved_fp); \ - __asm__("fsave %0"::"m" (*fdata)); \ - } - -/* Restore the floating point state of a thread: */ -#define _thread_machdep_restore_float_state(thr) \ - { \ - char *fdata = (char*)(&(thr)->_machdep.saved_fp); \ - __asm__("frstor %0"::"m" (*fdata)); \ - } - -/* Initialise the jmpbuf stack frame so it continues from entry: */ -#define _thread_machdep_thread_create(thr, entry, pattr) \ - { \ - /* entry */ \ - (thr)->saved_jmp_buf.mjb_eip = (long) entry; \ - /* stack */ \ - (thr)->saved_jmp_buf.mjb_esp = \ - (long) (thr)->stack->base + \ - (thr)->stack->size \ - - sizeof(double); \ - } - -static __inline int -_thread_machdep_setjmp_helper(a) - _machdep_jmp_buf *a; -{ - int v; - - __asm__("mov %%ds, %0\n" : "=m" (a->mjb_ds) ); - __asm__("mov %%es, %0\n" : "=m" (a->mjb_es) ); - __asm__("mov %%fs, %0\n" : "=m" (a->mjb_fs) ); - __asm__("mov %%gs, %0\n" : "=m" (a->mjb_gs) ); - v = _setjmp(a->u.jb); - if (v) { - __asm__("mov %0, %%gs\n" :: "m" (a->mjb_gs) ); - __asm__("mov %0, %%fs\n" :: "m" (a->mjb_fs) ); - /* __asm__("mov %0, %%es\n" :: "m" (a->mjb_es) ); */ - /* __asm__("mov %0, %%ds\n" :: "m" (a->mjb_ds) ); */ - } - return (v); -} - -#define _thread_machdep_longjmp(a,v) _longjmp((a).u.jb,v) -#define _thread_machdep_setjmp(a) _thread_machdep_setjmp_helper(&(a)) diff --git a/lib/libc_r/arch/m68k/uthread_machdep.h b/lib/libc_r/arch/m68k/uthread_machdep.h index 8bda374924d..d9bb9935ca6 100644 --- a/lib/libc_r/arch/m68k/uthread_machdep.h +++ b/lib/libc_r/arch/m68k/uthread_machdep.h @@ -1,40 +1,6 @@ -/* - * OpenBSD/m68k machine-dependent thread macros - * - * $OpenBSD: uthread_machdep.h,v 1.3 1999/11/25 07:01:28 d Exp $ - */ +/* $OpenBSD: uthread_machdep.h,v 1.4 2000/10/04 05:55:34 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ -/* 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->base \ - + (thr)->stack->size \ - - sizeof(double); \ - } - -#define _thread_machdep_longjmp(a,v) _longjmp(a,v) -#define _thread_machdep_setjmp(a) _setjmp(a) - -typedef jmp_buf _machdep_jmp_buf; - -struct _machdep_struct { - /* char saved_fp[108]; */ - int dummy; +struct _machdep_state { + int sp; }; - diff --git a/lib/libc_r/arch/m88k/uthread_machdep.h b/lib/libc_r/arch/m88k/uthread_machdep.h index 0fcad5cf0ae..586210e0deb 100644 --- a/lib/libc_r/arch/m88k/uthread_machdep.h +++ b/lib/libc_r/arch/m88k/uthread_machdep.h @@ -1,40 +1 @@ -/* - * OpenBSD/m88k machine-dependent thread macros - * - * $OpenBSD: uthread_machdep.h,v 1.2 1999/11/25 07:01:28 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->base \ - + (thr)->stack->size \ - - sizeof(double); \ - } - -#define _thread_machdep_longjmp(a,v) _longjmp(a,v) -#define _thread_machdep_setjmp(a) _setjmp(a) - -typedef jmp_buf _machdep_jmp_buf; - -struct _machdep_struct { - /* char saved_fp[108]; */ - int dummy; -}; - +/* $OpenBSD: uthread_machdep.h,v 1.3 2000/10/04 05:55:34 d Exp $ */ diff --git a/lib/libc_r/arch/mips/uthread_machdep.h b/lib/libc_r/arch/mips/uthread_machdep.h index 89fb399d629..113a83dc815 100644 --- a/lib/libc_r/arch/mips/uthread_machdep.h +++ b/lib/libc_r/arch/mips/uthread_machdep.h @@ -1,38 +1,6 @@ -/* - * OpenBSD/mips machine-dependent thread macros - * - * $OpenBSD: uthread_machdep.h,v 1.4 1999/11/25 07:01:28 d Exp $ - */ +/* $OpenBSD: uthread_machdep.h,v 1.5 2000/10/04 05:55:34 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ -#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->base \ - + (thr)->stack->size \ - - sizeof(double); \ - } - -#define _thread_machdep_longjmp(a,v) longjmp(a,v) -#define _thread_machdep_setjmp(a) setjmp(a) - -typedef jmp_buf _machdep_jmp_buf; - -struct _machdep_struct { - /* nothing needed */ +struct _machdep_state { + int frame; }; diff --git a/lib/libc_r/arch/powerpc/uthread_machdep.h b/lib/libc_r/arch/powerpc/uthread_machdep.h index 6041279d95e..54c864e71a4 100644 --- a/lib/libc_r/arch/powerpc/uthread_machdep.h +++ b/lib/libc_r/arch/powerpc/uthread_machdep.h @@ -1,45 +1,7 @@ -/* - * OpenBSD/powerpc machine-dependent thread macros - * - * $OpenBSD: uthread_machdep.h,v 1.4 1999/11/25 07:01:29 d Exp $ - */ +/* $OpenBSD: uthread_machdep.h,v 1.5 2000/10/04 05:55:35 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ -/* save the floating point state of a thread */ -#define _thread_machdep_save_float_state(thr) \ - { \ - /* rahnds to fill in */ \ - } - -/* restore the floating point state of a thread */ -#define _thread_machdep_restore_float_state(thr) \ - { \ - /* rahnds to fill in */ \ - } - -#define JMP_r1 (0x04/4) -#define JMP_lr (0x50/4) -/* initialise the jmpbuf stack frame so it continues from entry */ -#define _thread_machdep_thread_create(thr, entry, pattr) \ - { \ - (thr)->saved_jmp_buf[JMP_lr] = \ - (unsigned int) entry; \ - (thr)->saved_jmp_buf[JMP_r1] = \ - ((unsigned int) (thr)->stack->base \ - + (thr)->stack->size \ - - 0x4) & ~0xf; \ - { \ - unsigned int *pbacklink = \ - (thr)->saved_jmp_buf[JMP_r1]; \ - *pbacklink = 0; \ - } \ - } - -#define _thread_machdep_longjmp(a,v) longjmp(a,v) -#define _thread_machdep_setjmp(a) setjmp(a) - -typedef jmp_buf _machdep_jmp_buf; - -struct _machdep_struct { - char xxx; +struct _machdep_state { + int frame; }; diff --git a/lib/libc_r/arch/sparc/uthread_machdep.S b/lib/libc_r/arch/sparc/uthread_machdep.S deleted file mode 100644 index c24fff66c07..00000000000 --- a/lib/libc_r/arch/sparc/uthread_machdep.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $OpenBSD: uthread_machdep.S,v 1.1 2000/01/06 07:04:36 d Exp $ */ - -#include <machine/asm.h> -#include <machine/trap.h> - -ENTRY(_thread_machdep_create) - st %o2, [%o0] /* store the new stack pointer */ - sub %o1, 8, %o1 /* the return adress is o7 + 8 ! */ - st %o1, [%o0+4] /* store the new pc */ - - retl - nop - -ENTRY(_thread_machdep_setjmp) - t ST_FLUSHWIN /* flush register windows */ - st %sp, [%o0] /* store sp */ - st %o7, [%o0+4] /* store pc */ - retl - clr %o0 /* return 0 */ - -ENTRY(_thread_machdep_longjmp) - t ST_FLUSHWIN /* flush register windows */ - sub %sp, 64, %sp /* foo? */ - - ld [%o0+4], %o7 /* restore pc */ - ld [%o0], %fp /* restore fp, the restore ins below will - * cause it to become sp */ - /* i?i:1 - Do we need to care? it's always called with 1 */ - tst %o1 - be,a 0f - mov 1, %o1 -0: - retl - restore %o1, 0, %o0 - diff --git a/lib/libc_r/arch/sparc/uthread_machdep.h b/lib/libc_r/arch/sparc/uthread_machdep.h index 53ad543f77a..cb43f3a0463 100644 --- a/lib/libc_r/arch/sparc/uthread_machdep.h +++ b/lib/libc_r/arch/sparc/uthread_machdep.h @@ -1,39 +1,7 @@ -/* - * OpenBSD/sparc machine-dependent thread macros - * - * $OpenBSD: uthread_machdep.h,v 1.4 2000/01/06 07:04:54 d Exp $ - */ +/* $OpenBSD: uthread_machdep.h,v 1.5 2000/10/04 05:55:35 d Exp $ */ +/* David Leonard, <d@csee.uq.edu.au>. Public domain. */ -#include <sys/signal.h> - -/* save the floating point state of a thread */ -#define _thread_machdep_save_float_state(thr) \ - { \ - /* XXX tdb */ \ - } - -/* restore the floating point state of a thread */ -#define _thread_machdep_restore_float_state(thr) \ - { \ - /* XXX tdb */ \ - } - -typedef long _machdep_jmp_buf[2]; - -int _thread_machdep_setjmp __P((_machdep_jmp_buf)); -void _thread_machdep_longjmp __P((_machdep_jmp_buf, int)); - -/* initialise the jmpbuf stack frame so it continues from entry */ -#define _thread_machdep_thread_create(thr, entry, pattr) \ - { \ - long stack = (long)(thr)->stack->base + \ - (thr)->stack->size - 64; \ - (thr)->saved_jmp_buf[0] = (long)stack; \ - (thr)->saved_jmp_buf[1] = (long)entry - 8; \ - } - -struct _machdep_struct { - /* char saved_fp[???]; */ - int dummy; +struct _machdep_state { + int fp; /* frame pointer */ + int pc; /* program counter */ }; - |