diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-03-06 18:04:13 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-03-06 18:04:13 +0100 |
commit | 30b78bc2f4f7b74574abfbb3a3c2dc04686d2e7d (patch) | |
tree | 6350a96f7d9fbc487bf2604e5d90ab2a31384d4b /win | |
parent | 11b10ac8a4193e6804778a3284945ce0828be4c1 (diff) | |
parent | 56b7e9f8bf32824e0725005fcd0d2fa14a4ce088 (diff) |
Merge branch 'master+writev'
Diffstat (limited to 'win')
-rw-r--r-- | win/inspircd_win32wrapper.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h index a19bdf857..2218d9300 100644 --- a/win/inspircd_win32wrapper.h +++ b/win/inspircd_win32wrapper.h @@ -199,8 +199,6 @@ CoreExport void closedir(DIR * handle); void * ::operator new(size_t iSize); void ::operator delete(void * ptr); -#define DISABLE_WRITEV - #include <exception> class CWin32Exception : public std::exception @@ -218,3 +216,27 @@ private: // Same value as EXIT_STATUS_FORK (EXIT_STATUS_FORK is unused on Windows) #define EXIT_STATUS_SERVICE 4 + +// POSIX iovec +struct iovec +{ + void* iov_base; // Starting address + size_t iov_len; // Number of bytes to transfer +}; + +// Windows WSABUF with POSIX field names +struct WindowsIOVec +{ + // POSIX iovec has iov_base then iov_len, WSABUF in Windows has the fields in reverse order + u_long iov_len; // Number of bytes to transfer + char FAR* iov_base; // Starting address +}; + +inline ssize_t writev(int fd, const WindowsIOVec* iov, int count) +{ + DWORD sent; + int ret = WSASend(fd, reinterpret_cast<LPWSABUF>(const_cast<WindowsIOVec*>(iov)), count, &sent, 0, NULL, NULL); + if (ret == 0) + return sent; + return -1; +} |