Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] mc_comm_pattern.c containing all communication pattern functions
[simgrid.git] / src / mc / mc_object_info.c
1 #include <stddef.h>
2
3 #include <xbt/dynar.h>
4
5 #include "mc_object_info.h"
6 #include "mc_private.h"
7
8 dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *ip)
9 {
10   xbt_dynar_t dynar = info->functions_index;
11   mc_function_index_item_t base =
12       (mc_function_index_item_t) xbt_dynar_get_ptr(dynar, 0);
13   int i = 0;
14   int j = xbt_dynar_length(dynar) - 1;
15   while (j >= i) {
16     int k = i + ((j - i) / 2);
17     if (ip < base[k].low_pc) {
18       j = k - 1;
19     } else if (ip >= base[k].high_pc) {
20       i = k + 1;
21     } else {
22       return base[k].function;
23     }
24   }
25   return NULL;
26 }
27
28 dw_variable_t MC_file_object_info_find_variable_by_name(mc_object_info_t info, const char* name)
29 {
30   unsigned int cursor = 0;
31   dw_variable_t variable;
32   xbt_dynar_foreach(info->global_variables, cursor, variable){
33     if(!strcmp(name, variable->name))
34       return variable;
35   }
36
37   return NULL;
38 }