OSDN Git Service

Identify features which have been deprecated in WinSock v2.
authorKeith Marshall <keith@users.osdn.me>
Tue, 7 Nov 2017 19:24:55 +0000 (19:24 +0000)
committerKeith Marshall <keith@users.osdn.me>
Tue, 7 Nov 2017 19:24:55 +0000 (19:24 +0000)
w32api/ChangeLog
w32api/include/winsock.h
w32api/include/winsock2.h

index 7da5824..d81c326 100644 (file)
@@ -1,5 +1,18 @@
 2017-11-07  Keith Marshall  <keith@users.osdn.me>
 
+       Identify features which have been deprecated in WinSock v2.
+
+       * include/winsock.h (__WINSOCK2_DEPRECATED): Define as nothing.
+       * include/winsock2.h (__WINSOCK2_DEPRECATED): Define as equivalent...
+       (__MINGW_ATTRIB_DEPRECATED): ...to this.
+
+       * include/winsock.h include/winsock2.h: Qualify...
+       (WSAIsBlocking, WSAUnhookBlockingHook, WSASetBlockingHook)
+       (WSACancelBlockingCall): ...each of these function prototypes, with...
+       (__WINSOCK2_DEPRECATED): ...this attribute.
+
+2017-11-07  Keith Marshall  <keith@users.osdn.me>
+
        Adopt system naming convention for USE_SYS_TYPES_FD_SET macro.
 
        * include/winsock.h (USE_SYS_TYPES_FD_SET): Deprecate it; use...
index e0da4db..789ab04 100644 (file)
 #define _USE_SYS_TYPES_FD_SET  1
 #endif
 
+#ifndef __WINSOCK2_DEPRECATED
+/* Some of the WinSock v1.1 declarations have become deprecated in
+ * WinSock v2.  If <winsock2.h> has been included, this deprecation
+ * attribute macro should already have been defined; if not, we now
+ * define it to do nothing.
+ */
+#define __WINSOCK2_DEPRECATED
+#endif
+
 _BEGIN_C_DECLS
 
 typedef u_int  SOCKET;
@@ -515,10 +524,15 @@ WINSOCK_API_LINKAGE int PASCAL WSACleanup (void);
 WINSOCK_API_LINKAGE void PASCAL WSASetLastError (int);
 WINSOCK_API_LINKAGE int PASCAL WSAGetLastError (void);
 
-WINSOCK_API_LINKAGE BOOL PASCAL WSAIsBlocking (void);
-WINSOCK_API_LINKAGE int PASCAL WSAUnhookBlockingHook (void);
-WINSOCK_API_LINKAGE FARPROC PASCAL WSASetBlockingHook (FARPROC);
-WINSOCK_API_LINKAGE int PASCAL WSACancelBlockingCall (void);
+/* The following four pseudo-blocking functions are provided
+ * to support WinSock v1.1, but have been marked as deprecated
+ * in WinSock v2; they remain available, but it is recommended
+ * that threads should be used instead!
+ */
+WINSOCK_API_LINKAGE BOOL PASCAL WSAIsBlocking (void) __WINSOCK2_DEPRECATED;
+WINSOCK_API_LINKAGE int PASCAL WSAUnhookBlockingHook (void) __WINSOCK2_DEPRECATED;
+WINSOCK_API_LINKAGE FARPROC PASCAL WSASetBlockingHook (FARPROC) __WINSOCK2_DEPRECATED;
+WINSOCK_API_LINKAGE int PASCAL WSACancelBlockingCall (void) __WINSOCK2_DEPRECATED;
 
 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetServByName (HWND, u_int, const char *, const char *, char *, int);
 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetServByPort (HWND, u_int, int, const char *, char *, int);
index 6f6faef..9ed1e87 100644 (file)
  */
 #if !(defined _WINSOCK2_H || defined _WINSOCK_H)
 #define _WINSOCK2_H
+
+/* WinSock v2 deprecates several features, which are standard
+ * in WinSock v1.1; their declarations remain in scope, but we
+ * define this qualifying macro up-front, to ensure that the
+ * deprecated status is recorded.
+ */
+#define __WINSOCK2_DEPRECATED  __MINGW_ATTRIB_DEPRECATED
+
 #define _WINSOCK_H /* to prevent later inclusion of winsock.h */
 #pragma GCC system_header
 
@@ -587,13 +595,15 @@ typedef int (PASCAL *LPFN_WSACLEANUP) (void);
 typedef int (PASCAL *LPFN_WSAGETLASTERROR) (void);
 typedef void (PASCAL *LPFN_WSASETLASTERROR) (int);
 
-/* Pseudo-blocking functions are deprecated in WinSock v2.
- * Use threads instead of these!
+/* The following four pseudo-blocking functions are provided
+ * to support WinSock v1.1, but have been marked as deprecated
+ * in WinSock v2; they remain available, but it is recommended
+ * that threads should be used instead!
  */
-WINSOCK_API_LINKAGE BOOL PASCAL WSAIsBlocking (void);
-WINSOCK_API_LINKAGE int PASCAL WSAUnhookBlockingHook (void);
-WINSOCK_API_LINKAGE FARPROC PASCAL WSASetBlockingHook (FARPROC);
-WINSOCK_API_LINKAGE int PASCAL WSACancelBlockingCall (void);
+WINSOCK_API_LINKAGE BOOL PASCAL WSAIsBlocking (void) __WINSOCK2_DEPRECATED;
+WINSOCK_API_LINKAGE int PASCAL WSAUnhookBlockingHook (void) __WINSOCK2_DEPRECATED;
+WINSOCK_API_LINKAGE FARPROC PASCAL WSASetBlockingHook (FARPROC) __WINSOCK2_DEPRECATED;
+WINSOCK_API_LINKAGE int PASCAL WSACancelBlockingCall (void) __WINSOCK2_DEPRECATED;
 
 typedef BOOL (PASCAL *LPFN_WSAISBLOCKING) (void);
 typedef int (PASCAL *LPFN_WSAUNHOOKBLOCKINGHOOK) (void);