From 6f6e77f85f6ff93a3f898603157b54b6132662a1 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 8 Sep 2013 19:48:44 -0600 Subject: [PATCH] Windows: document the purpose and use of Squid namespace wrappers Also, add some missing #define's This is an iCelero project --- compat/os/mswindows.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compat/os/mswindows.h b/compat/os/mswindows.h index a31c36af0d..95edff63e5 100644 --- a/compat/os/mswindows.h +++ b/compat/os/mswindows.h @@ -474,6 +474,18 @@ namespace Squid { /** \endcond */ +/* + * Each of these functions is defined in the Squid namespace so as not to + * clash with the winsock.h and winsock2.h definitions. + * It is then paired with a #define to cause these wrappers to be used by + * the main code instead of those system definitions. + * + * We do this wrapper in order to: + * - cast the parameter types in only one place, and + * - record errors in POSIX errno variable, and + * - map the FD value used by Squid to the socket handes used by Windows. + */ + inline int accept(int s, struct sockaddr * a, socklen_t * l) { @@ -725,6 +737,7 @@ WSAAsyncSelect(int s, HWND h, unsigned int w, long e) } else return 0; } +#define WSAAsyncSelect(s,h,w,e) Squid::WSAAsyncSelect(s,h,w,e) #undef WSADuplicateSocket inline int @@ -740,6 +753,7 @@ WSADuplicateSocket(int s, DWORD n, LPWSAPROTOCOL_INFO l) } else return 0; } +#define WSADuplicateSocket(s,n,l) Squid::WSADuplicateSocket(s,n,l) #undef WSASocket inline int @@ -757,6 +771,7 @@ WSASocket(int a, int t, int p, LPWSAPROTOCOL_INFO i, GROUP g, DWORD f) } else return _open_osfhandle(result, 0); } +#define WSASocket(a,t,p,i,g,f) Squid::WSASocket(a,t,p,i,g,f) } /* namespace Squid */ -- 2.47.2