summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-09-09 22:19:40 +0800
committerJohn Hodge <tpg@mutabah.net>2018-09-09 22:20:32 +0800
commitd85ac84278fa0322f1df0b16a45a1cdde83cba57 (patch)
tree66bad02a3c0bb9144e629d2ac8294b58430ff4ef /tools
parentdd4e3c887fa2eef2db6fa2795d4283636a1cc26e (diff)
downloadmrust-d85ac84278fa0322f1df0b16a45a1cdde83cba57.tar.gz
Msvc compile fixes
Diffstat (limited to 'tools')
-rw-r--r--tools/minicargo/build.cpp2
-rw-r--r--tools/minicargo/main.cpp1
-rw-r--r--tools/standalone_miri/miri.cpp34
-rw-r--r--tools/standalone_miri/value.cpp10
-rw-r--r--tools/testrunner/main.cpp6
5 files changed, 34 insertions, 19 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp
index 2f8fafe4..35c64f3b 100644
--- a/tools/minicargo/build.cpp
+++ b/tools/minicargo/build.cpp
@@ -945,7 +945,7 @@ bool Builder::spawn_process(const char* exe_name, const StringList& args, const
auto cmdline_str = cmdline.str();
if(true)
{
- ::std::cout << "> " << cmdline_str << ::std::end;;
+ ::std::cout << "> " << cmdline_str << ::std::endl;
}
else
{
diff --git a/tools/minicargo/main.cpp b/tools/minicargo/main.cpp
index b96a8a03..d7312d48 100644
--- a/tools/minicargo/main.cpp
+++ b/tools/minicargo/main.cpp
@@ -5,6 +5,7 @@
* main.cpp
* - Entrypoint
*/
+#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring> // strcmp
#include <map>
diff --git a/tools/standalone_miri/miri.cpp b/tools/standalone_miri/miri.cpp
index f4179b5d..8231f2c5 100644
--- a/tools/standalone_miri/miri.cpp
+++ b/tools/standalone_miri/miri.cpp
@@ -12,6 +12,7 @@
#include <iomanip>
#include "debug.hpp"
#include "miri.hpp"
+#include <cstring> // memrchr
#ifdef _WIN32
# define NOMINMAX
# include <Windows.h>
@@ -953,10 +954,10 @@ bool InterpreterThread::step_one(Value& out_thread_result)
int res = 0;
// TODO: Handle comparison of the relocations too
- const auto& alloc_l = v_l.m_value ? v_l.m_value->allocation : v_l.m_alloc;
- const auto& alloc_r = v_r.m_value ? v_r.m_value->allocation : v_r.m_alloc;
- auto reloc_l = alloc_l ? v_l.get_relocation(v_l.m_offset) : RelocationPtr();
- auto reloc_r = alloc_r ? v_r.get_relocation(v_r.m_offset) : RelocationPtr();
+ //const auto& alloc_l = v_l.m_value ? v_l.m_value->allocation : v_l.m_alloc;
+ //const auto& alloc_r = v_r.m_value ? v_r.m_value->allocation : v_r.m_alloc;
+ auto reloc_l = /*alloc_l ? */v_l.get_relocation(v_l.m_offset)/* : RelocationPtr()*/;
+ auto reloc_r = /*alloc_r ? */v_r.get_relocation(v_r.m_offset)/* : RelocationPtr()*/;
if( reloc_l != reloc_r )
{
@@ -1578,10 +1579,23 @@ bool InterpreterThread::call_path(Value& ret, const ::HIR::Path& path, ::std::ve
return false;
}
+#ifdef _WIN32
+const char* memrchr(const void* p, int c, size_t s) {
+ const char* p2 = reinterpret_cast<const char*>(p);
+ while( s > 0 )
+ {
+ s -= 1;
+ if( p2[s] == c )
+ return &p2[s];
+ }
+ return nullptr;
+}
+#else
extern "C" {
long sysconf(int);
ssize_t write(int, const void*, size_t);
}
+#endif
bool InterpreterThread::call_extern(Value& rv, const ::std::string& link_name, const ::std::string& abi, ::std::vector<Value> args)
{
if( link_name == "__rust_allocate" )
@@ -1673,8 +1687,8 @@ bool InterpreterThread::call_extern(Value& rv, const ::std::string& link_name, c
}
else if( link_name == "GetModuleHandleW" )
{
- LOG_ASSERT(args.at(0).allocation.is_alloc(), "");
- const auto& tgt_alloc = args.at(0).allocation.alloc().get_relocation(0);
+ LOG_ASSERT(args.at(0).allocation, "");
+ const auto& tgt_alloc = args.at(0).get_relocation(0);
const void* arg0 = (tgt_alloc ? tgt_alloc.alloc().data_ptr() : nullptr);
//extern void* GetModuleHandleW(const void* s);
if(arg0) {
@@ -1698,10 +1712,8 @@ bool InterpreterThread::call_extern(Value& rv, const ::std::string& link_name, c
}
else if( link_name == "GetProcAddress" )
{
- LOG_ASSERT(args.at(0).allocation.is_alloc(), "");
- const auto& handle_alloc = args.at(0).allocation.alloc().get_relocation(0);
- LOG_ASSERT(args.at(1).allocation.is_alloc(), "");
- const auto& sym_alloc = args.at(1).allocation.alloc().get_relocation(0);
+ const auto& handle_alloc = args.at(0).get_relocation(0);
+ const auto& sym_alloc = args.at(1).get_relocation(0);
// TODO: Ensure that first arg is a FFI pointer with offset+size of zero
void* handle = handle_alloc.ffi().ptr_value;
@@ -2204,7 +2216,7 @@ bool InterpreterThread::call_intrinsic(Value& rv, const ::std::string& name, con
LOG_ASSERT(src_ofs <= src_alloc.ffi().size, "");
LOG_ASSERT(byte_count <= src_alloc.ffi().size, "");
LOG_ASSERT(src_ofs + byte_count <= src_alloc.ffi().size, "");
- dst_alloc.alloc().write_bytes(dst_ofs, src_alloc.ffi().ptr_value + src_ofs, byte_count);
+ dst_alloc.alloc().write_bytes(dst_ofs, reinterpret_cast<const char*>(src_alloc.ffi().ptr_value) + src_ofs, byte_count);
break;
}
}
diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp
index cf378077..849d3a64 100644
--- a/tools/standalone_miri/value.cpp
+++ b/tools/standalone_miri/value.cpp
@@ -239,7 +239,7 @@ void* ValueCommonRead::read_pointer_unsafe(size_t rd_ofs, size_t req_valid, size
// TODO: Have an idea of mutability and available size from FFI
out_size = f.size - ofs;
out_is_mut = false;
- return reloc.ffi().ptr_value + ofs;
+ return reinterpret_cast<char*>(reloc.ffi().ptr_value) + ofs;
}
}
throw "";
@@ -607,22 +607,22 @@ Value Value::new_pointer(::HIR::TypeRef ty, uint64_t v, RelocationPtr r) {
return rv;
}
Value Value::new_usize(uint64_t v) {
- Value rv( ::HIR::TypeRef(RawType::USize) );
+ auto rv = Value( ::HIR::TypeRef(RawType::USize) );
rv.write_usize(0, v);
return rv;
}
Value Value::new_isize(int64_t v) {
- Value rv( ::HIR::TypeRef(RawType::ISize) );
+ auto rv = Value( ::HIR::TypeRef(RawType::ISize) );
rv.write_isize(0, v);
return rv;
}
Value Value::new_u32(uint32_t v) {
- Value rv( ::HIR::TypeRef(RawType::U32) );
+ auto rv = Value( ::HIR::TypeRef(RawType::U32) );
rv.write_u32(0, v);
return rv;
}
Value Value::new_i32(int32_t v) {
- Value rv( ::HIR::TypeRef(RawType::I32) );
+ auto rv = Value( ::HIR::TypeRef(RawType::I32) );
rv.write_i32(0, v);
return rv;
}
diff --git a/tools/testrunner/main.cpp b/tools/testrunner/main.cpp
index 4dafe508..5c21937d 100644
--- a/tools/testrunner/main.cpp
+++ b/tools/testrunner/main.cpp
@@ -520,9 +520,8 @@ bool run_executable(const ::helpers::path& exe_name, const ::std::vector<const c
STARTUPINFO si = { 0 };
si.cb = sizeof(si);
- si.dwFlags = STARTF_USESTDHANDLES;
+ si.dwFlags = STARTF_USESTDHANDLES|STARTF_FORCEOFFFEEDBACK;
si.hStdInput = NULL;
- si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
{
SECURITY_ATTRIBUTES sa = { 0 };
sa.nLength = sizeof(sa);
@@ -532,8 +531,11 @@ bool run_executable(const ::helpers::path& exe_name, const ::std::vector<const c
//WriteFile(si.hStdOutput, cmdline_str.data(), static_cast<DWORD>(cmdline_str.size()), &tmp, NULL);
//WriteFile(si.hStdOutput, "\n", 1, &tmp, NULL);
}
+ DuplicateHandle(NULL, si.hStdOutput, NULL, &si.hStdError, GENERIC_WRITE, FALSE, FILE_SHARE_READ);
PROCESS_INFORMATION pi = { 0 };
+ auto em = SetErrorMode(SEM_NOGPFAULTERRORBOX);
CreateProcessA(exe_name.str().c_str(), (LPSTR)cmdline_str.c_str(), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
+ SetErrorMode(em);
CloseHandle(si.hStdOutput);
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD status = 1;