- const uint64_t* values = (const uint64_t*) data;
- size_t n = xbt_pagesize / sizeof(uint64_t);
+ const std::uint64_t* values = (const uint64_t*) data;
+ std::size_t n = xbt_pagesize / sizeof(uint64_t);
// Using mmap in order to be able to expand the region
// by relocating it somewhere else in the virtual memory
// space:
// Using mmap in order to be able to expand the region
// by relocating it somewhere else in the virtual memory
// space:
- void * memory = ::mmap(NULL, size << xbt_pagebits, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, -1, 0);
- if (memory==MAP_FAILED) {
+ void* memory = ::mmap(NULL, size << xbt_pagebits, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, -1, 0);
+ if (memory == MAP_FAILED) {
// Try to find a duplicate in set of pages with the same hash:
page_set_type& page_set = this->hash_index_[hash];
// Try to find a duplicate in set of pages with the same hash:
page_set_type& page_set = this->hash_index_[hash];
const void* snapshot_page = this->get_page(pageno);
if (memcmp(page, snapshot_page, xbt_pagesize) == 0) {
const void* snapshot_page = this->get_page(pageno);
if (memcmp(page, snapshot_page, xbt_pagesize) == 0) {
// Otherwise, a new page is allocated in the page store and the content
// of the page is `memcpy()`-ed to this new page.
// Otherwise, a new page is allocated in the page store and the content
// of the page is `memcpy()`-ed to this new page.
xbt_assert(this->page_counts_[pageno]==0, "Allocated page is already used");
void* snapshot_page = (void*) this->get_page(pageno);
memcpy(snapshot_page, page, xbt_pagesize);
xbt_assert(this->page_counts_[pageno]==0, "Allocated page is already used");
void* snapshot_page = (void*) this->get_page(pageno);
memcpy(snapshot_page, page, xbt_pagesize);
return mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
}
return mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
}
XBT_TEST_SUITE("mc_page_store", "Page store");
XBT_TEST_UNIT("base", test_mc_page_store, "Test adding/removing pages in the store")
{
XBT_TEST_SUITE("mc_page_store", "Page store");
XBT_TEST_UNIT("base", test_mc_page_store, "Test adding/removing pages in the store")
{
- size_t pagesize = (size_t) getpagesize();
- std::unique_ptr<simgrid::mc::PageStore> store
- = std::unique_ptr<simgrid::mc::PageStore>(new simgrid::mc::PageStore(500));
+ std::size_t pagesize = (size_t) getpagesize();
+ std::unique_ptr<PageStore> store
+ = std::unique_ptr<PageStore>(new simgrid::mc::PageStore(500));
size_t pageno1 = store->store_page(data);
xbt_test_assert(store->get_ref(pageno1)==1, "Bad refcount");
const void* copy = store->get_page(pageno1);
size_t pageno1 = store->store_page(data);
xbt_test_assert(store->get_ref(pageno1)==1, "Bad refcount");
const void* copy = store->get_page(pageno1);
- xbt_test_assert(memcmp(data, copy, pagesize)==0, "Page data should be the same");
+ xbt_test_assert(::memcmp(data, copy, pagesize)==0, "Page data should be the same");
xbt_test_assert(store->size()==1, "Bad size");
xbt_test_add("Store the same page again");
xbt_test_assert(store->size()==1, "Bad size");
xbt_test_add("Store the same page again");