summaryrefslogtreecommitdiff
path: root/src/win32/win32_socket.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/win32/win32_socket.h')
-rw-r--r--src/win32/win32_socket.h30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/win32/win32_socket.h b/src/win32/win32_socket.h
index 5f8f095..fb622f5 100644
--- a/src/win32/win32_socket.h
+++ b/src/win32/win32_socket.h
@@ -1,5 +1,7 @@
#if defined(_WIN32)
+#include <stdint.h>
+
#define _USE_W32_SOCKETS 1
#if defined(_MSC_VER)
@@ -20,7 +22,8 @@
#pragma warning(pop)
#endif
-/* winsock doesn't feature poll(), so there is a version implemented in terms of select() in win32_socket.c.
+/*
+ * winsock doesn't feature poll(), so there is a version implemented in terms of select() in win32_socket.c.
* The following definitions are copied from linux man pages.
* A poll() macro is defined to call the version in win32_socket.c.
*/
@@ -34,13 +37,14 @@
#define POLLNVAL 0x0020 /* Invalid request: fd not open */
struct pollfd {
SOCKET fd; /* file descriptor */
- short events; /* requested events */
- short revents; /* returned events */
+ int16_t events; /* requested events */
+ int16_t revents; /* returned events */
};
#endif
#define poll(x, y, z) win32_poll(x, y, z)
-/* These wrappers do nothing special except set the global errno variable if an error occurs
+/*
+ * These wrappers do nothing special except set the global errno variable if an error occurs
* (winsock doesn't do this by default).
* They set errno to unix-like values (i.e. WSAEWOULDBLOCK is mapped to EAGAIN),
* so code outside of this file "shouldn't" have to worry about winsock specific error handling.
@@ -52,15 +56,15 @@ struct pollfd {
#define read(x, y, z) win32_read_socket(x, y, z)
#define write(x, y, z) win32_write_socket(x, y, z)
-/* Winsock uses int instead of the usual socklen_t */
-typedef int socklen_t;
+/* Winsock uses int32_t instead of the usual socklen_t */
+typedef int32_t socklen_t;
-int win32_poll(struct pollfd *, unsigned int, int);
-SOCKET win32_socket(int, int, int);
-int win32_connect(SOCKET, struct sockaddr*, socklen_t);
+int32_t win32_poll(struct pollfd *, uint32_t, int32_t);
+SOCKET win32_socket(int32_t, int32_t, int32_t);
+int32_t win32_connect(SOCKET, struct sockaddr*, socklen_t);
SOCKET win32_accept(SOCKET, struct sockaddr*, socklen_t *);
-int win32_shutdown(SOCKET, int);
-int win32_close_socket(SOCKET fd);
+int32_t win32_shutdown(SOCKET, int32_t);
+int32_t win32_close_socket(SOCKET fd);
#define strtok_r(x, y, z) win32_strtok_r(x, y, z)
#define strsep(x,y) win32_strsep(x,y)
@@ -68,7 +72,7 @@ int win32_close_socket(SOCKET fd);
char *win32_strtok_r(char *s, const char *delim, char **lasts);
char *win32_strsep(char **stringp, const char *delim);
-ssize_t win32_read_socket(SOCKET fd, void *buf, int n);
-ssize_t win32_write_socket(SOCKET fd, void *buf, int n);
+ssize_t win32_read_socket(SOCKET fd, void *buf, int32_t n);
+ssize_t win32_write_socket(SOCKET fd, void *buf, int32_t n);
#endif // defined(_WIN32)