diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/BString.cc | 2 | ||||
| -rw-r--r-- | src/Exceptions.cc | 11 | ||||
| -rw-r--r-- | src/Handle.cc | 9 | ||||
| -rw-r--r-- | src/Input.cc | 15 | ||||
| -rw-r--r-- | src/Output.cc | 15 | ||||
| -rw-r--r-- | src/Task.cc | 2 | ||||
| -rw-r--r-- | src/TaskMan.cc | 4 | 
7 files changed, 51 insertions, 7 deletions
diff --git a/src/BString.cc b/src/BString.cc index bf7b4e3..57febcd 100644 --- a/src/BString.cc +++ b/src/BString.cc @@ -63,7 +63,7 @@ Balau::String & Balau::String::do_rtrim() {              break;      if ((i == 0) && isspace(buffer[0])) -        assign("", 0); +        clear();      else          erase(p); diff --git a/src/Exceptions.cc b/src/Exceptions.cc index a9df9e6..b4646ce 100644 --- a/src/Exceptions.cc +++ b/src/Exceptions.cc @@ -27,11 +27,16 @@ void Balau::GeneralException::genTrace() {      for (i = 0; i < frames; i++) {          SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); -        int status; +        int status = 0;          String line; +#ifndef _MSC_VER          char * demangled = abi::__cxa_demangle(symbol->Name, 0, 0, &status); -        line.set("%i: 0x%08x (%s)", i, symbol->Address, status == 0 ? demangled : symbol->Name); -        free(demangled); +#else +		char * demangled = NULL; +#endif +		line.set("%i: 0x%08x (%s)", i, symbol->Address, status == 0 && demangled ? demangled : symbol->Name); +		if (demangled) +	        free(demangled);          m_trace.push_back(line);      } diff --git a/src/Handle.cc b/src/Handle.cc index 1a5255d..3b40c84 100644 --- a/src/Handle.cc +++ b/src/Handle.cc @@ -8,6 +8,11 @@  #include "Printer.h"  #include "Async.h" +#ifdef _MSC_VER +#include <direct.h> +typedef int mode_t; +#endif +  #ifdef _WIN32  static const char * strerror_r(int errorno, char * buf, size_t bufsize) {  #ifdef _MSVC @@ -237,7 +242,11 @@ class AsyncOpMkdir : public Balau::AsyncOperation {    public:        AsyncOpMkdir(const char * path, mode_t mode, cbResults_t * results) : m_path(path), m_mode(mode), m_results(results) { }      virtual void run() { +#ifdef _MSC_VER +        int r = m_results->result = mkdir(m_path); +#else          int r = m_results->result = mkdir(m_path, m_mode); +#endif          m_results->errorno = r < 0 ? errno : 0;      }      virtual void done() { diff --git a/src/Input.cc b/src/Input.cc index 481545e..c1b7b98 100644 --- a/src/Input.cc +++ b/src/Input.cc @@ -3,7 +3,11 @@  #include <sys/types.h>  #include <sys/stat.h>  #include <fcntl.h> +#ifndef _MSC_VER  #include <unistd.h> +#else +#include <io.h> +#endif  #include "Async.h"  #include "Input.h"  #include "Task.h" @@ -35,7 +39,11 @@ class AsyncOpOpen : public Balau::AsyncOperation {    public:        AsyncOpOpen(const char * path, cbResults_t * results) : m_path(path), m_results(results) { }      virtual void run() { +#ifdef _MSC_VER +        const ssize_t r = m_results->result = _open(m_path, O_RDONLY); +#else          const ssize_t r = m_results->result = open(m_path, O_RDONLY); +#endif          m_results->errorno = r < 0 ? errno : 0;      }      virtual void done() { @@ -182,7 +190,7 @@ void Balau::Input::close() throw (GeneralException) {              m_fd = -1;              if (cbResults->result < 0) {                  char buf[4096]; -                char * str = strerror_r(cbResults->errorno, buf, sizeof(buf)); +                const char * str = strerror_r(cbResults->errorno, buf, sizeof(buf));                  throw GeneralException(String("Unable to close file ") + m_name + ": " + str);              }              delete cbResults; @@ -211,7 +219,12 @@ class AsyncOpRead : public Balau::AsyncOperation {    public:        AsyncOpRead(int fd, void * buf, size_t count, off_t offset, cbResults_t * results) : m_fd(fd), m_buf(buf), m_count(count), m_offset(offset), m_results(results) { }      virtual void run() { +#ifdef _MSC_VER +        IAssert(0, "Not yet implemented"); +        const ssize_t r = 0; +#else          const ssize_t r = m_results->result = pread(m_fd, m_buf, m_count, m_offset); +#endif          m_results->errorno = r < 0 ? errno : 0;      }      virtual void done() { diff --git a/src/Output.cc b/src/Output.cc index 03c0d6e..261884e 100644 --- a/src/Output.cc +++ b/src/Output.cc @@ -3,7 +3,11 @@  #include <sys/types.h>  #include <sys/stat.h>  #include <fcntl.h> +#ifndef _MSC_VER  #include <unistd.h> +#else +#include <io.h> +#endif  #include "Async.h"  #include "Output.h"  #include "Task.h" @@ -35,7 +39,11 @@ class AsyncOpOpen : public Balau::AsyncOperation {    public:        AsyncOpOpen(const char * path, bool truncate, cbResults_t * results) : m_path(path), m_truncate(truncate), m_results(results) { }      virtual void run() { +#ifdef _MSC_VER +        const ssize_t r = m_results->result = _open(m_path, O_WRONLY | O_CREAT | (m_truncate ? O_TRUNC : 0), 0755); +#else          const ssize_t r = m_results->result = open(m_path, O_WRONLY | O_CREAT | (m_truncate ? O_TRUNC : 0), 0755); +#endif          m_results->errorno = r < 0 ? errno : 0;      }      virtual void done() { @@ -182,7 +190,7 @@ void Balau::Output::close() throw (GeneralException) {              m_fd = -1;              if (cbResults->result < 0) {                  char buf[4096]; -                char * str = strerror_r(cbResults->errorno, buf, sizeof(buf)); +                const char * str = strerror_r(cbResults->errorno, buf, sizeof(buf));                  throw GeneralException(String("Unable to close file ") + m_name + ": " + str);              }              delete cbResults; @@ -211,7 +219,12 @@ class AsyncOpWrite : public Balau::AsyncOperation {    public:        AsyncOpWrite(int fd, const void * buf, size_t count, off_t offset, cbResults_t * results) : m_fd(fd), m_buf(buf), m_count(count), m_offset(offset), m_results(results) { }      virtual void run() { +#ifdef _MSC_VER +        IAssert(0, "Not yet implemented"); +        const ssize_t r = 0; +#else          const ssize_t r = m_results->result = pwrite(m_fd, m_buf, m_count, m_offset); +#endif          m_results->errorno = r < 0 ? errno : 0;      }      virtual void done() { diff --git a/src/Task.cc b/src/Task.cc index b294fa9..9bf7c5b 100644 --- a/src/Task.cc +++ b/src/Task.cc @@ -30,7 +30,7 @@ void Balau::Task::setup(TaskMan * taskMan, void * stack) {          m_stack = stack;          coro_create(&m_ctx, coroutineTrampoline, this, m_stack, size);  #else -        Assert(!stack, "We shouldn't allocate stacks with Fibers"); +        IAssert(!stack, "We shouldn't allocate stacks with Fibers");          m_stack = NULL;          m_fiber = CreateFiber(size, coroutineTrampoline, this);  #endif diff --git a/src/TaskMan.cc b/src/TaskMan.cc index 71d5bc6..03801a3 100644 --- a/src/TaskMan.cc +++ b/src/TaskMan.cc @@ -5,6 +5,10 @@  #include "Main.h"  #include "Local.h" +#ifdef _MSC_VER +#include <Windows.h> +#endif +  static Balau::AsyncManager s_async;  namespace {  | 
