2017-11-14 Keith Marshall <keith@users.osdn.me>
+ Establish default selection for WinSock API declaration.
+
+ * include/windows.h include/nspapi.h: Include...
+ * include/_winsock.h: ...this new system private header; it selects...
+ [_WIN32_WINNT >= _WIN32_WINNT_NT4]: ...WinSock v2 API declarations, as
+ provided by conditional inclusion of <winsock2.h>, otherwise...
+ [_WIN32_WINNT < _WIN32_WINNT_NT4]: ...WinSock v1.1 API declarations,
+ as provided by inclusion of <winsock.h>
+
+ * tests/headers.at <_winsock.h>: Add reference.
+
+2017-11-14 Keith Marshall <keith@users.osdn.me>
+
Update gethostname() declaration; drop Cygwin specificity.
* include/winsock.h (gethostname): Declare unconditionally; add...
--- /dev/null
+/*
+ * _winsock.h
+ *
+ * A private system header, included wherever other system headers may
+ * require declaration of the WinSock API, without explicitly specifying
+ * a particular WinSock version dependency.
+ *
+ *
+ * $Id$
+ *
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2017, MinGW.org Project
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+#ifndef _WINSOCK_H
+#pragma GCC system_header
+
+/* The WinSock API dependency may be satisfied by including either <winsock.h>
+ * or <winsock2.h>; note that, regardless of whichever of these alternatives we
+ * choose, _WINSOCK_H will become defined, thus satisfying the repeat inclusion
+ * guard for this header file itself, without any requirement for us to provide
+ * an explicit definition herein.
+ */
+#include <sdkddkver.h>
+#if _WIN32_WINNT >= _WIN32_WINNT_NT4
+/* When the target operating system is WinNT4, or later, we prefer to support
+ * the WinSock v2 API, by default; (this is consistent with the default choice
+ * which was traditionally specified within MinGW.org's <windows.h>)...
+ */
+#include <winsock2.h>
+
+#else
+/* ...whereas, for operating systems predating WinNT4, we elect to offer
+ * support for only WinSock v1.1
+ */
+#include <winsock.h>
+#endif
+
+#endif /* !_WINSOCK_H: $RCSfile$: end of file */
* the full content, we must process the WinSock API declarations from
* <winsock.h> or <winsock2.h>, BEFORE we define the <nspapi.h> repeat
* inclusion guard, so that <winsock2.h> may, if necessary, recurse to
- * access the selectively exposed content.
+ * access the selectively exposed content. Inclusion of the following
+ * private header will declare the necessary WinSock API, choosing to
+ * include either <winsock.h> or <winsock2.h> by default, on the same
+ * basis as the similar choice made in <windows.h>
*/
-#ifndef _WINSOCK_H
-/* We must include <winsock.h> or <winsock2.h>; (we favour <winsock2.h>
- * over <winsock.h>, on the same basis as our <windows.h> does).
- */
-#include <sdkddkver.h>
-#if _WIN32_WINNT >= _WIN32_WINNT_WIN2K
-#include <winsock2.h>
-
-#else /* _WIN32_WINNT < Win2K */
-#include <winsock.h>
-#endif
+#include "_winsock.h"
-#endif /* !_WINSOCK_H */
/* We can now be confident that the WinSock API has been appropriately
* declared; we may now define the <nspapi.h> repeat inclusion guard.
*/
* $Id$
*
* Written by Anders Norlander <anorland@hem2.passagen.se>
- * Copyright (C) 1998-2003, 2006, 2007, 2016, MinGW.org Project
+ * Copyright (C) 1998-2003, 2006, 2007, 2016, 2017, MinGW.org Project
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
#include <commdlg.h>
#include <winspool.h>
#endif
-#if defined(Win32_Winsock)
-#warning "The Win32_Winsock macro name is deprecated.\
- Please use __USE_W32_SOCKETS instead"
-#ifndef __USE_W32_SOCKETS
-#define __USE_W32_SOCKETS
+#if defined Win32_Winsock
+#warning "The Win32_Winsock macro is deprecated; use __USE_W32_SOCKETS instead."
+# ifndef __USE_W32_SOCKETS
+# define __USE_W32_SOCKETS
+# endif
#endif
-#endif
-#if defined(__USE_W32_SOCKETS) || !(defined(__CYGWIN__) || defined(__MSYS__) || defined(_UWIN))
-#if (_WIN32_WINNT >= 0x0400)
-#include <winsock2.h>
-/*
- * MS likes to include mswsock.h here as well,
- * but that can cause undefined symbols if
- * winsock2.h is included before windows.h
- */
-#else
-#include <winsock.h>
-#endif /* (_WIN32_WINNT >= 0x0400) */
+#if defined __USE_W32_SOCKETS \
+ || ! (defined __CYGWIN__ || defined __MSYS__ || defined _UWIN)
+ /* The WinSock API should be declared; including the following
+ * private header file will make an informed choice between the
+ * WinSock v1.1 API, as declared in <winsock.h>, and WinSock v2,
+ * as declared in <winsock2.h>, as the preferred default level
+ * of WinSock API support to be offered.
+ */
+# include "_winsock.h"
+ /*
+ * FIXME: strict Microsoft compatibility may require inclusion
+ * of <mswsock.h> here as well; however, this has been observed
+ * to produce undefined symbol errors, if <winsock2.h> has been
+ * included before <windows.h>, so we omit this.
+ */
+# /* include <mswsock.h> */
#endif
#ifndef NOGDI
/* In older versions we disallowed COM declarations in __OBJC__
winresrc.h dnl
winsnmp.h dnl
winsock2.h dnl
+_winsock.h dnl
winsock.h dnl
winspool.h dnl
winsvc.h dnl