Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix use clang build nullptr_t error #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/eosio/vm/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ namespace eosio { namespace vm {
public:
using host_t = Host;

template <typename HostFunctions = nullptr_t>
template <typename HostFunctions = std::nullptr_t>
backend(wasm_code& code, HostFunctions = nullptr) : _ctx(typename Impl::template parser<Host>{ _mod.allocator }.parse_module(code, _mod)) {
if constexpr (!std::is_same_v<HostFunctions, nullptr_t>)
if constexpr (!std::is_same_v<HostFunctions, std::nullptr_t>)
HostFunctions::resolve(_mod);
_mod.finalize();
}
template <typename HostFunctions = nullptr_t>
template <typename HostFunctions = std::nullptr_t>
backend(wasm_code_ptr& ptr, size_t sz, HostFunctions = nullptr) : _ctx(typename Impl::template parser<Host>{ _mod.allocator }.parse_module2(ptr, sz, _mod)) {
if constexpr (!std::is_same_v<HostFunctions, nullptr_t>)
if constexpr (!std::is_same_v<HostFunctions, std::nullptr_t>)
HostFunctions::resolve(_mod);
_mod.finalize();
}
Expand Down
6 changes: 3 additions & 3 deletions include/eosio/vm/host_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace eosio { namespace vm {
};

template <typename Derived>
struct construct_derived<Derived, nullptr_t> {
static nullptr_t value(nullptr_t) { return nullptr; }
struct construct_derived<Derived, std::nullptr_t> {
static std::nullptr_t value(std::nullptr_t) { return nullptr; }
};

// Workaround for compiler bug handling C++g17 auto template parameters.
Expand Down Expand Up @@ -466,7 +466,7 @@ namespace eosio { namespace vm {

template<auto F, typename Derived, typename Host, typename... T>
decltype(auto) invoke_with_host(Host* host, T&&... args) {
if constexpr (std::is_same_v<Derived, nullptr_t>)
if constexpr (std::is_same_v<Derived, std::nullptr_t>)
return std::invoke(F, static_cast<T&&>(args)...);
else
return std::invoke(F, construct_derived<Derived, Host>::value(*host), static_cast<T&&>(args)...);
Expand Down
10 changes: 5 additions & 5 deletions include/eosio/vm/wasm_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
#include <eosio/vm/vector.hpp>

namespace eosio { namespace vm {
template <typename ElemT, size_t ElemSz, typename Allocator = nullptr_t >
template <typename ElemT, size_t ElemSz, typename Allocator = std::nullptr_t >
class stack {
public:
template <typename Alloc=Allocator, typename = std::enable_if_t<std::is_same_v<Alloc, nullptr_t>, int>>
template <typename Alloc=Allocator, typename = std::enable_if_t<std::is_same_v<Alloc, std::nullptr_t>, int>>
stack()
: _store(ElemSz) {}

template <typename Alloc=Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
template <typename Alloc=Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, std::nullptr_t>, int>>
stack(Alloc&& alloc)
: _store(alloc, ElemSz) {}

void push(ElemT&& e) {
if constexpr (std::is_same_v<Allocator, nullptr_t>) {
if constexpr (std::is_same_v<Allocator, std::nullptr_t>) {
if (_index >= _store.size())
_store.resize(_store.size()*2);
}
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace eosio { namespace vm {
size_t size() const { return _index; }

private:
using base_data_store_t = std::conditional_t<std::is_same_v<Allocator, nullptr_t>, unmanaged_vector<ElemT>, managed_vector<ElemT, Allocator>>;
using base_data_store_t = std::conditional_t<std::is_same_v<Allocator, std::nullptr_t>, unmanaged_vector<ElemT>, managed_vector<ElemT, Allocator>>;

base_data_store_t _store;
size_t _index = 0;
Expand Down
2 changes: 1 addition & 1 deletion tools/bench_interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace eosio::vm;

int main(int argc, char** argv) {
wasm_allocator wa;
using backend_t = eosio::vm::backend<nullptr_t>;
using backend_t = eosio::vm::backend<std::nullptr_t>;

if (argc < 2) {
std::cerr << "Error, no wasm file provided\n";
Expand Down
6 changes: 3 additions & 3 deletions tools/hello_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ int main(int argc, char** argv) {
using rhf_t = eosio::vm::registered_host_functions<example_host_methods>;

// register print_num
rhf_t::add<nullptr_t, &print_num, wasm_allocator>("env", "print_num");
rhf_t::add<std::nullptr_t, &print_num, wasm_allocator>("env", "print_num");
// register eosio_assert
rhf_t::add<nullptr_t, &eosio_assert, wasm_allocator>("env", "eosio_assert");
rhf_t::add<std::nullptr_t, &eosio_assert, wasm_allocator>("env", "eosio_assert");
// register print_name
rhf_t::add<example_host_methods, &example_host_methods::print_name, wasm_allocator>("env", "print_name");
// finally register memset
rhf_t::add<nullptr_t, &example_host_methods::memset, wasm_allocator>("env", "memset");
rhf_t::add<std::nullptr_t, &example_host_methods::memset, wasm_allocator>("env", "memset");

watchdog wd{std::chrono::seconds(3)};
try {
Expand Down
2 changes: 1 addition & 1 deletion tools/interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char** argv) {
// Thread specific `allocator` used for wasm linear memory.
wasm_allocator wa;
// Specific the backend with no "host" for host functions.
using backend_t = eosio::vm::backend<nullptr_t>;
using backend_t = eosio::vm::backend<std::nullptr_t>;

if (argc < 2) {
std::cerr << "Error, no wasm file provided\n";
Expand Down