From 976a4b7330cccf57533229a8185e1aacedbbb12a Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 5 Dec 2014 13:21:14 +1100 Subject: [PATCH] socket: explain and relax type casting requirement The recv/send functions (and the assertions) were only tested under 32bit systems. They need relaxing for 64bit. --- net/socket.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/socket.cpp b/net/socket.cpp index 139c5574..7e4cb076 100644 --- a/net/socket.cpp +++ b/net/socket.cpp @@ -52,8 +52,12 @@ socket_domain::socket_domain (socket_t _fd): // TODO: Make this not retarded. Fucking Windows. #define dup(X) (X) - static_assert(sizeof(int) == sizeof(ssize_t), "int != ssize_t"); - static_assert(sizeof(int) == sizeof( size_t), "int != size_t"); + // Winsock has incorrect return and parameter types (according to POSIX) + // so we need some wrappers around the system implementations that casts + // to expected types. Mainly int vs ssize_t returns, and int vs size_t + // parameters. + static_assert(sizeof(int) <= sizeof(ssize_t), "int != ssize_t"); + static_assert(sizeof(int) <= sizeof( size_t), "int != size_t"); ssize_t recv(socket_t _socket, void *_buf, size_t _len, int _flags) { return (ssize_t)::recv(_socket, (char*)_buf, (int)_len, _flags); }