mirror of https://github.com/mgba-emu/mgba.git
Make socket shims inline
This commit is contained in:
parent
924c6cf5a6
commit
043d396320
|
@ -16,21 +16,21 @@ typedef int Socket;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void SocketSubsystemInitialize() {
|
static inline void SocketSubsystemInitialize() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSAStartup(MAKEWORD(2, 2), 0);
|
WSAStartup(MAKEWORD(2, 2), 0);
|
||||||
#endif
|
#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);
|
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);
|
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);
|
Socket sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
return sock;
|
return sock;
|
||||||
|
@ -51,19 +51,19 @@ Socket SocketOpenTCP(int port, uint32_t bindAddress) {
|
||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
Socket SocketListen(Socket socket, int queueLength) {
|
static inline Socket SocketListen(Socket socket, int queueLength) {
|
||||||
return listen(socket, 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);
|
return accept(socket, address, addressLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketClose(Socket socket) {
|
static inline int SocketClose(Socket socket) {
|
||||||
return close(socket) >= 0;
|
return close(socket) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SocketSetBlocking(Socket socket, int blocking) {
|
static inline int SocketSetBlocking(Socket socket, int blocking) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
blocking = !blocking;
|
blocking = !blocking;
|
||||||
return ioctlsocket(socket, FIONBIO, &blocking) == NO_ERROR;
|
return ioctlsocket(socket, FIONBIO, &blocking) == NO_ERROR;
|
||||||
|
|
Loading…
Reference in New Issue