shithub: scc

Download patch

ref: d7f0e25b97d041a2645e2d90f6033949b01c7cc6
parent: ecf1b1b62ca8f0cca554c942ba02442397d21ad0
author: zerous Naveen Narayanan <zerous@nocebo.space>
date: Tue Sep 3 20:20:50 EDT 2019

Add setjmp.s and longjmp.s for i386

--- a/src/libc/arch/i386/Makefile
+++ b/src/libc/arch/i386/Makefile
@@ -3,6 +3,7 @@
 include $(PROJECTDIR)/scripts/rules.mk
 include ../../rules.mk
 
+OBJS = longjmp.o setjmp.o
 DIRS = netbsd openbsd dragonfly linux darwin
 
 all: $(OBJS) $(SYS)
--- /dev/null
+++ b/src/libc/arch/i386/longjmp.s
@@ -1,0 +1,19 @@
+	.file	"longjmp.s"
+
+	.text
+	.globl	_longjmp
+_longjmp:
+	mov  	4(%esp),%edx
+	mov  	8(%esp),%eax
+	test    %eax,%eax
+	jnz 	1f
+	inc     %eax
+1:
+	mov   	(%edx),%ebx
+	mov  	4(%edx),%esi
+	mov  	8(%edx),%edi
+	mov 	12(%edx),%ebp
+	mov 	16(%edx),%ecx
+	mov     %ecx,%esp
+	mov 	20(%edx),%ecx
+	jmp 	*%ecx
--- /dev/null
+++ b/src/libc/arch/i386/setjmp.s
@@ -1,0 +1,16 @@
+	.file	"setjmp.s"
+
+	.text
+	.globl	_setjmp
+_setjmp:
+	mov 	4(%esp),%eax
+	mov    	%ebx,(%eax)
+	mov    	%esi,4(%eax)
+	mov    	%edi,8(%eax)
+	mov    	%ebp,12(%eax)
+	lea 	4(%esp),%ecx
+	mov    	%ecx,16(%eax)
+	mov  	(%esp),%ecx
+	mov    	%ecx,20(%eax)
+	xor    	%eax,%eax
+	ret