]> 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 f76dbc4835a1012160d863060f2928dda145ce82..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.
@@ -77,6 +82,20 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
 #endif
 
 
+// Windows doesn't have ioctl but offers ioctlsocket for some socket-related
+// functions. Unfortunately, argument types differ, so we implement a
+// (restricted) wrapper.
+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 {