Default to stack objects on DOS_NT platforms as well.
authorEli Zaretskii <eliz@gnu.org>
Thu, 25 Sep 2014 09:34:53 +0000 (12:34 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 25 Sep 2014 09:34:53 +0000 (12:34 +0300)
 src/w32term.h (ALIGN_STACK) [__GNUC__]: Define to
 __attribute__((force_align_arg_pointer)) for GCC 4.2 and later.
 src/lisp.h (USE_STACK_LISP_OBJECTS): Remove the !DOS_NT condition.
 src/w32proc.c (enum_locale_fn, enum_codepage_fn): Add the
 ALIGN_STACK attribute.
 src/w32fns.c (w32_monitor_enum): Add the ALIGN_STACK attribute.
 src/w32uniscribe.c (add_opentype_font_name_to_list): Add the
 ALIGN_STACK attribute.
 src/w32font.c (add_font_name_to_list, add_font_entity_to_list)
 (add_one_font_entity_to_list): Add the ALIGN_STACK attribute.

src/ChangeLog
src/lisp.h
src/w32fns.c
src/w32font.c
src/w32proc.c
src/w32term.h
src/w32uniscribe.c

index e6805691ecb5fccd4781447ccff21f1a4b0f9d93..9c360e64de0c4eb41ce23d2c85851529e4eefcd8 100644 (file)
@@ -1,3 +1,22 @@
+2014-09-25  Eli Zaretskii  <eliz@gnu.org>
+
+       Default to stack objects on DOS_NT platforms as well.
+       * w32term.h (ALIGN_STACK) [__GNUC__]: Define to
+       __attribute__((force_align_arg_pointer)) for GCC 4.2 and later.
+
+       * lisp.h (USE_STACK_LISP_OBJECTS): Remove the !DOS_NT condition.
+
+       * w32proc.c (enum_locale_fn, enum_codepage_fn): Add the
+       ALIGN_STACK attribute.
+
+       * w32fns.c (w32_monitor_enum): Add the ALIGN_STACK attribute.
+
+       * w32uniscribe.c (add_opentype_font_name_to_list): Add the
+       ALIGN_STACK attribute.
+
+       * w32font.c (add_font_name_to_list, add_font_entity_to_list)
+       (add_one_font_entity_to_list): Add the ALIGN_STACK attribute.
+
 2014-09-25  Martin Rudalics  <rudalics@gmx.at>
 
        * frame.c (frame_inhibit_resize):
index 4cd2e69dac32422f0cf23ca6949a346d3a91e7a0..f76008e8f5e42f0436071fd62eb91396270e9ef7 100644 (file)
@@ -282,12 +282,10 @@ error !;
 # endif
 #endif
 
-/* This should work with GCC on non-DOS_NT.  Clang has known problems; see
-   http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00506.html.
-   Also http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00422.html
-   describes an issue with 32-bit MS-Windows.  */
+/* This should work with GCC.  Clang has known problems; see
+   http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00506.html.  */
 #ifndef USE_STACK_LISP_OBJECTS
-# if defined __GNUC__ && !defined __clang__ && !defined DOS_NT
+# if defined __GNUC__ && !defined __clang__
 #  define USE_STACK_LISP_OBJECTS true
 # else
 #  define USE_STACK_LISP_OBJECTS false
index 2b77bb737b6074f80a1e90f91df88c37aa9d58a1..0a8bde1f6616e77da24a6b58a45125df88107362 100644 (file)
@@ -5012,7 +5012,7 @@ If omitted or nil, that stands for the selected frame's display.  */)
   return Qnil;
 }
 
