Commit Diff


commit - b4d5d19438106b3904185eb9ba7d6e1b8b0cfdf7
commit + 1e05fdf92cf4c3ae32c52d6928f3e74000b76f6a
blob - 35e99ca59b955d7bba09f10e14f603b4cb6e9416
blob + 57fd1bd82900f128810c8ee3c691cc9086112a9d
--- src/libthread/386-ucontext.h
+++ src/libthread/386-ucontext.h
@@ -1,8 +1,8 @@
+#define	setcontext(u)	setmcontext(&(u)->uc_mcontext)
+#define	getcontext(u)	getmcontext(&(u)->uc_mcontext)
 typedef struct mcontext mcontext_t;
 typedef struct ucontext ucontext_t;
 
-extern	int		getcontext(ucontext_t*);
-extern	void		setcontext(ucontext_t*);
 extern	int		swapcontext(ucontext_t*, ucontext_t*);
 extern	void		makecontext(ucontext_t*, void(*)(), int, ...);
 
blob - e1f266da8fde36339a1193ef0a12a81c97756b76
blob + 42169853435f27a80e3557a899911888d18c7686
--- src/libthread/FreeBSD-386-asm.s
+++ src/libthread/FreeBSD-386-asm.s
@@ -5,11 +5,10 @@ _tas:
 	xchgl %eax, 0(%ecx)
 	ret
 
-.globl getcontext
-getcontext:
+.globl getmcontext
+getmcontext:
 	movl	4(%esp), %eax
-	addl		$16, %eax	/* point to mcontext */
-	
+
 	movl	%fs, 8(%eax)
 	movl	%es, 12(%eax)
 	movl	%ds, 16(%eax)
@@ -26,16 +25,15 @@ getcontext:
 	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:
+.globl setmcontext
+setmcontext:
 	movl	4(%esp), %eax
-	addl		$16, %eax	/* point to mcontext */
-	
+
 	movl	8(%eax), %fs
 	movl	12(%eax), %es
 	movl	16(%eax), %ds
@@ -45,11 +43,10 @@ setcontext:
 	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	72(%eax), %esp
+	pushl	60(%eax)	/* new %eip */
 	movl	48(%eax), %eax
 	ret
+
blob - 8515e4ded973b16d16e9304f4ef699ea3b539ccb
blob + 5a285bf20bcf53bbcbaee9f7a018e54f5be76dc4
--- src/libthread/Linux-arm-asm.s
+++ src/libthread/Linux-arm-asm.s
@@ -9,9 +9,8 @@ _tas:
 	mov	r0, r3
 	mov	pc, lr
 
-.globl getcontext
-getcontext:
-	add	r0, r0, #148	/* walk to mcontext */
+.globl getmcontext
+getmcontext:
 	str	r1, [r0,#4]
 	str	r2, [r0,#8]
 	str	r3, [r0,#12]
@@ -33,9 +32,8 @@ getcontext:
 	mov	r0, #0
 	mov	pc, lr
 
-.globl setcontext
-setcontext:
-	add	r0, r0, #148	/* walk to mcontext */
+.globl setmcontext
+setmcontext:
 	ldr	r1, [r0,#4]
 	ldr	r2, [r0,#8]
 	ldr	r3, [r0,#12]
blob - 5f7f862e45bcac59a2ac33c73aa428f6adff4384
blob + 969c19f20c5eb86ab000bd12c7d83bcbddebcb25
--- src/libthread/Linux.c
+++ src/libthread/Linux.c
@@ -437,8 +437,8 @@ _threadpexit(void)
 }
 
 #ifdef __arm__
-extern int getmcontext(mcontext_t*);
-extern int setmcontext(const mcontext_t*);
+#define	setcontext(u)	setmcontext(&(u)->uc_mcontext)
+#define	getcontext(u)	getmcontext(&(u)->uc_mcontext)
 
 void
 makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...)
blob - 741797431833b3099b01542f79518d30159b25a4
blob + 3725f264a4ef4f7b132095d58194cc55820437c3
--- src/libthread/OpenBSD-386.c
+++ src/libthread/OpenBSD-386.c
@@ -13,22 +13,7 @@ makecontext(ucontext_t *ucp, void (*func)(void), int a
 	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)
 {
 	if(getcontext(oucp) == 0)
blob - c3c7e72bdf380c05c4688bbb3374189971ff5f3b
blob + b83522f00e6725fba2d9f975e9eae0e945f8bcad
--- src/libthread/OpenBSD-power.c
+++ src/libthread/OpenBSD-power.c
@@ -16,19 +16,6 @@ makecontext(ucontext_t *ucp, void (*func)(void), int a
 }
 
 int
-getcontext(ucontext_t *uc)
-{
-	return _getmcontext(&uc->mc);
-}
-
-int
-setcontext(ucontext_t *uc)
-{
-	_setmcontext(&uc->mc);
-	return 0;
-}
-
-int
 swapcontext(ucontext_t *oucp, ucontext_t *ucp)
 {
 	if(getcontext(oucp) == 0)
blob - a39be28a940f0ff88fb59d350dab86ce746f5d92
blob + a25d480a5657bc6b327ee7e2bf7cfe52b528e849
--- src/libthread/power-ucontext.h
+++ src/libthread/power-ucontext.h
@@ -1,3 +1,5 @@
+#define	setcontext(u)	_setmcontext(&(u)->uc_mcontext)
+#define	getcontext(u)	_getmcontext(&(u)->uc_mcontext)
 typedef struct mcontext mcontext_t;
 typedef struct ucontext ucontext_t;
 struct mcontext
@@ -27,8 +29,6 @@ struct ucontext
 };
 
 void makecontext(ucontext_t*, void(*)(void), int, ...);
-int getcontext(ucontext_t*);
-int setcontext(ucontext_t*);
 int swapcontext(ucontext_t*, ucontext_t*);
 int _getmcontext(mcontext_t*);
 void _setmcontext(mcontext_t*);
blob - 09276bb3556732ec0a699f89932b693a77b1eff0
blob + 9757526ea1b6a05991590c1e8dee7a0131def2f2
--- src/libthread/threadimpl.h
+++ src/libthread/threadimpl.h
@@ -13,8 +13,10 @@
 #include "thread.h"
 
 #if defined(__FreeBSD__) && __FreeBSD__ < 5
-extern	int		getcontext(ucontext_t*);
-extern	void		setcontext(ucontext_t*);
+extern	int		getmcontext(mcontext_t*);
+extern	void		setmcontext(mcontext_t*);
+#define	setcontext(u)	setmcontext(&(u)->uc_mcontext)
+#define	getcontext(u)	getmcontext(&(u)->uc_mcontext)
 extern	int		swapcontext(ucontext_t*, ucontext_t*);
 extern	void		makecontext(ucontext_t*, void(*)(), int, ...);
 #endif