[newlib-cygwin/cygwin-3_6-branch] Cygwin: Fix compatibility with w32api headers v13

Jon Turney via Cygwin-cvs <[email protected]>
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b4acca9b272c5d79fd6257de2c50b27ef9b289db

commit b4acca9b272c5d79fd6257de2c50b27ef9b289db
Author: Radek Bartoň <[email protected]>
Date:   Mon Jun 9 18:14:14 2025 +0200

    Cygwin: Fix compatibility with w32api headers v13
    
    (cherry picked from commit 2029784e05d9805aa074dcadb99c31311790b7ac)

Diff:
---
 winsup/cygwin/fhandler/socket_inet.cc  | 5 +++++
 winsup/cygwin/fhandler/socket_local.cc | 5 +++++
 winsup/cygwin/local_includes/ntdll.h   | 4 ++++
 winsup/cygwin/net.cc                   | 5 +++++
 4 files changed, 19 insertions(+)

diff --git a/winsup/cygwin/fhandler/socket_inet.cc b/winsup/cygwin/fhandler/socket_inet.cc
index 22dfed63d..5ed0cb0ec 100644
--- a/winsup/cygwin/fhandler/socket_inet.cc
+++ b/winsup/cygwin/fhandler/socket_inet.cc
@@ -20,7 +20,12 @@
 #undef u_long
 #define u_long __ms_u_long
 #include <w32api/ws2tcpip.h>
+/* 2025-06-09: win32api headers v13 now define a cmsghdr type which clashes with
+   our socket.h. Arrange not to see it here. */
+#undef cmsghdr
+#define cmsghdr __ms_cmsghdr
 #include <w32api/mswsock.h>
+#undef cmsghdr
 #include <w32api/mstcpip.h>
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
diff --git a/winsup/cygwin/fhandler/socket_local.cc b/winsup/cygwin/fhandler/socket_local.cc
index ea5ee67cc..0498edc40 100644
--- a/winsup/cygwin/fhandler/socket_local.cc
+++ b/winsup/cygwin/fhandler/socket_local.cc
@@ -21,7 +21,12 @@
 #define u_long __ms_u_long
 #include "ntsecapi.h"
 #include <w32api/ws2tcpip.h>
+/* 2025-06-09: win32api headers v13 now define a cmsghdr type which clashes with
+   our socket.h. Arrange not to see it here. */
+#undef cmsghdr
+#define cmsghdr __ms_cmsghdr
 #include <w32api/mswsock.h>
+#undef cmsghdr
 #include <unistd.h>
 #include <asm/byteorder.h>
 #include <sys/socket.h>
diff --git a/winsup/cygwin/local_includes/ntdll.h b/winsup/cygwin/local_includes/ntdll.h
index 4497fe53f..299167217 100644
--- a/winsup/cygwin/local_includes/ntdll.h
+++ b/winsup/cygwin/local_includes/ntdll.h
@@ -489,6 +489,8 @@ typedef struct _FILE_DISPOSITION_INFORMATION_EX	// 64
   ULONG Flags;
 } FILE_DISPOSITION_INFORMATION_EX, *PFILE_DISPOSITION_INFORMATION_EX;
 
+#if __MINGW64_VERSION_MAJOR < 13
+
 typedef struct _FILE_STAT_INFORMATION		// 68
 {
   LARGE_INTEGER FileId;
@@ -509,6 +511,8 @@ typedef struct _FILE_CASE_SENSITIVE_INFORMATION	// 71
   ULONG Flags;
 } FILE_CASE_SENSITIVE_INFORMATION, *PFILE_CASE_SENSITIVE_INFORMATION;
 
+#endif
+
 enum {
   FILE_LINK_REPLACE_IF_EXISTS				= 0x01,
   FILE_LINK_POSIX_SEMANTICS				= 0x02,
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 9d7224a21..579b1a70b 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -18,7 +18,12 @@ details. */
 #undef u_long
 #define u_long __ms_u_long
 #include <w32api/ws2tcpip.h>
+/* 2025-06-09: win32api headers v13 now define a cmsghdr type which clashes with
+   our socket.h. Arrange not to see it here. */
+#undef cmsghdr
+#define cmsghdr __ms_cmsghdr
 #include <w32api/mswsock.h>
+#undef cmsghdr
 #include <w32api/iphlpapi.h>
 #define gethostname cygwin_gethostname
 #include <unistd.h>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.