summaryrefslogtreecommitdiffhomepage
path: root/src/signal/nt32
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-09-22 19:56:41 -0400
committermidipix <writeonce@midipix.org>2016-09-28 06:18:09 -0400
commitbe8c406f9fea929e2eac4006c446f164ad25ba91 (patch)
tree7e53b62c744eb73bf396f0daff467cd3010e55f5 /src/signal/nt32
parente3a9601cdc0ea5cb5d2a43ea7e8f0f4bf8afdbbf (diff)
downloadmmglue-be8c406f9fea929e2eac4006c446f164ad25ba91.tar.bz2
mmglue-be8c406f9fea929e2eac4006c446f164ad25ba91.tar.xz
nt32: implemented sigsetjmp().
Diffstat (limited to 'src/signal/nt32')
-rw-r--r--src/signal/nt32/sigsetjmp.s51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/signal/nt32/sigsetjmp.s b/src/signal/nt32/sigsetjmp.s
new file mode 100644
index 0000000..82e160e
--- /dev/null
+++ b/src/signal/nt32/sigsetjmp.s
@@ -0,0 +1,51 @@
+.text
+.globl ___sigsetjmp
+.globl _sigsetjmp
+
+.def __sigsetjmp; .scl 2; .type 32; .endef
+.def sigsetjmp; .scl 2; .type 32; .endef
+
+___sigsetjmp:
+_sigsetjmp:
+ # int sigsetjmp(sigjmp_buf jmp_buf, int save_mask);
+ #
+ # 8(%esp): save_mask
+ # 4(%esp): jmp_buf
+ # 0(%esp): return address
+
+ movl 8(%esp),%edx # edx <-- save_mask
+ test %edx,%edx # save signal mask?
+ jnz 1f # yes: save mask
+ jmp ___setjmp # no: setjmp
+
+1:
+ # typedef unsigned long __jmp_buf[6];
+ #
+ # typedef struct __jmp_buf_tag {
+ # __jmp_buf __jb;
+ # unsigned long __fl;
+ # unsigned long __ss[16];
+ # }
+ #
+
+ movl 4(%esp),%ecx # ecx <-- jmp_buf
+ popl 36(%ecx) # save return address to .__ss[2]
+ movl %ebx,40(%ecx) # save ebx (arbitrary choice) to .__ss[3]
+ movl %ecx,%ebx # save pointer to __jmp_buf to ebx
+
+ call ___setjmp
+
+ pushl 36(%ebx) # push previously saved return address
+ movl %ebx,4(%esp) # save pointer to __jmp_buf to 4(%esp) (arg 0)
+ movl %eax,8(%esp) # save setjmp return value to 8(%esp) (arg 1)
+ movl 40(%ebx),%ebx # restore ebx from .__ss[3]
+
+
+ jmp ___sigsetjmp_tail # defer to __sigsetjmp_tail
+
+
+ .section .got$sigsetjmp,"r"
+ .global __imp__sigsetjmp
+__imp__sigsetjmp:
+ .long _sigsetjmp
+ .linkonce discard