[PATCH 3/4] include: Do not define winsock functions if using the WS_* prefix.

Zebediah Figura zfigura at codeweavers.com
Mon Jan 10 17:31:06 CST 2022


They cannot be linked to this way.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 include/winsock.h  | 58 +++++++++++++++++++++++----------------------
 include/winsock2.h | 59 ++++++++++++++++++++++++----------------------
 2 files changed, 61 insertions(+), 56 deletions(-)

diff --git a/include/winsock.h b/include/winsock.h
index d6160bea446..4b8242e404d 100644
--- a/include/winsock.h
+++ b/include/winsock.h
@@ -947,39 +947,41 @@ void WINAPI WSASetLastError(int);
 int WINAPI WSAStartup(WORD,LPWSADATA);
 int WINAPI WSAUnhookBlockingHook(void);
 
-SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
-int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
-int WINAPI WS(closesocket)(SOCKET);
-int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
-struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
-struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
-int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
-struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
-struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
-#ifdef WS_DEFINE_SELECT
-int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
-#endif
-struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
-struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
-int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
-int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
-ULONG WINAPI WS(inet_addr)(const char*);
-char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
-int WINAPI WS(ioctlsocket)(SOCKET,LONG,ULONG*);
-int WINAPI WS(listen)(SOCKET,int);
-int WINAPI WS(recv)(SOCKET,char*,int,int);
-int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
-int WINAPI WS(send)(SOCKET,const char*,int,int);
-int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
-int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
-int WINAPI WS(shutdown)(SOCKET,int);
-SOCKET WINAPI WS(socket)(int,int,int);
+#ifndef USE_WS_PREFIX
+
+SOCKET WINAPI accept(SOCKET s, struct sockaddr *addr, int *len);
+int WINAPI bind(SOCKET s, const struct sockaddr *addr, int len);
+int WINAPI closesocket(SOCKET s);
+int WINAPI connect(SOCKET s, const struct sockaddr *addr, int len);
+struct hostent * WINAPI gethostbyaddr(const char *addr, int len, int family);
+struct hostent * WINAPI gethostbyname(const char *name);
+int WINAPI getpeername(SOCKET s, struct sockaddr *addr, int *len);
+struct protoent * WINAPI getprotobyname(const char *name);
+struct protoent * WINAPI getprotobynumber(int number);
+struct servent * WINAPI getservbyname(const char *name, const char *protocol);
+struct servent * WINAPI getservbyport(int port, const char *protocol);
+int WINAPI getsockname(SOCKET s, struct sockaddr *addr, int *len);
+int WINAPI getsockopt(SOCKET s, int level, int name, char *value, int *len);
+ULONG WINAPI inet_addr(const char *addr);
+char * WINAPI inet_ntoa(struct in_addr addr);
+int WINAPI ioctlsocket(SOCKET s, LONG cmd, u_long *argp);
+int WINAPI listen(SOCKET s, int backlog);
+int WINAPI recv(SOCKET s, char *buffer, int size, int flags);
+int WINAPI recvfrom(SOCKET s, char *buffer, int size, int flags, struct sockaddr *addr, int *addr_len);
+int WINAPI select(int unused, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout);
+int WINAPI send(SOCKET s, const char *buffer, int size, int flags);
+int WINAPI sendto(SOCKET s, const char *buffer, int size, int flags, const struct sockaddr *addr, int addr_len);
+int WINAPI setsockopt(SOCKET s, int level, int name, const char *value, int len);
+int WINAPI shutdown(SOCKET s, int how);
+SOCKET WINAPI socket(int family, int type, int protocol);
 
 #if defined(__MINGW32__) || defined (_MSC_VER) || defined(__WINE_USE_MSVCRT)
 /* gethostname is not defined on Unix because of conflicts with unistd.h */
-int WINAPI WS(gethostname)(char*,int);
+int WINAPI gethostname(char *name, int len);
 #endif
 
+#endif /* USE_WS_PREFIX */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/winsock2.h b/include/winsock2.h
index 31b7bd13675..565979a74c0 100644
--- a/include/winsock2.h
+++ b/include/winsock2.h
@@ -1113,37 +1113,40 @@ typedef SOCKET (WINAPI *LPFN_SOCKET)(int,int,int);
 #if WS_API_PROTOTYPES
 int WINAPI __WSAFDIsSet(SOCKET, WS(fd_set) *);
 
