Make socket shims inline
Jeffrey Pfau jeffrey@endrift.com
Wed, 05 Feb 2014 01:22:34 -0800
1 files changed,
8 insertions(+),
8 deletions(-)
jump to
M
src/util/socket.h
→
src/util/socket.h
@@ -16,21 +16,21 @@ typedef int Socket;
#endif -void SocketSubsystemInitialize() { +static inline void SocketSubsystemInitialize() { #ifdef _WIN32 WSAStartup(MAKEWORD(2, 2), 0); #endif } -ssize_t SocketSend(Socket socket, const void* buffer, size_t size) { +static inline ssize_t SocketSend(Socket socket, const void* buffer, size_t size) { return write(socket, buffer, size); } -ssize_t SocketRecv(Socket socket, void* buffer, size_t size) { +static inline ssize_t SocketRecv(Socket socket, void* buffer, size_t size) { return read(socket, buffer, size); } -Socket SocketOpenTCP(int port, uint32_t bindAddress) { +static inline Socket SocketOpenTCP(int port, uint32_t bindAddress) { Socket sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { return sock;@@ -51,19 +51,19 @@ }
return sock; } -Socket SocketListen(Socket socket, int queueLength) { +static inline Socket SocketListen(Socket socket, int queueLength) { return listen(socket, queueLength); } -Socket SocketAccept(Socket socket, struct sockaddr* restrict address, socklen_t* restrict addressLength) { +static inline Socket SocketAccept(Socket socket, struct sockaddr* restrict address, socklen_t* restrict addressLength) { return accept(socket, address, addressLength); } -int SocketClose(Socket socket) { +static inline int SocketClose(Socket socket) { return close(socket) >= 0; } -int SocketSetBlocking(Socket socket, int blocking) { +static inline int SocketSetBlocking(Socket socket, int blocking) { #ifdef _WIN32 blocking = !blocking; return ioctlsocket(socket, FIONBIO, &blocking) == NO_ERROR;