]> git.meshlink.io Git - catta/blobdiff - src/compat/windows/wincompat.h
wrap lifetimes of CattaServer and CattaSimplePoll in WSAStartup/WSACleanup
[catta] / src / compat / windows / wincompat.h
index b5020226a8e5465ea406bc56105e3d61a7fdd0c9..de3396c2a62bc08665c9212812a1305d51636710 100644 (file)
 #include <mswsock.h>
 
 
+// wrappers around WSAStartup/WSACleanup to avoid clutter
+void winsock_init(void);
+void winsock_exit(void);
+
+
 // Winsock doesn't have recvmsg/sendmsg but offers the same functionality
 // with WSARecvMsg/WSASendMsg, so we implement the former in terms of the
 // latter.
@@ -83,6 +88,14 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
 int ioctl(int d, unsigned long request, int *p);
 
 
+// Windows lacks poll, but WSAPoll is good enough for us.
+#define poll(fds, nfds, timeout) WSAPoll(fds, nfds, timeout)
+
+// Windows lacks pipe. It has an equivalent CreatePipe but we really need
+// something to give to WSAPoll, so we fake it with a local TCP socket. (ugh)
+int pipe(int pipefd[2]);
+
+
 // Windows logically doesn't have uname, so we supply a replacement.
 
 struct utsname {