all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#48354: [PATCH] Fix compat with latest mingw64-headers
@ 2021-05-11 12:59 Konstantin Shabanov
  2021-05-11 15:46 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Shabanov @ 2021-05-11 12:59 UTC (permalink / raw)
  To: 48354

[-- Attachment #1: Type: text/plain, Size: 690 bytes --]

This commit to mingw-w64 broke compatibility with emacs-head because of the OS_NT conflict:

    In file included from w32image.c:32:
    w32common.h:45:3: error: expected identifier before numeric constant
       45 |   OS_NT
          |   ^~~~~

https://sourceforge.net/p/mingw-w64/mingw-w64/ci/dc7ef298837d4581200a3bed660aed36818c1b00/

The series of patches in attachments should fix the issue:
- the first one should cause the build to fail in the future instead of silent overriding definition;
- the second patch renames OS_9X to conform mingw-w64 naming;
- the third actually fixes build failure (preserving backward compatibility);

Best regards,
Konstantin Shabanov

[-- Attachment #2: 0001-Reorder-headers-inclusion.patch --]
[-- Type: application/octet-stream, Size: 1268 bytes --]

From fdc8243947828233c9d959cbec0a0946ff3788cd Mon Sep 17 00:00:00 2001
From: Konstantin Shabanov <mail@etehtsea.me>
Date: Tue, 11 May 2021 18:20:46 +0700
Subject: [PATCH 1/3] Reorder headers inclusion

Otherwise it gets overriden silently instead of build failure like
this one (in case of global variables conflict):

In file included from w32image.c:32:
w32common.h:45:3: error: expected identifier before numeric constant
   45 |   OS_NT
      |   ^~~~~
---
 src/w32fns.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/w32fns.c b/src/w32fns.c
index 66baeaecbd..43bee6147b 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -41,13 +41,10 @@ #define _WIN32_WINNT 0x0600
 #include "buffer.h"
 #include "keyboard.h"
 #include "blockinput.h"
 #include "coding.h"
 
-#include "w32common.h"
-#include "w32inevt.h"
-
 #ifdef WINDOWSNT
 #include <mbstring.h>
 #include <mbctype.h>	/* for _getmbcp */
 #endif /* WINDOWSNT */
 
@@ -71,10 +68,13 @@ #define _WIN32_WINNT 0x0600
 
 #include <dlgs.h>
 #include <imm.h>
 #include <windowsx.h>
 
+#include "w32common.h"
+#include "w32inevt.h"
+
 #ifndef FOF_NO_CONNECTED_ELEMENTS
 #define FOF_NO_CONNECTED_ELEMENTS 0x2000
 #endif
 
 extern int w32_console_toggle_lock_key (int, Lisp_Object);
-- 
2.31.1


[-- Attachment #3: 0003-Fix-compatibility-with-the-latest-mingw64-headers.patch --]
[-- Type: application/octet-stream, Size: 1200 bytes --]

From dd935d9170765386627fee0a727a688095cb7344 Mon Sep 17 00:00:00 2001
From: Konstantin Shabanov <mail@etehtsea.me>
Date: Tue, 11 May 2021 18:44:49 +0700
Subject: [PATCH 3/3] Fix compatibility with the latest mingw64-headers

OS_NT was introduced in mingw64-headers itself and started to cause
build failure:

In file included from w32image.c:32:
w32common.h:45:3: error: expected identifier before numeric constant
   45 |   OS_NT
      |   ^~~~~

This change is expected to be backward compatible.
---
 src/w32common.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/w32common.h b/src/w32common.h
index 53b3376f7c..00caf7e31c 100644
--- a/src/w32common.h
+++ b/src/w32common.h
@@ -38,14 +38,17 @@ #define get_w32_minor_version()  	w32_minor_version
 
 extern int    	      w32_major_version;
 extern int    	      w32_minor_version;
 extern int    	      w32_build_number;
 
-enum {
-  OS_WIN95ORGREATER = 1,
-  OS_NT
-};
+#ifndef OS_NT
+  #define OS_NT 1
+#endif
+
+#ifndef OS_WIN95ORGREATER
+  #define OS_WIN95ORGREATER 2
+#endif
 
 extern int os_subtype;
 
 /* Cache system info, e.g., the NT page size.  */
 extern void cache_system_info (void);
-- 
2.31.1


[-- Attachment #4: 0002-Rename-OS_9X-to-OS_WIN95ORGREATER.patch --]
[-- Type: application/octet-stream, Size: 10222 bytes --]

From 5517e09c9d25f01cbf49e13f117381df5e698012 Mon Sep 17 00:00:00 2001
From: Konstantin Shabanov <mail@etehtsea.me>
Date: Tue, 11 May 2021 18:29:06 +0700
Subject: [PATCH 2/3] Rename OS_9X to OS_WIN95ORGREATER

Unify with the current mingw64-headers
https://sourceforge.net/p/mingw-w64/mingw-w64/ci/dc7ef298837d4581200a3bed660aed36818c1b00/
---
 src/dynlib.c    |  2 +-
 src/w32.c       |  4 ++--
 src/w32common.h |  2 +-
 src/w32fns.c    | 10 +++++-----
 src/w32heap.c   |  4 ++--
 src/w32notify.c |  2 +-
 src/w32proc.c   |  8 ++++----
 src/w32term.c   |  4 ++--
 src/w32term.h   |  2 +-
 9 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/dynlib.c b/src/dynlib.c
index 1338e9109c..2d263fb3ec 100644
--- a/src/dynlib.c
+++ b/src/dynlib.c
@@ -133,11 +133,11 @@ dynlib_addr (void (*funcptr) (void), const char **fname, const char **symname)
   wchar_t mfn_w[MAX_PATH];
   char mfn_a[MAX_PATH];
   void *addr = (void *) funcptr;
 
   /* Step 1: Find the handle of the module where ADDR lives.  */
-  if (os_subtype == OS_9X
+  if (os_subtype == OS_WIN95ORGREATER
       /* Windows NT family version before XP (v5.1).  */
       || ((w32_major_version + (w32_minor_version > 0)) < 6))
     {
       MEMORY_BASIC_INFORMATION mbi;
 
diff --git a/src/w32.c b/src/w32.c
index 467e6cb427..635c882431 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -4745,11 +4745,11 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force)
   strcpy (temp, map_w32_filename (oldname, NULL));
 
   /* volume_info is set indirectly by map_w32_filename.  */
   oldname_dev = volume_info.serialnum;
 
-  if (os_subtype == OS_9X)
+  if (os_subtype == OS_WIN95ORGREATER)
     {
       char * o;
       char * p;
       int    i = 0;
       char oldname_a[MAX_PATH];
@@ -10466,11 +10466,11 @@ shutdown_handler (DWORD type)
 /* On Windows 9X, load UNICOWS.DLL and return its handle, or die.  On
    NT, return a handle to GDI32.DLL.  */
 HANDLE
 maybe_load_unicows_dll (void)
 {
-  if (os_subtype == OS_9X)
+  if (os_subtype == OS_WIN95ORGREATER)
     {
       HANDLE ret = LoadLibrary ("Unicows.dll");
       if (ret)
 	{
 	  /* These two functions are present on Windows 9X as stubs
diff --git a/src/w32common.h b/src/w32common.h
index cbe05c5d8d..53b3376f7c 100644
--- a/src/w32common.h
+++ b/src/w32common.h
@@ -39,11 +39,11 @@ #define get_w32_minor_version()  	w32_minor_version
 extern int    	      w32_major_version;
 extern int    	      w32_minor_version;
 extern int    	      w32_build_number;
 
 enum {
-  OS_9X = 1,
+  OS_WIN95ORGREATER = 1,
   OS_NT
 };
 
 extern int os_subtype;
 
diff --git a/src/w32fns.c b/src/w32fns.c
index 43bee6147b..02edd8929f 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -7989,11 +7989,11 @@ DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash,
 
       path = map_w32_filename (SSDATA (encoded_file), NULL);
 
       /* The Unicode version of SHFileOperation is not supported on
 	 Windows 9X. */
-      if (w32_unicode_filenames && os_subtype != OS_9X)
+      if (w32_unicode_filenames && os_subtype != OS_WIN95ORGREATER)
 	{
 	  SHFILEOPSTRUCTW file_op_w;
 	  /* We need one more element beyond MAX_PATH because this is
 	     a list of file names, with the last element double-null
 	     terminated. */
@@ -9293,21 +9293,21 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
   strtok (pname_buf, ",");
   /* We want to know more than the printer name */
   if (!OpenPrinter (pname_buf, &hPrn, NULL))
     return Qnil;
   /* GetPrinterW is not supported by unicows.dll.  */
-  if (w32_unicode_filenames && os_subtype != OS_9X)
+  if (w32_unicode_filenames && os_subtype != OS_WIN95ORGREATER)
     GetPrinterW (hPrn, 2, NULL, 0, &dwNeeded);
   else
     GetPrinterA (hPrn, 2, NULL, 0, &dwNeeded);
   if (dwNeeded == 0)
     {
       ClosePrinter (hPrn);
       return Qnil;
     }
   /* Call GetPrinter again with big enough memory block.  */
-  if (w32_unicode_filenames && os_subtype != OS_9X)
+  if (w32_unicode_filenames && os_subtype != OS_WIN95ORGREATER)
     {
       /* Allocate memory for the PRINTER_INFO_2 struct.  */
       ppi2w = xmalloc (dwNeeded);
       err = GetPrinterW (hPrn, 2, (LPBYTE)ppi2w, dwNeeded, &dwReturned);
       ClosePrinter (hPrn);
@@ -9439,11 +9439,11 @@ cache_system_info (void)
   version.data = GetVersion ();
   w32_major_version = version.info.major;
   w32_minor_version = version.info.minor;
 
   if (version.info.platform & 0x8000)
-    os_subtype = OS_9X;
+    os_subtype = OS_WIN95ORGREATER;
   else
     os_subtype = OS_NT;
 
   /* Cache page size, allocation unit, processor type, etc.  */
   GetSystemInfo (&sysinfo_cache);
@@ -9452,11 +9452,11 @@ cache_system_info (void)
   /* Cache os info.  */
   osinfo_cache.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
   GetVersionEx (&osinfo_cache);
 
   w32_build_number = osinfo_cache.dwBuildNumber;
-  if (os_subtype == OS_9X)
+  if (os_subtype == OS_WIN95ORGREATER)
     w32_build_number &= 0xffff;
 
   w32_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
 }
 
diff --git a/src/w32heap.c b/src/w32heap.c
index e002f72608..c4cbcd14f8 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -267,11 +267,11 @@ init_heap (bool use_dynamic_heap)
 	    DebPrint (("Enabling Low Fragmentation Heap failed: error %ld\n",
 		       GetLastError ()));
 	}
 #endif
 
-      if (os_subtype == OS_9X)
+      if (os_subtype == OS_WIN95ORGREATER)
         {
           the_malloc_fn = malloc_after_dump_9x;
           the_realloc_fn = realloc_after_dump_9x;
           the_free_fn = free_after_dump_9x;
         }
@@ -310,11 +310,11 @@ init_heap (bool use_dynamic_heap)
 	  fprintf (stderr, "Cannot build Emacs without RtlCreateHeap being available; exiting.\n");
 	  exit (-1);
 	}
       heap = s_pfn_Rtl_Create_Heap (0, data_region_base, 0, 0, NULL, &params);
 
-      if (os_subtype == OS_9X)
+      if (os_subtype == OS_WIN95ORGREATER)
         {
           fprintf (stderr, "Cannot dump Emacs on Windows 9X; exiting.\n");
           exit (-1);
         }
       else
diff --git a/src/w32notify.c b/src/w32notify.c
index b9e9063392..a525979cd8 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -564,11 +564,11 @@ DEFUN ("w32notify-add-watch", Fw32notify_add_watch,
   char *errstr;
 
   CHECK_LIST (filter);
 
   /* The underlying features are available only since XP.  */
-  if (os_subtype == OS_9X
+  if (os_subtype == OS_WIN95ORGREATER
       || (w32_major_version == 5 && w32_minor_version < 1))
     {
       errno = ENOSYS;
       report_file_notify_error ("Watching filesystem events is not supported",
 				Qnil);
diff --git a/src/w32proc.c b/src/w32proc.c
index ffa56e135d..082dd61f76 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -621,11 +621,11 @@ init_timers (void)
 {
   /* GetThreadTimes is not available on all versions of Windows, so
      need to probe for its availability dynamically, and call it
      through a pointer.  */
   s_pfn_Get_Thread_Times = NULL; /* in case dumped Emacs comes with a value */
-  if (os_subtype != OS_9X)
+  if (os_subtype != OS_WIN95ORGREATER)
     s_pfn_Get_Thread_Times = (GetThreadTimes_Proc)
       get_proc_addr (GetModuleHandle ("kernel32.dll"), "GetThreadTimes");
 
   /* Make sure we start with zeroed out itimer structures, since
      dumping may have left there traces of threads long dead.  */
@@ -2652,11 +2652,11 @@ find_child_console (HWND hwnd, LPARAM arg)
     {
       char window_class[32];
 
       GetClassName (hwnd, window_class, sizeof (window_class));
       if (strcmp (window_class,
-		  (os_subtype == OS_9X)
+		  (os_subtype == OS_WIN95ORGREATER)
 		  ? "tty"
 		  : "ConsoleWindowClass") == 0)
 	{
 	  cp->hwnd = hwnd;
 	  return FALSE;
@@ -2876,11 +2876,11 @@ sys_kill (pid_t pid, int sig)
   else
     {
       if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd)
 	{
 #if 1
-	  if (os_subtype == OS_9X)
+	  if (os_subtype == OS_WIN95ORGREATER)
 	    {
 /*
    Another possibility is to try terminating the VDM out-right by
    calling the Shell VxD (id 0x17) V86 interface, function #4
    "SHELL_Destroy_VM", ie.
@@ -3791,11 +3791,11 @@ w32_compare_strings (const char *s1, const char *s2, char *locname,
 	  || strcmp (locname, "POSIX") == 0))
     return (ignore_case ? stricmp (s1, s2) : strcmp (s1, s2));
 
   if (!g_b_init_compare_string_w)
     {
-      if (os_subtype == OS_9X)
+      if (os_subtype == OS_WIN95ORGREATER)
 	{
 	  pCompareStringW = (CompareStringW_Proc)
             get_proc_addr (LoadLibrary ("Unicows.dll"),
                                   "CompareStringW");
 	  if (!pCompareStringW)
diff --git a/src/w32term.c b/src/w32term.c
index 4f910296ec..e13b402f75 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -7636,11 +7636,11 @@ syms_of_w32term (void)
 specified by `file-name-coding-system'.
 
 This variable is set to non-nil by default when Emacs runs on Windows
 systems of the NT family, including W2K, XP, Vista, Windows 7 and
 Windows 8.  It is set to nil on Windows 9X.  */);
-  if (os_subtype == OS_9X)
+  if (os_subtype == OS_WIN95ORGREATER)
     w32_unicode_filenames = 0;
   else
     w32_unicode_filenames = 1;
 
   DEFVAR_BOOL ("w32-use-native-image-API",
@@ -7653,11 +7653,11 @@ syms_of_w32term (void)
 library is available only since W2K, therefore this variable is
 unconditionally set to nil on older systems.  */);
 
   /* For now, disabled by default, since this is an experimental feature.  */
 #if 0 && HAVE_NATIVE_IMAGE_API
-  if (os_subtype == OS_9X)
+  if (os_subtype == OS_WIN95ORGREATER)
     w32_use_native_image_api = 0;
   else
     w32_use_native_image_api = 1;
 #else
   w32_use_native_image_api = 0;
diff --git a/src/w32term.h b/src/w32term.h
index 7d351df871..c38a5bf486 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -759,11 +759,11 @@ #define FILE_NOTIFICATIONS_SIZE 16384
 #ifdef WINDOWSNT
 /* Keyboard hooks.  */
 extern void setup_w32_kbdhook (void);
 extern void remove_w32_kbdhook (void);
 extern int check_w32_winkey_state (int);
-#define w32_kbdhook_active (os_subtype != OS_9X)
+#define w32_kbdhook_active (os_subtype != OS_WIN95ORGREATER)
 #else
 #define w32_kbdhook_active 0
 #endif
 
 /* Keypad command key support.  W32 doesn't have virtual keys defined
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#48354: [PATCH] Fix compat with latest mingw64-headers
  2021-05-11 12:59 bug#48354: [PATCH] Fix compat with latest mingw64-headers Konstantin Shabanov
@ 2021-05-11 15:46 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2021-05-11 15:46 UTC (permalink / raw)
  To: Konstantin Shabanov; +Cc: 48354-done

> Date: Tue, 11 May 2021 12:59:47 +0000
> From: Konstantin Shabanov <mail@etehtsea.me>
> 
> 
> [1:text/plain Hide]
> 
> This commit to mingw-w64 broke compatibility with emacs-head because of the OS_NT conflict:
> 
>     In file included from w32image.c:32:
>     w32common.h:45:3: error: expected identifier before numeric constant
>        45 |   OS_NT
>           |   ^~~~~
> 
> https://sourceforge.net/p/mingw-w64/mingw-w64/ci/dc7ef298837d4581200a3bed660aed36818c1b00/
> 
> The series of patches in attachments should fix the issue:
> - the first one should cause the build to fail in the future instead of silent overriding definition;
> - the second patch renames OS_9X to conform mingw-w64 naming;
> - the third actually fixes build failure (preserving backward compatibility);

Thanks, this is already fixed since 2 days ago on the emacs-27 branch,
soon to be merged to master.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-11 15:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-11 12:59 bug#48354: [PATCH] Fix compat with latest mingw64-headers Konstantin Shabanov
2021-05-11 15:46 ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.