1 /* Copyright (c) 2008-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef MC_ADDRESS_SPACE_H
8 #define MC_ADDRESS_SPACE_H
11 #include <type_traits>
17 #include "mc_forward.h"
19 // Compatibility stuff, will be removed:
20 #define MC_ADDRESS_SPACE_READ_FLAGS_NONE ::simgrid::mc::AddressSpace::Normal
21 #define MC_ADDRESS_SPACE_READ_FLAGS_LAZY ::simgrid::mc::AddressSpace::Lazy
23 // Compatibility stuff, will be removed:
24 #define MC_PROCESS_INDEX_MISSING ::simgrid::mc::ProcessIndexMissing
25 #define MC_PROCESS_INDEX_DISABLED ::simgrid::mc::ProcessIndexDisabled
26 #define MC_PROCESS_INDEX_ANY ::simgrid::mc::ProcessIndexAny
31 /** Process index used when no process is available
33 * The expected behaviour is that if a process index is needed it will fail.
35 const int ProcessIndexMissing = -1;
37 /** Process index used when we don't care about the process index
39 const int ProcessIndexDisabled = -2;
41 /** Constant used when any process will do.
43 * This is is index of the first process.
45 const int ProcessIndexAny = 0;
51 /** Allows the `read_bytes` to return a pointer to another buffer
52 * where the data ins available instead of copying the data into the buffer
56 virtual ~AddressSpace();
57 virtual const void* read_bytes(void* buffer, std::size_t size,
58 std::uint64_t address, int process_index = ProcessIndexAny,
59 ReadMode mode = Normal) = 0;
61 T read(uint64_t address, int process_index = ProcessIndexMissing)
63 static_assert(std::is_trivial<T>::value, "Cannot read a non-trivial type");
65 this->read_bytes(&res, sizeof(T), address, process_index);
73 // Deprecated compatibility wrapper:
75 const void* MC_address_space_read(
76 mc_address_space_t address_space, simgrid::mc::AddressSpace::ReadMode mode,
77 void* target, const void* addr, size_t size,
80 return address_space->read_bytes(target, size, (std::uint64_t) addr,