From b4d5d19438106b3904185eb9ba7d6e1b8b0cfdf7 Mon Sep 17 00:00:00 2001 From: rsc Date: Thu, 3 Nov 2005 01:00:56 +0000 Subject: new FreeBSD --- src/libthread/FreeBSD-386-asm.s | 89 +++++++++++++++++++++-------------------- src/libthread/FreeBSD.c | 15 ------- 2 files changed, 45 insertions(+), 59 deletions(-) (limited to 'src/libthread') diff --git a/src/libthread/FreeBSD-386-asm.s b/src/libthread/FreeBSD-386-asm.s index f9a80255..e1f266da 100644 --- a/src/libthread/FreeBSD-386-asm.s +++ b/src/libthread/FreeBSD-386-asm.s @@ -5,50 +5,51 @@ _tas: xchgl %eax, 0(%ecx) ret -.globl setmcontext -setmcontext: - movl 4(%esp), %edx - movl 8(%edx), %fs - movl 12(%edx), %es - movl 16(%edx), %ds - movl 76(%edx), %ss - movl 20(%edx), %edi - movl 24(%edx), %esi - movl 28(%edx), %ebp - movl %esp, %ecx - movl 72(%edx), %esp - pushl 60(%edx) /* eip */ - pushl 44(%edx) /* ecx */ - pushl 48(%edx) /* eax */ - movl 36(%edx), %ebx - movl 40(%edx), %edx - movl 12(%ecx), %eax - popl %eax - popl %ecx - ret +.globl getcontext +getcontext: + movl 4(%esp), %eax + addl $16, %eax /* point to mcontext */ + + movl %fs, 8(%eax) + movl %es, 12(%eax) + movl %ds, 16(%eax) + movl %ss, 76(%eax) + movl %edi, 20(%eax) + movl %esi, 24(%eax) + movl %ebp, 28(%eax) + movl %ebx, 36(%eax) + movl %edx, 40(%eax) + movl %ecx, 44(%eax) -.globl getmcontext -getmcontext: - pushl %edx - movl 8(%esp), %edx - movl %fs, 8(%edx) - movl %es, 12(%edx) - movl %ds, 16(%edx) - movl %ss, 76(%edx) - movl %edi, 20(%edx) - movl %esi, 24(%edx) - movl %ebp, 28(%edx) - movl %ebx, 36(%edx) - movl $1, 48(%edx) - popl %eax - movl %eax, 40(%edx) - movl %ecx, 44(%edx) - movl (%esp), %eax /* eip */ - movl %eax, 60(%edx) - movl %esp, %eax - addl $4, %eax /* setmcontext will re-push the eip */ - movl %eax, 72(%edx) - movl 40(%edx), %edx - xorl %eax, %eax + movl $1, 48(%eax) /* %eax */ + movl (%esp), %ecx /* %eip */ + movl %ecx, 60(%eax) + leal 4(%esp), %ecx /* %esp */ + movl %ecx, 72(%eax) + + movl 44(%eax), %ecx /* restore %ecx */ + movl $0, %eax ret +.globl setcontext +setcontext: + movl 4(%esp), %eax + addl $16, %eax /* point to mcontext */ + + movl 8(%eax), %fs + movl 12(%eax), %es + movl 16(%eax), %ds + movl 76(%eax), %ss + movl 20(%eax), %edi + movl 24(%eax), %esi + movl 28(%eax), %ebp + movl 36(%eax), %ebx + movl 40(%eax), %edx + movl 72(%eax), %esp + + movl 60(%eax), %ecx /* push new %eip */ + pushl %ecx + + movl 44(%eax), %ecx + movl 48(%eax), %eax + ret diff --git a/src/libthread/FreeBSD.c b/src/libthread/FreeBSD.c index 33fd3113..5c282465 100644 --- a/src/libthread/FreeBSD.c +++ b/src/libthread/FreeBSD.c @@ -18,21 +18,6 @@ makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) ucp->uc_mcontext.mc_esp = (int)sp; } -extern int getmcontext(mcontext_t*); -extern int setmcontext(mcontext_t*); - -int -getcontext(ucontext_t *uc) -{ - return getmcontext(&uc->uc_mcontext); -} - -void -setcontext(ucontext_t *uc) -{ - setmcontext(&uc->uc_mcontext); -} - int swapcontext(ucontext_t *oucp, ucontext_t *ucp) { -- cgit v1.2.3