diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-09-10 10:04:51 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-09-10 10:54:28 +0200 |
commit | a2e7158792f88d8b2734ecfb3424cb873ff43083 (patch) | |
tree | 78e17c36b5e4c865229f19832618b7b34ffe7a39 /trace/record | |
parent | record: Add generic record events (diff) | |
download | rtems-tools-a2e7158792f88d8b2734ecfb3424cb873ff43083.tar.bz2 |
record: Windows compatibility
Update #3665.
Diffstat (limited to 'trace/record')
-rw-r--r-- | trace/record/record-client-base.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/trace/record/record-client-base.cc b/trace/record/record-client-base.cc index 01ed803..ac88eab 100644 --- a/trace/record/record-client-base.cc +++ b/trace/record/record-client-base.cc @@ -27,12 +27,18 @@ #include "client.h" +#ifdef _WIN32 +#include <io.h> +#include <winsock2.h> +#else #include <arpa/inet.h> -#include <fcntl.h> #include <netinet/in.h> #include <sys/socket.h> -#include <sys/stat.h> #include <unistd.h> +#endif + +#include <fcntl.h> +#include <sys/stat.h> #include <cassert> #include <cstring> @@ -42,13 +48,18 @@ static ssize_t ReadFile(int fd, void* buf, size_t n) { } static ssize_t ReadSocket(int fd, void* buf, size_t n) { - return ::recv(fd, buf, n, 0); + // This cast is necessary for Windows + return ::recv(fd, static_cast<char*>(buf), n, 0); } void FileDescriptor::Open(const char* file) { assert(fd_ == -1); - fd_ = ::open(file, O_RDONLY); + int oflag = O_RDONLY; +#ifdef _WIN32 + oflag |= O_BINARY; +#endif + fd_ = ::open(file, oflag); if (fd_ < 0) { throw ErrnoException(std::string("cannot open file '") + file + "'"); } |