emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 aa0c38f: Make sure thread stack is properly align


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-26 aa0c38f: Make sure thread stack is properly aligned on MS-Windows
Date: Sat, 14 Oct 2017 04:14:38 -0400 (EDT)

branch: emacs-26
commit aa0c38f3586d462c7b4d489542b32580f489fdc5
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Make sure thread stack is properly aligned on MS-Windows
    
    * src/systhread.c: Include w32term.h instead of windows.h.
    (w32_beginthread_wrapper): Add ALIGN_STACK attribute, to ensure
    the thread's stack is correctly aligned.
    * src/w32term.h (ALIGN_STACK): Update commentary.
---
 src/systhread.c |  7 ++++---
 src/w32term.h   | 15 ++++++++-------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/systhread.c b/src/systhread.c
index ee89a1e..6f9baab 100644
--- a/src/systhread.c
+++ b/src/systhread.c
@@ -187,7 +187,7 @@ sys_thread_yield (void)
 
 #elif defined (WINDOWSNT)
 
-#include <windows.h>
+#include <w32term.h>
 
 /* Cannot include <process.h> because of the local header by the same
    name, sigh.  */
@@ -326,8 +326,9 @@ sys_thread_self (void)
 static thread_creation_function *thread_start_address;
 
 /* _beginthread wants a void function, while we are passed a function
-   that returns a pointer.  So we use a wrapper.  */
-static void
+   that returns a pointer.  So we use a wrapper.  See the command in
+   w32term.h about the need for ALIGN_STACK attribute.  */
+static void ALIGN_STACK
 w32_beginthread_wrapper (void *arg)
 {
   (void)thread_start_address (arg);
diff --git a/src/w32term.h b/src/w32term.h
index 16b44b0..8d08ca0 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -22,13 +22,14 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "frame.h"
 #include "atimer.h"
 
-/* Stack alignment stuff.  Every CALLBACK function should have the
-   ALIGN_STACK attribute if it manipulates Lisp objects, because
-   Windows x86 32-bit ABI only guarantees 4-byte stack alignment, and
-   that is what we will get when a Windows function calls us.  The
-   ALIGN_STACK attribute forces GCC to emit a preamble code to
-   re-align the stack at function entry.  Further details about this
-   can be found in http://www.peterstock.co.uk/games/mingw_sse/.  */
+/* Stack alignment stuff.  Every CALLBACK and thread function should
+   have the ALIGN_STACK attribute if it manipulates Lisp objects,
+   because Windows x86 32-bit ABI only guarantees 4-byte stack
+   alignment, and that is what we will get when a Windows function
+   calls us.  The ALIGN_STACK attribute forces GCC to emit a preamble
+   code to re-align the stack at function entry.  Further details
+   about this can be found in
+   http://www.peterstock.co.uk/games/mingw_sse/.  */
 #ifdef __GNUC__
 # if USE_STACK_LISP_OBJECTS && !defined _WIN64 && !defined __x86_64__  \
   && __GNUC__ + (__GNUC_MINOR__ > 1) >= 5



reply via email to

[Prev in Thread] Current Thread [Next in Thread]