-SOCKET WINAPI WS(accept)(SOCKET, struct WS(sockaddr) *, int *);
-int WINAPI WS(bind)(SOCKET, const struct WS(sockaddr) *, int);
-int WINAPI WS(closesocket)(SOCKET);
-int WINAPI WS(connect)(SOCKET, const struct WS(sockaddr) *, int);
-struct WS(hostent) * WINAPI WS(gethostbyaddr)(const char *, int, int);
-struct WS(hostent) * WINAPI WS(gethostbyname)(const char *);
+
+#ifndef USE_WS_PREFIX
+
+SOCKET WINAPI accept(SOCKET s, struct sockaddr *addr, int *len);
+int WINAPI bind(SOCKET s, const struct sockaddr *addr, int len);
+int WINAPI closesocket(SOCKET s);
+int WINAPI connect(SOCKET s, const struct sockaddr *addr, int len);
+struct hostent * WINAPI gethostbyaddr(const char *addr, int len, int family);
+struct hostent * WINAPI gethostbyname(const char *name);
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__WINE_USE_MSVCRT)
 /* gethostname is defined in unistd.h */
-int WINAPI WS(gethostname)(char *, int);
+int WINAPI gethostname(char *name, int len);
 #endif
-int WINAPI WS(getpeername)(SOCKET, struct WS(sockaddr) *, int *);
-struct WS(protoent) * WINAPI WS(getprotobyname)(const char *);
-struct WS(protoent) * WINAPI WS(getprotobynumber)(int);
-struct WS(servent) * WINAPI WS(getservbyname)(const char *, const char *);
-struct WS(servent) * WINAPI WS(getservbyport)(int, const char *);
-int WINAPI WS(getsockname)(SOCKET, struct WS(sockaddr) *, int *);
-int WINAPI WS(getsockopt)(SOCKET, int, int, char *, int *);
-ULONG WINAPI WS(inet_addr)(const char *);
-char * WINAPI WS(inet_ntoa)(struct WS(in_addr));
-int WINAPI WS(ioctlsocket)(SOCKET, LONG, WS(u_long) *);
-int WINAPI WS(listen)(SOCKET, int);
-int WINAPI WS(recv)(SOCKET, char *, int, int);
-int WINAPI WS(recvfrom)(SOCKET, char *, int, int, struct WS(sockaddr) *, int *);
-#ifdef WS_DEFINE_SELECT
-int WINAPI WS(select)(int, WS(fd_set) *, WS(fd_set) *, WS(fd_set) *, const struct WS(timeval) *);
-#endif
-int WINAPI WS(send)(SOCKET, const char *, int, int);
-int WINAPI WS(sendto)(SOCKET, const char *, int, int, const struct WS(sockaddr) *, int);
-int WINAPI WS(setsockopt)(SOCKET, int, int, const char *, int);
-int WINAPI WS(shutdown)(SOCKET, int);
-SOCKET WINAPI WS(socket)(int, int, int);
+int WINAPI getpeername(SOCKET s, struct sockaddr *addr, int *len);
+struct protoent * WINAPI getprotobyname(const char *name);
+struct protoent * WINAPI getprotobynumber(int number);
+struct servent * WINAPI getservbyname(const char *name, const char *protocol);
+struct servent * WINAPI getservbyport(int port, const char *protocol);
+int WINAPI getsockname(SOCKET s, struct sockaddr *addr, int *len);
+int WINAPI getsockopt(SOCKET s, int level, int name, char *value, int *len);
+ULONG WINAPI inet_addr(const char *addr);
+char * WINAPI inet_ntoa(struct in_addr addr);
+int WINAPI ioctlsocket(SOCKET s, LONG cmd, u_long *argp);
+int WINAPI listen(SOCKET s, int backlog);
+int WINAPI recv(SOCKET s, char *buffer, int size, int flags);
+int WINAPI recvfrom(SOCKET s, char *buffer, int size, int flags, struct sockaddr *addr, int *addr_len);
+int WINAPI select(int unused, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout);
+int WINAPI send(SOCKET s, const char *buffer, int size, int flags);
+int WINAPI sendto(SOCKET s, const char *buffer, int size, int flags, const struct sockaddr *addr, int addr_len);
+int WINAPI setsockopt(SOCKET s, int level, int name, const char *value, int len);
+int WINAPI shutdown(SOCKET s, int how);
+SOCKET WINAPI socket(int family, int type, int protocol);
+
+#endif /* USE_WS_PREFIX */
 
 int WINAPI GetHostNameW(WCHAR *, int);
 SOCKET WINAPI WSAAccept(SOCKET,struct WS(sockaddr)*,LPINT,LPCONDITIONPROC,DWORD_PTR);
-- 
2.34.1




More information about the wine-devel mailing list