summaryrefslogtreecommitdiff
blob: acd7c7de10ac8fdf7aad6e01522f7430a22e60e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--- lwp-1.9/src/process.S.amd64	2001-10-04 23:14:08.000000000 +0200
+++ lwp-1.9/src/process.S	2003-09-26 17:18:35.000000000 +0200
@@ -472,6 +472,61 @@ ENTRY(returnto)
 #endif 	/* i386 */
 
 
+#if defined(__x86_64__)
+		
+#ifdef	__linux__
+#include <linux/linkage.h>	
+#endif
+
+#define FRAME_SIZE	(8*8)
+
+/*
+   savecontext(f, area1, newsp)
+	int (*f)();
+ 	struct savearea *area1;
+	char *newsp;
+		
+*/
+
+#define f	rdi
+#define area1	rsi
+#define newsp	rdx
+#define topstack  0
+
+	.text
+ENTRY(savecontext)
+	sub	$FRAME_SIZE, %rsp
+	mov	%rbx, (0*8)(%rsp)	/* Save registers. */
+	mov	%rbp, (1*8)(%rsp)
+	mov	%r12, (2*8)(%rsp)
+	mov	%r13, (3*8)(%rsp)
+	mov	%r14, (4*8)(%rsp)
+	mov	%r15, (5*8)(%rsp)
+	mov	%rsp, topstack(%area1)	/* Store sp in savearea. */
+	cmp	$0, %newsp
+	cmovne	%newsp, %rsp		/* Don't change the stack if newsp is zero. */
+	jmp	*%f			/* f(); */
+
+/*
+  returnto(area2)
+     struct savearea *area2;
+*/
+
+#define	area2	rdi
+
+ENTRY(returnto)
+	mov	topstack(%area2), %rsp	/* Restore stack pointer. */
+	mov	(0*8)(%rsp), %rbx	/* Restore registers. */
+	mov	(1*8)(%rsp), %rbp
+	mov	(2*8)(%rsp), %r12
+	mov	(3*8)(%rsp), %r13
+	mov	(4*8)(%rsp), %r14
+	mov	(5*8)(%rsp), %r15
+	add	$FRAME_SIZE, %rsp
+	ret
+
+#endif 	/* amd64 */
+
 #ifdef luna88k
 /* Luna88K Code from Dan Stodolsky via Brad White */
 
--- lwp-1.9/src/lwp.c.amd64	2001-04-02 14:16:16.000000000 +0200
+++ lwp-1.9/src/lwp.c	2003-09-26 17:14:30.000000000 +0200
@@ -565,6 +565,14 @@ int LWP_CreateProcess(PFIC ep, int stack
 #else
 	pagesize = getpagesize();
 
+#if defined(__x86_64__)
+	/* [gb] Ensure minimal stack size. Heuristically determined
+	   through tdb test that 2048 is too small when printf() et al. come
+	   into action.  */
+	if (stacksize < pagesize)
+	  stacksize = pagesize;
+#endif
+
 #ifdef MAP_ANON
 	stackptr = mmap(lwp_stackbase, stacksize, PROT_READ | PROT_WRITE,
                         MAP_PRIVATE | MAP_ANON, -1, 0);