-static BOOL CALLBACK
+static BOOL CALLBACK ALIGN_STACK
 w32_monitor_enum (HMONITOR monitor, HDC hdc, RECT *rcMonitor, LPARAM dwData)
 {
   Lisp_Object *monitor_list = (Lisp_Object *) dwData;
index 7b2aac1cbf25c7ecdbef0f94b885f2f1c3ea28a8..895931843ba6a0684ad3691162812e67b9996275 100644 (file)
@@ -115,15 +115,15 @@ static void compute_metrics (HDC, struct w32font_info *, unsigned int,
 static Lisp_Object w32_registry (LONG, DWORD);
 
 /* EnumFontFamiliesEx callbacks.  */
-static int CALLBACK add_font_entity_to_list (ENUMLOGFONTEX *,
-                                             NEWTEXTMETRICEX *,
-                                             DWORD, LPARAM);
-static int CALLBACK add_one_font_entity_to_list (ENUMLOGFONTEX *,
-                                                 NEWTEXTMETRICEX *,
-                                                 DWORD, LPARAM);
-static int CALLBACK add_font_name_to_list (ENUMLOGFONTEX *,
-                                           NEWTEXTMETRICEX *,
-                                           DWORD, LPARAM);
+static int CALLBACK ALIGN_STACK add_font_entity_to_list (ENUMLOGFONTEX *,
+                                                        NEWTEXTMETRICEX *,
+                                                        DWORD, LPARAM);
+static int CALLBACK ALIGN_STACK add_one_font_entity_to_list (ENUMLOGFONTEX *,
+                                                            NEWTEXTMETRICEX *,
+                                                            DWORD, LPARAM);
+static int CALLBACK ALIGN_STACK add_font_name_to_list (ENUMLOGFONTEX *,
+                                                      NEWTEXTMETRICEX *,
+                                                      DWORD, LPARAM);
 
 /* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track
    of what we really want.  */
@@ -1000,7 +1000,7 @@ w32font_open_internal (struct frame *f, Lisp_Object font_entity,
 
 /* Callback function for EnumFontFamiliesEx.
  * Adds the name of a font to a Lisp list (passed in as the lParam arg).  */
-static int CALLBACK
+static int CALLBACK ALIGN_STACK
 add_font_name_to_list (ENUMLOGFONTEX *logical_font,
                       NEWTEXTMETRICEX *physical_font,
                       DWORD font_type, LPARAM list_object)
@@ -1446,7 +1446,7 @@ check_face_name (LOGFONT *font, char *full_name)
  * and if so, adds it to a list. Both the data we are checking against
  * and the list to which the fonts are added are passed in via the
  * lparam argument, in the form of a font_callback_data struct. */
-static int CALLBACK
+static int CALLBACK ALIGN_STACK
 add_font_entity_to_list (ENUMLOGFONTEX *logical_font,
                         NEWTEXTMETRICEX *physical_font,
                         DWORD font_type, LPARAM lParam)
@@ -1565,7 +1565,7 @@ add_font_entity_to_list (ENUMLOGFONTEX *logical_font,
 
 /* Callback function for EnumFontFamiliesEx.
  * Terminates the search once we have a match. */
-static int CALLBACK
+static int CALLBACK ALIGN_STACK
 add_one_font_entity_to_list (ENUMLOGFONTEX *logical_font,
                             NEWTEXTMETRICEX *physical_font,
                             DWORD font_type, LPARAM lParam)
index dc91910d9a77f9e510e11c59359aa565b83dfcea..b255c57cd7c2c8d8faf1dd8ce18acd319b4f3f59 100644 (file)
@@ -2909,7 +2909,7 @@ int_from_hex (char * s)
    function isn't given a context pointer.  */
 Lisp_Object Vw32_valid_locale_ids;
 
-static BOOL CALLBACK
+static BOOL CALLBACK ALIGN_STACK
 enum_locale_fn (LPTSTR localeNum)
 {
   DWORD id = int_from_hex (localeNum);
@@ -2973,7 +2973,7 @@ If successful, the new locale id is returned, otherwise nil.  */)
    function isn't given a context pointer.  */
 Lisp_Object Vw32_valid_codepages;
 
-static BOOL CALLBACK
+static BOOL CALLBACK ALIGN_STACK
 enum_codepage_fn (LPTSTR codepageNum)
 {
   DWORD id = atoi (codepageNum);
index 0fabe12819c55b701b61136402929bea60fc630a..fcadca6a9af0dfe34267560cabb949f0e7f33504 100644 (file)
@@ -22,6 +22,22 @@ along with GNU Emacs.  If not, see <http://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/.  */
+#ifdef __GNUC__
+# if defined USE_STACK_LISP_OBJECTS && defined _W64    \
+  && __GNUC__ + (__GNUC_MINOR__ > 1) >= 5
+#  define ALIGN_STACK __attribute__((force_align_arg_pointer))
+# else
+#  define ALIGN_STACK
+# endif         /* USE_STACK_LISP_OBJECTS */
+#endif
+
 \f
 #define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0)
 #define WHITE_PIX_DEFAULT(f) PALETTERGB(255,255,255)
index 7e6419c4d2832e9a6e8b380d787e5a2b32cb84a2..1c7b256988c7c558643c2029c342c2cbe285a9c6 100644 (file)
@@ -52,9 +52,9 @@ extern Lisp_Object Quniscribe;
 extern Lisp_Object Qopentype;
 
 /* EnumFontFamiliesEx callback.  */
-static int CALLBACK add_opentype_font_name_to_list (ENUMLOGFONTEX *,
-                                                    NEWTEXTMETRICEX *,
-                                                    DWORD, LPARAM);
+static int CALLBACK ALIGN_STACK add_opentype_font_name_to_list (ENUMLOGFONTEX *,
+                                                               NEWTEXTMETRICEX *,
+                                                               DWORD, LPARAM);
 /* Used by uniscribe_otf_capability.  */
 static Lisp_Object otf_features (HDC context, char *table);
 
@@ -613,7 +613,7 @@ uniscribe_encode_char (struct font *font, int c)
 /* Callback function for EnumFontFamiliesEx.
    Adds the name of opentype fonts to a Lisp list (passed in as the
    lParam arg). */
-static int CALLBACK
+static int CALLBACK ALIGN_STACK
 add_opentype_font_name_to_list (ENUMLOGFONTEX *logical_font,
                                NEWTEXTMETRICEX *physical_font,
                                DWORD font_type, LPARAM list_object)