if(i_block < nb_shared_blocks-1)
xbt_assert(stop_offset < shared_block_offsets[2*i_block+2],
"stop_offset (%lu) should be lower than its successor start offset (%lu)", stop_offset, shared_block_offsets[2*i_block+2]);
-// fprintf(stderr, "shared block 0x%x - 0x%x\n", start_offset, stop_offset);
size_t start_block_offset = ALIGN_UP(start_offset, smpi_shared_malloc_blocksize);
size_t stop_block_offset = ALIGN_DOWN(stop_offset, smpi_shared_malloc_blocksize);
unsigned int i;
for (i = start_block_offset / smpi_shared_malloc_blocksize; i < stop_block_offset / smpi_shared_malloc_blocksize; i++) {
-// fprintf(stderr, "\tmmap:for 0x%x - 0x%x\n", i*smpi_shared_malloc_blocksize, smpi_shared_malloc_blocksize);
void* pos = (void*)((unsigned long)mem + i * smpi_shared_malloc_blocksize);
void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED | MAP_POPULATE,
smpi_shared_malloc_bogusfile, 0);
size_t low_page_start_offset = ALIGN_UP(start_offset, PAGE_SIZE);
size_t low_page_stop_offset = start_block_offset < ALIGN_DOWN(stop_offset, PAGE_SIZE) ? start_block_offset : ALIGN_DOWN(stop_offset, PAGE_SIZE);
if(low_page_start_offset < low_page_stop_offset) {
-// fprintf(stderr, "\tmmap:low 0x%x - 0x%x\n", low_page_start_offset, low_page_stop_offset-low_page_start_offset);
void* pos = (void*)((unsigned long)mem + low_page_start_offset);
void* res = mmap(pos, low_page_stop_offset-low_page_start_offset, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED | MAP_POPULATE,
smpi_shared_malloc_bogusfile, 0);
if(low_page_stop_offset <= stop_block_offset) {
size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN(stop_offset, PAGE_SIZE);
if(high_page_stop_offset > stop_block_offset) {
-// fprintf(stderr, "\tmmap:high 0x%x - 0x%x\n", stop_block_offset, high_page_stop_offset-stop_block_offset);
void* pos = (void*)((unsigned long)mem + stop_block_offset);
void* res = mmap(pos, high_page_stop_offset-stop_block_offset, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED | MAP_POPULATE,
smpi_shared_malloc_bogusfile, 0);