+ }
+ }
+
+ if(ct1 != NULL)
+ ct1->nb_comparisons++;
+ if(ct2 != NULL)
+ ct2->nb_comparisons++;
+
+ xbt_os_timer_t global_timer = xbt_os_timer_new();
+ xbt_os_timer_t timer = xbt_os_timer_new();
+
+ xbt_os_timer_start(global_timer);
+
+ if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug))
+ xbt_os_timer_start(timer);
+
+ /* Compare number of blocks/fragments used in each heap */
+ size_t chunks_used1 = mmalloc_get_chunks_used((xbt_mheap_t)s1->regions[heap_index]->data);
+ size_t chunks_used2 = mmalloc_get_chunks_used((xbt_mheap_t)s2->regions[heap_index]->data);
+ if(chunks_used1 != chunks_used2){
+ if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+ xbt_os_timer_stop(timer);
+ if(ct1 != NULL)
+ xbt_dynar_push_as(ct1->chunks_used_comparison_times, double, xbt_os_timer_elapsed(timer));
+ if(ct2 != NULL)
+ xbt_dynar_push_as(ct2->chunks_used_comparison_times, double, xbt_os_timer_elapsed(timer));
+ XBT_DEBUG("Different number of chunks used in each heap : %zu - %zu", chunks_used1, chunks_used2);
+ errors++;
+ }else{
+ if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
+ XBT_VERB("Different number of chunks used in each heap : %zu - %zu", chunks_used1, chunks_used2);
+
+ xbt_os_timer_free(timer);
+ xbt_os_timer_stop(global_timer);
+ if(ct1 != NULL)
+ xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+ if(ct2 != NULL)
+ xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+ xbt_os_timer_free(global_timer);
+
+ if(!raw_mem)
+ MC_UNSET_RAW_MEM;
+
+ return 1;
+ }
+ }else{
+ if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug))
+ xbt_os_timer_stop(timer);
+ }
+
+ if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug))
+ xbt_os_timer_start(timer);
+
+ /* Compare size of stacks */
+ unsigned int cursor = 0;
+ void *addr_stack1, *addr_stack2;
+ void *sp1, *sp2;
+ size_t size_used1, size_used2;
+ int is_diff = 0;
+ while(cursor < xbt_dynar_length(stacks_areas)){
+ addr_stack1 = (char *)s1->regions[heap_index]->data + ((char *)((stack_region_t)xbt_dynar_get_as(stacks_areas, cursor, stack_region_t))->address - (char *)std_heap);
+ addr_stack2 = (char *)s2->regions[heap_index]->data + ((char *)((stack_region_t)xbt_dynar_get_as(stacks_areas, cursor, stack_region_t))->address - (char *)std_heap);
+ sp1 = ((mc_snapshot_stack_t)xbt_dynar_get_as(s1->stacks, cursor, mc_snapshot_stack_t))->stack_pointer;
+ sp2 = ((mc_snapshot_stack_t)xbt_dynar_get_as(s2->stacks, cursor, mc_snapshot_stack_t))->stack_pointer;
+ size_used1 = ((stack_region_t)xbt_dynar_get_as(stacks_areas, cursor, stack_region_t))->size - ((char*)sp1 - (char*)addr_stack1);
+ size_used2 = ((stack_region_t)xbt_dynar_get_as(stacks_areas, cursor, stack_region_t))->size - ((char*)sp2 - (char*)addr_stack2);
+ if(size_used1 != size_used2){
+ if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+ if(is_diff == 0){
+ xbt_os_timer_stop(timer);
+ if(ct1 != NULL)
+ xbt_dynar_push_as(ct1->stacks_sizes_comparison_times, double, xbt_os_timer_elapsed(timer));
+ if(ct2 != NULL)
+ xbt_dynar_push_as(ct2->stacks_sizes_comparison_times, double, xbt_os_timer_elapsed(timer));
+ }
+ XBT_DEBUG("Different size used in stacks : %zu - %zu", size_used1, size_used2);
+ errors++;
+ is_diff = 1;
+ }else{
+ if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
+ XBT_VERB("Different size used in stacks : %zu - %zu", size_used1, size_used2);
+
+ xbt_os_timer_free(timer);
+ xbt_os_timer_stop(global_timer);
+ if(ct1 != NULL)
+ xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+ if(ct2 != NULL)
+ xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+ xbt_os_timer_free(global_timer);
+
+ if(!raw_mem)
+ MC_UNSET_RAW_MEM;