From: Christopher Dykes Date: Thu, 4 Aug 2016 22:44:27 +0000 (-0700) Subject: Add a couple more things to the socket portability layer X-Git-Tag: v2016.08.08.00~12 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=242e3da1ad184bd221bdfa5e10f5903fbf8dda6b;p=folly.git Add a couple more things to the socket portability layer Summary: To make it possible for things to actually compile, this adds `socketpair` and the `sockaddr_un` struct, and also removes the `FOLLY_HAVE_UNIX_SOCKETS` define, as it is no longer needed. Reviewed By: yfeldblum Differential Revision: D3671158 fbshipit-source-id: 7333470f2e85c24edb935be5e1b94b4edc6e7267 --- diff --git a/folly/portability/Sockets.cpp b/folly/portability/Sockets.cpp index d96091cb..928573d3 100755 --- a/folly/portability/Sockets.cpp +++ b/folly/portability/Sockets.cpp @@ -307,6 +307,11 @@ int shutdown(int s, int how) { int socket(int af, int type, int protocol) { return socket_to_fd(::socket(af, type, protocol)); } + +int socketpair(int domain, int type, int protocol, int sv[2]) { + // Stub this out for now, to get things compiling. + return -1; +} } } } diff --git a/folly/portability/Sockets.h b/folly/portability/Sockets.h index de0db0ac..dcabc13f 100755 --- a/folly/portability/Sockets.h +++ b/folly/portability/Sockets.h @@ -16,12 +16,6 @@ #pragma once -#ifdef _WIN32 -#define FOLLY_HAVE_UNIX_SOCKETS 0 -#else -#define FOLLY_HAVE_UNIX_SOCKETS 1 -#endif - #ifndef _WIN32 #include #include @@ -38,6 +32,9 @@ #include +using nfds_t = int; +using sa_family_t = ADDRESS_FAMILY; + // We don't actually support either of these flags // currently. #define MSG_DONTWAIT 1 @@ -52,14 +49,19 @@ struct msghdr { int msg_flags; }; +struct sockaddr_un { + sa_family_t sun_family; + char sun_path[108]; +}; + #define SHUT_RD SD_RECEIVE #define SHUT_WR SD_SEND #define SHUT_RDWR SD_BOTH -using nfds_t = int; +// These are the same, but PF_LOCAL +// isn't defined by WinSock. +#define PF_LOCAL PF_UNIX -// This is named differently in posix. -#define sa_family_t ADDRESS_FAMILY // Someone thought it would be a good idea // to define a field via a macro... #undef s_host @@ -96,6 +98,7 @@ int socket_to_fd(SOCKET s); // implement. int accept(int s, struct sockaddr* addr, socklen_t* addrlen); int inet_aton(const char* cp, struct in_addr* inp); +int socketpair(int domain, int type, int protocol, int sv[2]); // Unless you have a case where you would normally have // to reference the function as being explicitly in the