/** @brief A classical mutex, but blocking in the simulation world
* @ingroup s4u_api
*
- * It is strictly impossible to use a real mutex (such as
+ * It is strictly impossible to use a real mutex, such as
* [std::mutex](http://en.cppreference.com/w/cpp/thread/mutex)
- * or [pthread_mutex_t](http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_lock.html)),
+ * or [pthread_mutex_t](http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_lock.html),
* because it would block the whole simulation.
* Instead, you should use the present class, that is a drop-in replacement of
* [std::mutex](http://en.cppreference.com/w/cpp/thread/mutex).
* @param data Memory page
* @return hash off the page
*/
-static inline __attribute__ ((always_inline))
-PageStore::hash_type mc_hash_page(const void* data)
+static XBT_ALWAYS_INLINE PageStore::hash_type mc_hash_page(const void* data)
{
const std::uint64_t* values = (const uint64_t*) data;
std::size_t n = xbt_pagesize / sizeof(uint64_t);
};
-inline __attribute__((always_inline))
-void PageStore::unref_page(std::size_t pageno) {
+XBT_ALWAYS_INLINE void PageStore::unref_page(std::size_t pageno)
+{
if ((--this->page_counts_[pageno]) == 0)
this->remove_page(pageno);
}
-inline __attribute__((always_inline))
-void PageStore::ref_page(size_t pageno)
+XBT_ALWAYS_INLINE void PageStore::ref_page(size_t pageno)
{
++this->page_counts_[pageno];
}
-inline __attribute__((always_inline))
-const void* PageStore::get_page(std::size_t pageno) const
+XBT_ALWAYS_INLINE const void* PageStore::get_page(std::size_t pageno) const
{
return (void*) simgrid::mc::mmu::join(pageno, (std::uintptr_t) this->memory_);
}
-inline __attribute__((always_inline))
-std::size_t PageStore::get_ref(std::size_t pageno)
+XBT_ALWAYS_INLINE std::size_t PageStore::get_ref(std::size_t pageno)
{
return this->page_counts_[pageno];
}
-inline __attribute__((always_inline))
-std::size_t PageStore::size() {
+XBT_ALWAYS_INLINE std::size_t PageStore::size()
+{
return this->top_index_ - this->free_pages_.size();
}
-inline __attribute__((always_inline))
-std::size_t PageStore::capacity()
+XBT_ALWAYS_INLINE std::size_t PageStore::capacity()
{
return this->capacity_;
}
* @param size Byte size
* @return Number of memory pages
*/
-static inline __attribute__ ((always_inline))
-std::size_t chunkCount(std::size_t size)
+static XBT_ALWAYS_INLINE std::size_t chunkCount(std::size_t size)
{
size_t page_count = size >> xbt_pagebits;
if (size & (xbt_pagesize-1))
}
/** @brief Split into chunk number and remaining offset */
-static inline __attribute__ ((always_inline))
-std::pair<std::size_t, std::uintptr_t> split(std::uintptr_t offset)
+static XBT_ALWAYS_INLINE std::pair<std::size_t, std::uintptr_t> split(std::uintptr_t offset)
{
return {
offset >> xbt_pagebits,
}
/** Merge chunk number and remaining offset info a global offset */
-static inline __attribute__ ((always_inline))
-std::uintptr_t join(std::size_t page, std::uintptr_t offset)
+static XBT_ALWAYS_INLINE std::uintptr_t join(std::size_t page, std::uintptr_t offset)
{
return ((std::uintptr_t) page << xbt_pagebits) + offset;
}
-static inline __attribute__ ((always_inline))
-std::uintptr_t join(std::pair<std::size_t,std::uintptr_t> value)
+static XBT_ALWAYS_INLINE std::uintptr_t join(std::pair<std::size_t, std::uintptr_t> value)
{
return join(value.first, value.second);
}
-static inline __attribute__ ((always_inline))
-bool sameChunk(std::uintptr_t a, std::uintptr_t b)
+static XBT_ALWAYS_INLINE bool sameChunk(std::uintptr_t a, std::uintptr_t b)
{
return (a >> xbt_pagebits) == (b >> xbt_pagebits);
}
XBT_PRIVATE void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg);
-static inline __attribute__((always_inline))
-void* mc_translate_address_region_chunked(uintptr_t addr, mc_mem_region_t region)
+static XBT_ALWAYS_INLINE void* mc_translate_address_region_chunked(uintptr_t addr, mc_mem_region_t region)
{
auto split = simgrid::mc::mmu::split(addr - region->start().address());
auto pageno = split.first;
return (char*) snapshot_page + offset;
}
-static inline __attribute__((always_inline))
-void* mc_translate_address_region(uintptr_t addr, mc_mem_region_t region, int process_index)
+static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, mc_mem_region_t region, int process_index)
{
switch (region->storage_type()) {
case simgrid::mc::StorageType::NoData:
extern "C" {
-static inline __attribute__ ((always_inline))
-mc_mem_region_t mc_get_region_hinted(void* addr, simgrid::mc::Snapshot* snapshot, int process_index, mc_mem_region_t region)
+static XBT_ALWAYS_INLINE mc_mem_region_t mc_get_region_hinted(void* addr, simgrid::mc::Snapshot* snapshot,
+ int process_index, mc_mem_region_t region)
{
if (region->contain(simgrid::mc::remote(addr)))
return region;
const void* addr1, simgrid::mc::Snapshot* snapshot1,
const void* addr2, simgrid::mc::Snapshot* snapshot2, int process_index, std::size_t size);
-static inline __attribute__ ((always_inline))
-const void* mc_snapshot_get_heap_end(simgrid::mc::Snapshot* snapshot)
+static XBT_ALWAYS_INLINE const void* mc_snapshot_get_heap_end(simgrid::mc::Snapshot* snapshot)
{
if(snapshot==nullptr)
xbt_die("snapshot is nullptr");
* @param size Size of the data to read in bytes
* @return Pointer where the data is located (target buffer of original location)
*/
-static inline __attribute__((always_inline))
-const void* MC_region_read(
- mc_mem_region_t region, void* target, const void* addr, std::size_t size)
+static XBT_ALWAYS_INLINE const void* MC_region_read(mc_mem_region_t region, void* target, const void* addr,
+ std::size_t size)
{
xbt_assert(region);
}
}
-static inline __attribute__ ((always_inline))
-void* MC_region_read_pointer(mc_mem_region_t region, const void* addr)
+static XBT_ALWAYS_INLINE void* MC_region_read_pointer(mc_mem_region_t region, const void* addr)
{
void* res;
return *(void**) MC_region_read(region, &res, addr, sizeof(void*));