This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SH: makecontext: Fix calculation of ARGC > 4


Hi!

On Thu, 14 Jun 2012 19:46:40 +0900, Kaz Kojima <kkojima@rr.iij4u.or.jp> wrote:
> Thomas Schwinge <thomas@codesourcery.com> wrote:
> > With this patch, stdlib/tst-setcontext and stdlib/tst-makecontext3 now
> > pass.  Kaz, does this make sense?
> > 
> > 	* sysdeps/unix/sysv/linux/sh/makecontext.S (__makecontext): Fix
> > 	calculation of ARGC > 4.

Pushed as commit 2a649725b939fe8a50089cce9644b9649ef4fe43.


> > During review of that file, I annotated the assembler code as in the
> > following -- enough to now have this in the mailing list archives or
> > would that be worth committing, too?
> 
> Yes and yes.  Thanks for the fix and nice annotations!

I pushed the following as commit
af1bce34ef3ae8caa84214175e93d809c11a5ea4:

	* sysdeps/unix/sysv/linux/sh/makecontext.S: Add comments and give more
	meaningful names to some local labels.
 
diff --git a/sysdeps/unix/sysv/linux/sh/makecontext.S b/sysdeps/unix/sysv/linux/sh/makecontext.S
index 0a9e079..9e1358d 100644
--- a/sysdeps/unix/sysv/linux/sh/makecontext.S
+++ b/sysdeps/unix/sysv/linux/sh/makecontext.S
@@ -33,44 +33,44 @@
 	.align	5
 ENTRY(__makecontext)
 	mov	#4, r3
-	mov.l	@(oSS_SP,r4), r1
-	mov.l	@(oSS_SIZE,r4), r2
-	add	r1, r2
-	cmp/gt	r6, r3
+	mov.l	@(oSS_SP,r4), r1	/* r1 <- ucb->stack_base */
+	mov.l	@(oSS_SIZE,r4), r2	/* r2 <- ucb->stack_size */
+	add	r1, r2			/* r2 <- stack_top */
+	cmp/gt	r6, r3			/* 4 > argc? */
 	bf/s	1f
-	 shlr2	r2
+	 shlr2	r2			/* r2 <- stack_top / 4 */
 	sub	r6, r2
 	add	r3, r2
 1:
-	shll2	r2
+	shll2	r2		/* r2 <- stack_top - ((argc > 4) ? 4 * (argc - 4) : 0 */
 	mov	#oR15, r0
 	mov.l	@(oLINK,r4), r1
-	mov.l	r2, @(r0,r4)
-	mov.l	r1, @(oR8,r4)
+	mov.l	r2, @(r0,r4)	/* ucp->r15 <- r2 */
+	mov.l	r1, @(oR8,r4)	/* ucp->r8 <- ucp->uc_link */
 	mov	#oPC, r0
-	mov.l	r5, @(r0,r4)
+	mov.l	r5, @(r0,r4)	/* ucp->PC <- func */
 
-	cmp/pl	r6
+	cmp/pl	r6		/* argc > 0? */
 	bf/s	.L1
 	 dt	r6
-	mov.l	r7, @(oR4,r4)
-	cmp/pl	r6
+	mov.l	r7, @(oR4,r4)	/* ucp->r4 <- argv[0] */
+	cmp/pl	r6		/* argc > 1? */
 	bf/s	.L1
 	 dt	r6
 	mov.l	@(0,r15), r1
-	mov.l	r1, @(oR5,r4)
-	cmp/pl	r6
+	mov.l	r1, @(oR5,r4)	/* ucp->r5 <- argv[1] */
+	cmp/pl	r6		/* argc > 2? */
 	bf/s	.L1
 	 dt	r6
 	mov.l	@(4,r15), r1
-	mov.l	r1, @(oR6,r4)
-	cmp/pl	r6
+	mov.l	r1, @(oR6,r4)	/* ucp->r6 <- argv[2] */
+	cmp/pl	r6		/* argc > 3? */
 	bf/s	.L1
 	 dt	r6
 	mov.l	@(8,r15), r1
-	mov.l	r1, @(oR7,r4)
+	mov.l	r1, @(oR7,r4)	/* ucp->r7 <- argv[3] */
 	mov	#12,r0
-.L0:
+.L0:				/* Save remaining argv[] on the stack.  */
 	cmp/pl	r6
 	bf/s	.L1
 	 dt	r6
@@ -87,7 +87,7 @@ ENTRY(__makecontext)
 #endif
 	add	#oPR, r4
 	rts
-	 mov.l	r0, @r4
+	 mov.l	r0, @r4		/* ucp->pr <- exitcode */
 #ifndef PIC
 	.align	2
 .L2:
@@ -97,24 +97,24 @@ ENTRY(__makecontext)
 
 	.align	5
 .Lexitcode:
-	tst	r8, r8
+	tst	r8, r8		/* ucb->uc_link == NULL? */
 	bt/s	2f
-	 mov	r8, r4
+	 mov	r8, r4		/* r4 <- ucb->uc_link */
 #ifdef PIC
 	mova	.Lgot, r0
 	mov.l	.Lgot, r12
 	add	r0, r12
-	mov.l	.L3, r1
+	mov.l	.Lsetcontext, r1
 	bsrf	r1
 .LPCS0:
 	 nop
 #else
-	mov.l	.L3, r1
+	mov.l	.Lsetcontext, r1
 	jsr	@r1
 	 nop
 #endif
 2:
-	mov.l	.L4, r1
+	mov.l	.Lexit, r1
 #ifdef PIC
 	add	r12, r1
 #endif
@@ -128,14 +128,14 @@ ENTRY(__makecontext)
 #ifdef PIC
 .Lgot:
 	.long	_GLOBAL_OFFSET_TABLE_
-.L3:
+.Lsetcontext:
 	.long	__setcontext@PLT-(.LPCS0+2-(.))
-.L4:
+.Lexit:
 	.long	HIDDEN_JUMPTARGET(exit)@GOTOFF
 #else
-.L3:
+.Lsetcontext:
 	.long	__setcontext
-.L4:
+.Lexit:
 	.long	HIDDEN_JUMPTARGET(exit)
 #endif
 	cfi_startproc


GrÃÃe,
 Thomas

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]