summaryrefslogtreecommitdiff
path: root/shared/net_compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'shared/net_compat.h')
-rw-r--r--shared/net_compat.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/shared/net_compat.h b/shared/net_compat.h
index 5e63e04..65fa46d 100644
--- a/shared/net_compat.h
+++ b/shared/net_compat.h
@@ -2,6 +2,9 @@
#pragma once
#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOGDI
+#define NOUSER
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
@@ -41,13 +44,20 @@
ioctlsocket(s, FIONBIO, &mode);
}
+ #include <windows.h>
+ static inline void sleep_us(int microseconds) {
+ Sleep(microseconds / 1000); // Windows uses milliseconds
+ }
+
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <err.h>
#include <errno.h>
- #include <fcntl.h>
+#include <fcntl.h>
+#include <arpa/inet.h>
+
static inline void net_init(void) {} // no-op on POSIX
static inline void net_cleanup(void) {} // no-op on POSIX
@@ -55,6 +65,10 @@
fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK);
}
+ static inline void sleep_us(int microseconds) {
+ usleep(microseconds);
+ }
+
static inline int net_errno(void) { return errno; }
#define NET_EAGAIN EAGAIN
#define NET_EINTR EINTR