Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Aug 2002 13:27:46 -0700 (PDT)
From:      Jonathan Mini <mini@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 16862 for review
Message-ID:  <200208312027.g7VKRklx009870@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=16862

Change 16862 by mini@mini_stylus on 2002/08/31 13:27:40

	- Look for uc_flags in the right place.
	- A context is valid when mc_len == sizeof(mcontext_t), not when
	  (mc_len - sizeof(mcontext_t) != 0 (i.e., je, not jnz).
	- Obey SKIPSIGMASK in getcontext() too.
	
	This makes getcontext()/setcontext() work again.

Affected files ...

.. //depot/projects/kse/lib/libc/i386/gen/getcontext.S#4 edit

Differences ...

==== //depot/projects/kse/lib/libc/i386/gen/getcontext.S#4 (text+ko) ====

@@ -33,6 +33,7 @@
 #define	MC_SIZE			640	/* sizeof mcontext_t */
 #define	UC_MC_OFFSET		16	/* offset to mcontext from ucontext */
 #define	UC_MC_LEN_OFFSET	96	/* offset to mc_len from mcontext */
+#define	UC_FLAGS_OFFSET		676	/* offset to uc_flags from ucontext */
 #define	MC_FLAGS_OFFSET		660	/* offset to uc_flags from ucontext */
 #define	MC_BUSY_OFFSET		656	/* offset to uc_busy from ucontext */
 #define	MC_LEN_OFFSET		80	/* offset to mc_len from mcontext */
@@ -58,10 +59,10 @@
 	movl	$-1, %eax
 	jmp	7f
 1:	cmpl	$MC_SIZE, UC_MC_LEN_OFFSET(%eax) /* is context valid? */
-	jnz	2f
+	je	2f
 	movl	$-1, %eax		/* bzzzt, invalid context */
 	jmp	7f
-2:	testl $UCF_SKIPSIGMASK, MC_FLAGS_OFFSET(%edx)	/* Restore sigmask? */
+2:	testl $UCF_SKIPSIGMASK, UC_FLAGS_OFFSET(%eax)	/* Restore sigmask? */
 	jnz 3f
 	PIC_PROLOGUE
 	pushl	$0			/* oset = NULL */
@@ -118,9 +119,11 @@
 	cmpl	$0, %eax		/* check for null pointer */
 	jne	1f
 	movl	$-1, %eax
-	jmp	2f
+	jmp	3f
 	movl	4(%esp), %eax		/* get address of context and sigset */
-1:	PIC_PROLOGUE
+1:	testl $UCF_SKIPSIGMASK, UC_FLAGS_OFFSET(%eax)	/* Save sigmask? */
+	jnz 2f
+	PIC_PROLOGUE
 	pushl	%eax			/* oset = &ucp->uc_sigmask */
 	pushl	$0			/* set = NULL */
 	pushl	$3			/* how = SIG_SETMASK */
@@ -128,8 +131,8 @@
 	addl	$12, %esp
 	PIC_EPILOGUE
 	testl	%eax, %eax		/* check for error */
-	jnz	2f
-	pushl	%edx			/* save value of edx */
+	jnz	3f
+2:	pushl	%edx			/* save value of edx */
 	movl	8(%esp), %edx		/* get address of context */
 	addl	$UC_MC_OFFSET, %edx	/* add offset to mcontext */
 	movl	%gs, 4(%edx)
@@ -165,4 +168,4 @@
 	movl	$MC_SIZE, MC_LEN_OFFSET(%edx) /* context is now valid */
 	movl	40(%edx), %edx		/* restore edx -- is this needed? */
 	xorl	%eax, %eax		/* return 0 */
-2:	ret
+3:	ret

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208312027.g7VKRklx009870>