Make socket shims inline

This commit is contained in:
Jeffrey Pfau 2014-02-05 01:22:34 -08:00
parent 924c6cf5a6
commit 043d396320
1 changed files with 8 additions and 8 deletions

View File

@ -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 @@ Socket SocketOpenTCP(int port, uint32_t bindAddress) {
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;