all repos — mgba @ 043d396320cf21acdaf507de80673c1e8528d3f3

mGBA Game Boy Advance Emulator

Make socket shims inline
Jeffrey Pfau jeffrey@endrift.com
Wed, 05 Feb 2014 01:22:34 -0800
commit

043d396320cf21acdaf507de80673c1e8528d3f3

parent

924c6cf5a63528484be1d03676e09456d5fb5bc5

1 files changed, 8 insertions(+), 8 deletions(-)

jump to
M src/util/socket.hsrc/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;