Attachment "kai-update.patch" to
ticket [3059922fff]
added by
dgp
2010-09-08 20:38:57.
Also attachment "kai-update.patch" to
ticket [1910041fff]
added by
dgp
2010-09-08 20:38:05.
Index: win/tclWin32Dll.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWin32Dll.c,v
retrieving revision 1.54.2.2
diff -u -r1.54.2.2 tclWin32Dll.c
--- win/tclWin32Dll.c 4 Aug 2010 19:17:29 -0000 1.54.2.2
+++ win/tclWin32Dll.c 8 Sep 2010 13:33:57 -0000
@@ -320,6 +320,7 @@
*/
#ifdef HAVE_NO_SEH
+#ifndef _WIN64
__asm__ __volatile__ (
/*
@@ -388,6 +389,76 @@
:
"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"
);
+#else
+ __asm__ __volatile__ (
+
+ /*
+ * Construct an EXCEPTION_REGISTRATION to protect the call to
+ * Tcl_Finalize
+ */
+
+ "leaq %[registration], %%rdx" "\n\t"
+ "movq %%gs:0, %%rax" "\n\t"
+ "movq %%rax, 0x0(%%rdx)" "\n\t" /* link */
+ "leaq 1f, %%rax" "\n\t"
+ "movq %%rax, 0x8(%%rdx)" "\n\t" /* handler */
+ "movq %%rbp, 0x10(%%rdx)" "\n\t" /* ebp */
+ "movq %%rsp, 0x18(%%rdx)" "\n\t" /* esp */
+ "movl %[error], 0x20(%%rdx)" "\n\t" /* status */
+
+ /*
+ * Link the EXCEPTION_REGISTRATION on the chain
+ */
+
+ "movq %%rdx, %%gs:0" "\n\t"
+
+ /*
+ * Call Tcl_Finalize
+ */
+
+ "call _Tcl_Finalize" "\n\t"
+
+ /*
+ * Come here on a normal exit. Recover the EXCEPTION_REGISTRATION
+ * and store a TCL_OK status
+ */
+
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movq %[ok], %%rax" "\n\t"
+ "movl %%rax, 0x20(%%rdx)" "\n\t"
+ "jmp 2f" "\n"
+
+ /*
+ * Come here on an exception. Get the EXCEPTION_REGISTRATION that
+ * we previously put on the chain.
+ */
+
+ "1:" "\t"
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movq 0x10(%%rdx), %%rdx" "\n"
+
+
+ /*
+ * Come here however we exited. Restore context from the
+ * EXCEPTION_REGISTRATION in case the stack is unbalanced.
+ */
+
+ "2:" "\t"
+ "movq 0x18(%%rdx), %%rsp" "\n\t"
+ "movq 0x10(%%rdx), %%rbp" "\n\t"
+ "movq 0x0(%%rdx), %%rax" "\n\t"
+ "movq %%rax, %%gs:0" "\n\t"
+
+ :
+ /* No outputs */
+ :
+ [registration] "m" (registration),
+ [ok] "i" (TCL_OK),
+ [error] "i" (TCL_ERROR)
+ :
+ "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "memory"
+ );
+#endif
#else /* HAVE_NO_SEH */
__try {
Index: win/tclWinChan.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinChan.c,v
retrieving revision 1.49.4.2
diff -u -r1.49.4.2 tclWinChan.c
--- win/tclWinChan.c 21 May 2010 12:18:17 -0000 1.49.4.2
+++ win/tclWinChan.c 8 Sep 2010 13:33:57 -0000
@@ -1106,6 +1106,7 @@
* illegal for one asm block to contain a jump to another.
*/
+#ifndef _WIN64
__asm__ __volatile__ (
/*
@@ -1178,6 +1179,83 @@
:
"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"
);
+#else
+ __asm__ __volatile__ (
+
+ /*
+ * Pick up parameters before messing with the stack
+ */
+
+ "movq %[dupedHandle], %%rbx" "\n\t"
+
+ /*
+ * Construct an EXCEPTION_REGISTRATION to protect the call to
+ * CloseHandle.
+ */
+
+ "leaq %[registration], %%rdx" "\n\t"
+ "movq %%gs:0, %%rax" "\n\t"
+ "movq %%rax, 0x0(%%edx)" "\n\t" /* link */
+ "leaq 1f, %%rax" "\n\t"
+ "movq %%rax, 0x8(%%rdx)" "\n\t" /* handler */
+ "movq %%rbp, 0x10(%%rdx)" "\n\t" /* ebp */
+ "movq %%rsp, 0x18(%%rdx)" "\n\t" /* esp */
+ "movl $0, 0x20(%%rdx)" "\n\t" /* status */
+
+ /*
+ * Link the EXCEPTION_REGISTRATION on the chain.
+ */
+
+ "movq %%rdx, %%gs:0" "\n\t"
+
+ /*
+ * Call CloseHandle(dupedHandle).
+ */
+
+ "pushq %%rbx" "\n\t"
+ "movq %%rbx,%%rcx" "\n\t"
+ "call _CloseHandle" "\n\t"
+ "addq $8, %%rsp" "\n\t"
+
+
+ /*
+ * Come here on normal exit. Recover the EXCEPTION_REGISTRATION
+ * and put a TRUE status return into it.
+ */
+
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movl $1, %%eax" "\n\t"
+ "movl %%eax, 0x20(%%rdx)" "\n\t"
+ "jmp 2f" "\n"
+
+ /*
+ * Come here on an exception. Recover the EXCEPTION_REGISTRATION
+ */
+
+ "1:" "\t"
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movq 0x10(%%rdx), %%rdx" "\n\t"
+
+ /*
+ * Come here however we exited. Restore context from the
+ * EXCEPTION_REGISTRATION in case the stack is unbalanced.
+ */
+
+ "2:" "\t"
+ "movq 0x18(%%rdx), %%rsp" "\n\t"
+ "movq 0x10(%%rdx), %%rbp" "\n\t"
+ "movq 0x0(%%rdx), %%rax" "\n\t"
+ "movq %%rax, %%gs:0" "\n\t"
+
+ :
+ /* No outputs */
+ :
+ [registration] "m" (registration),
+ [dupedHandle] "m" (dupedHandle)
+ :
+ "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "memory"
+ );
+#endif
result = registration.status;
#endif
Index: win/tclWinFCmd.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinFCmd.c,v
retrieving revision 1.52
diff -u -r1.52 tclWinFCmd.c
--- win/tclWinFCmd.c 29 Aug 2006 00:36:57 -0000 1.52
+++ win/tclWinFCmd.c 8 Sep 2010 13:33:57 -0000
@@ -213,6 +213,7 @@
* for one asm block to contain a jump to another.
*/
+#ifndef _WIN64
__asm__ __volatile__ (
/*
* Pick up params before messing with the stack.
@@ -288,6 +289,85 @@
:
"%eax", "%ebx", "%ecx", "%edx", "memory"
);
+#else
+ __asm__ __volatile__ (
+ /*
+ * Pick up params before messing with the stack.
+ */
+
+ "movq %[nativeDst], %%rbx" "\n\t"
+ "movq %[nativeSrc], %%rcx" "\n\t"
+
+ /*
+ * Construct an EXCEPTION_REGISTRATION to protect the call to
+ * MoveFile.
+ */
+
+ "leaq %[registration], %%rdx" "\n\t"
+ "movq %%gs:0, %%rax" "\n\t"
+ "movq %%rax, 0x0(%%rdx)" "\n\t" /* link */
+ "leaq 1f, %%rax" "\n\t"
+ "movq %%rax, 0x8(%%rdx)" "\n\t" /* handler */
+ "movq %%rbp, 0x10(%%rdx)" "\n\t" /* ebp */
+ "movq %%rsp, 0x18(%%rdx)" "\n\t" /* esp */
+ "movl $0, 0x20(%%rdx)" "\n\t" /* status */
+
+ /*
+ * Link the EXCEPTION_REGISTRATION on the chain.
+ */
+
+ "movq %%rdx, %%gs:0" "\n\t"
+
+ /*
+ * Call MoveFile(nativeSrc, nativeDst)
+ */
+
+ "pushq %%rbx" "\n\t"
+ "pushq %%rcx" "\n\t"
+ "movq %%rbx, %%rdx" "\n\t"
+ "movq %[moveFile], %%rax" "\n\t"
+ "call *%%rax" "\n\t"
+ "addq $16, %%rsp" "\n\t"
+
+ /*
+ * Come here on normal exit. Recover the EXCEPTION_REGISTRATION and
+ * put the status return from MoveFile into it.
+ */
+
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movl %%eax, 0x20(%%rdx)" "\n\t"
+ "jmp 2f" "\n"
+
+ /*
+ * Come here on an exception. Recover the EXCEPTION_REGISTRATION
+ */
+
+ "1:" "\t"
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movq 0x10(%%rdx), %%rdx" "\n\t"
+
+ /*
+ * Come here however we exited. Restore context from the
+ * EXCEPTION_REGISTRATION in case the stack is unbalanced.
+ */
+
+ "2:" "\t"
+ "movq 0x18(%%rdx), %%rsp" "\n\t"
+ "movq 0x10(%%rdx), %%rbp" "\n\t"
+ "movq 0x0(%%rdx), %%rax" "\n\t"
+ "movq %%rax, %%gs:0" "\n\t"
+
+ :
+ /* No outputs */
+ :
+ [registration] "m" (registration),
+ [nativeDst] "m" (nativeDst),
+ [nativeSrc] "m" (nativeSrc),
+ [moveFile] "r" (tclWinProcs->moveFileProc)
+ :
+ "%rax", "%rbx", "%rcx", "%rdx", "memory"
+ );
+#endif
if (registration.status != FALSE) {
retval = TCL_OK;
}
@@ -601,6 +681,7 @@
* for one asm block to contain a jump to another.
*/
+#ifndef _WIN64
__asm__ __volatile__ (
/*
@@ -678,6 +759,88 @@
:
"%eax", "%ebx", "%ecx", "%edx", "memory"
);
+#else
+ __asm__ __volatile__ (
+
+ /*
+ * Pick up parameters before messing with the stack
+ */
+
+ "movq %[nativeDst], %%rbx" "\n\t"
+ "movq %[nativeSrc], %%rcx" "\n\t"
+
+ /*
+ * Construct an EXCEPTION_REGISTRATION to protect the call to
+ * CopyFile.
+ */
+
+ "leaq %[registration], %%rdx" "\n\t"
+ "movq %%gs:0, %%rax" "\n\t"
+ "movq %%rax, 0x0(%%rdx)" "\n\t" /* link */
+ "leaq 1f, %%rax" "\n\t"
+ "movq %%rax, 0x8(%%rdx)" "\n\t" /* handler */
+ "movq %%rbp, 0x10(%%rdx)" "\n\t" /* ebp */
+ "movq %%rsp, 0x18(%%rdx)" "\n\t" /* esp */
+ "movl $0, 0x20(%%rdx)" "\n\t" /* status */
+
+ /*
+ * Link the EXCEPTION_REGISTRATION on the chain.
+ */
+
+ "movq %%rdx, %%gs:0" "\n\t"
+
+ /*
+ * Call CopyFile(nativeSrc, nativeDst, 0)
+ */
+
+ "movq %[copyFile], %%rax" "\n\t"
+ "pushq $0" "\n\t"
+ "pushq %%rbx" "\n\t"
+ "pushq %%rcx" "\n\t"
+ "movq %%rbx, %%rdx" "\n\t"
+ "subq %%r8, %%r8" "\n\t"
+ "call *%%rax" "\n\t"
+ "addq $24, %%rsp" "\n\t"
+
+ /*
+ * Come here on normal exit. Recover the EXCEPTION_REGISTRATION and
+ * put the status return from CopyFile into it.
+ */
+
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movl %%eax, 0x20(%%rdx)" "\n\t"
+ "jmp 2f" "\n"
+
+ /*
+ * Come here on an exception. Recover the EXCEPTION_REGISTRATION
+ */
+
+ "1:" "\t"
+ "movq %%gs:0, %%rdx" "\n\t"
+ "movq 0x10(%%rdx), %%rdx" "\n\t"
+
+ /*
+ * Come here however we exited. Restore context from the
+ * EXCEPTION_REGISTRATION in case the stack is unbalanced.
+ */
+
+ "2:" "\t"
+ "movq 0x18(%%rdx), %%rsp" "\n\t"
+ "movq 0x10(%%rdx), %%rbp" "\n\t"
+ "movq 0x0(%%rdx), %%rax" "\n\t"
+ "movq %%rax, %%gs:0" "\n\t"
+
+ :
+ /* No outputs */
+ :
+ [registration] "m" (registration),
+ [nativeDst] "m" (nativeDst),
+ [nativeSrc] "m" (nativeSrc),
+ [copyFile] "r" (tclWinProcs->copyFileProc)
+ :
+ "%rax", "%rbx", "%rcx", "%rdx", "r8", "memory"
+ );
+#endif
if (registration.status != FALSE) {
retval = TCL_OK;
}