Patchwork [m32c] make m32c_jsri16 reentrant

login
register
mail settings
Submitter DJ Delorie
Date Oct. 22, 2010, 7:57 p.m.
Message ID <201010221957.o9MJvPaQ009762@greed.delorie.com>
Download mbox | patch
Permalink /patch/68950/
State New
Headers show

Comments

DJ Delorie - Oct. 22, 2010, 7:57 p.m.
Applied.

2010-10-22  DJ Delorie  <dj@redhat.com>

	* config/m32c/m32c-lib1.S (m32c_jsri16): Make reentrant.

Patch

Index: config/m32c/m32c-lib1.S
===================================================================
--- config/m32c/m32c-lib1.S	(revision 165857)
+++ config/m32c/m32c-lib1.S	(working copy)
@@ -201,23 +201,31 @@  cmpsi_gt:
 cmpsi_lt:
 	mov.w	#0,r0
 	exitd
 #endif
 
 #ifdef L__m32c_jsri16
-	.data
-m32c_jsri_addr:
-	.byte	0, 0, 0
-m32c_jsri_ret:
-	.byte	0, 0, 0
-
 	.text
+#ifdef A16
 	.global	m32c_jsri16
 m32c_jsri16:
-	pop.w	m32c_jsri_ret
-	pop.b	m32c_jsri_ret+2
-	pop.w	m32c_jsri_addr
-	push.b	m32c_jsri_ret+2
-	push.w	m32c_jsri_ret
-	jmpi.a	m32c_jsri_addr
+	add.w	#-1, sp
+
+	/* Read the address (16 bits) and return address (24 bits) off
+	the stack.  */
+	mov.w	4[sp], r0
+	mov.w	1[sp], r3
+	mov.b	3[sp], a0 /* This zero-extends, so the high byte has
+			     zero in it.  */
+
+	/* Write the return address, then new address, to the stack.  */
+	mov.w	a0, 1[sp] /* Just to get the zero in 2[sp].  */
+	mov.w	r0, 0[sp]
+	mov.w	r3, 3[sp]
+	mov.b	a0, 5[sp]
+
+	/* This "returns" to the target address, leaving the pending
+	return address on the stack.  */
+	rts
+#endif
 
 #endif