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 | |
parent | record: Add generic record events (diff) | |
download | rtems-tools-a2e7158792f88d8b2734ecfb3424cb873ff43083.tar.bz2 |
record: Windows compatibility
Update #3665.
Diffstat (limited to 'trace')
-rw-r--r-- | trace/record/record-client-base.cc | 19 | ||||
-rw-r--r-- | trace/wscript | 9 |
2 files changed, 22 insertions, 6 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 + "'"); } diff --git a/trace/wscript b/trace/wscript index 9bac9b9..a2124ad 100644 --- a/trace/wscript +++ b/trace/wscript @@ -33,6 +33,7 @@ def options(opt): def configure(conf): conf.load('compiler_c') conf.load('compiler_cxx') + conf.check_cxx(lib = 'ws2_32', mandatory=False) def build(bld): # @@ -46,7 +47,10 @@ def build(bld): conf['warningflags'] = ['-Wall', '-Wextra', '-pedantic'] conf['optflags'] = bld.env.C_OPTS conf['cflags'] = ['-pipe', '-g'] + conf['optflags'] - conf['linkflags'] = ['-g'] + conf['cxxflags'] = ['-std=c++11'] + conf['cflags'] + conf['lib'] = [] + if bld.env.LIB_WS2_32: + conf['lib'].extend(bld.env.LIB_WS2_32) # # The list of defines @@ -65,7 +69,8 @@ def build(bld): includes = ['record'], defines = defines, cflags = conf['cflags'] + conf['warningflags'], - linkflags = conf['linkflags']) + cxxflags = conf['cxxflags'] + conf['warningflags'], + lib = conf['lib']) def tags(ctx): ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True) |