X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8b0d5ae29ebd13e69a23991b8adfb67c5c5d79d3..d6eb772e45cc853fc204bb5aebeb411cdfa7c929:/src/mc/remote/RemotePtr.hpp diff --git a/src/mc/remote/RemotePtr.hpp b/src/mc/remote/RemotePtr.hpp index f7a87ca1e1..29007105d3 100644 --- a/src/mc/remote/RemotePtr.hpp +++ b/src/mc/remote/RemotePtr.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2008-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -6,10 +6,9 @@ #ifndef SIMGRID_MC_REMOTE_PTR_HPP #define SIMGRID_MC_REMOTE_PTR_HPP -#include "src/simix/smx_private.hpp" +#include "src/kernel/actor/ActorImpl.hpp" -namespace simgrid { -namespace mc { +namespace simgrid::mc { /** HACK, A value from another process * @@ -27,19 +26,19 @@ namespace mc { */ template class Remote { private: - typename std::aligned_storage::type buffer; + typename std::aligned_storage_t buffer; public: Remote() = default; explicit Remote(T const& p) { std::memcpy(&buffer, &p, sizeof buffer); } - T* getBuffer() { return reinterpret_cast(&buffer); } - const T* getBuffer() const { return reinterpret_cast(&buffer); } - std::size_t getBufferSize() const { return sizeof(T); } + T* get_buffer() { return reinterpret_cast(&buffer); } + const T* get_buffer() const { return reinterpret_cast(&buffer); } + std::size_t get_buffer_size() const { return sizeof(T); } operator T() const { static_assert(std::is_trivial::value, "Cannot convert non trivial type"); - return *getBuffer(); + return *get_buffer(); } void clear() { std::memset(&buffer, 0, sizeof buffer); } }; @@ -59,14 +58,14 @@ public: * as a `uint64_t`. */ template class RemotePtr { - std::uint64_t address_; + std::uint64_t address_ = 0; public: - RemotePtr() : address_(0) {} - explicit RemotePtr(std::nullptr_t) : address_(0) {} + RemotePtr() = default; + explicit RemotePtr(std::nullptr_t) {} explicit RemotePtr(std::uint64_t address) : address_(address) {} explicit RemotePtr(T* address) : address_((std::uintptr_t)address) {} - explicit RemotePtr(Remote p) : address_((std::uintptr_t)*p.getBuffer()) {} + explicit RemotePtr(Remote p) : address_((std::uintptr_t)*p.get_buffer()) {} std::uint64_t address() const { return address_; } /** Turn into a local pointer @@ -135,7 +134,6 @@ template inline RemotePtr remote(uint64_t p) { return RemotePtr(p); } -} -} +} // namespace simgrid::mc #endif