Use bt_iter_equals_pos in compare function
[lttv.git] / lttv / lttv / traceset.c
index 7e86c5b764b8e2c0e1f0787f6826b2e99c23932a..8743d70825d54a51549a2f783373f78fca33ff68 100644 (file)
@@ -520,11 +520,11 @@ guint64 lttv_traceset_get_timestamp_last_event(LttvTraceset *ts)
        last_position.bt_pos = &pos;
        last_position.timestamp = G_MAXUINT64;
        last_position.cpu_id = INT_MAX;
-#ifdef BABEL_HAS_SEEK_LAST     
+
        /* Assign iterator to the last event of the traces */  
        last_position.bt_pos->type = BT_SEEK_LAST;
        last_position.iter = ts->iter;
-#endif
+
        return lttv_traceset_position_get_timestamp(&last_position);
 }
 
@@ -605,12 +605,8 @@ TimeInterval lttv_traceset_get_time_span_real(LttvTraceset *ts)
                                ltt_time_zero) == 0 && ts->traces->len > 0){
                ts->time_span.start_time = ltt_time_from_uint64(
                                lttv_traceset_get_timestamp_first_event(ts));
-#ifdef BABEL_HAS_SEEK_LAST     
                ts->time_span.end_time = ltt_time_from_uint64(
-                                       lttv_traceset_get_timestamp_end(ts));
-#else
-               ts->time_span.end_time = lttv_traceset_get_time_span(ts).end_time;      
-#endif
+                                       lttv_traceset_get_timestamp_last_event(ts));    
        }
         return ts->time_span;
 }
@@ -662,6 +658,9 @@ int set_values_position(const LttvTracesetPosition *pos)
        lttv_traceset_seek_to_position(&previous_pos);
        /*We must desallocate because the function bt_iter_get_pos() does a g_new */
        bt_iter_free_pos(previous_pos.bt_pos);
+       if (pos->timestamp == G_MAXUINT64) {
+         return 0;
+       }
        return 1;
 }
 
@@ -691,29 +690,37 @@ LttTime  lttv_traceset_position_get_time(const LttvTracesetPosition *pos)
 }
 
 
-
+/* 0 if equals, other is different */
 int lttv_traceset_position_compare(const LttvTracesetPosition *pos1, const LttvTracesetPosition *pos2)
 {
 #warning " TODO :Rename for lttv_traceset_position_equals && Must return COMPARAISON OF THE 2 POSITION && verify if it is the best way to compare position"
         if(pos1 == NULL || pos2 == NULL){
                 return -1;
        }
-        
-        guint64 timeStampPos1,timeStampPos2;
-        guint cpuId1, cpuId2;
-        
-        timeStampPos1 = lttv_traceset_position_get_timestamp(pos1);
-        timeStampPos2 = lttv_traceset_position_get_timestamp(pos2);
-        
-        
-        cpuId1 = lttv_traceset_position_get_cpuid(pos1);
-        cpuId2 = lttv_traceset_position_get_cpuid(pos2);
-       
-        if(timeStampPos1 == timeStampPos2 && cpuId1 == cpuId2){
-                return 0;
-       }
-        else{
-                return 1;
+
+       int res = bt_iter_equals_pos(pos1->bt_pos, pos2->bt_pos);
+       
+       if (res < 0) {
+       
+               guint64 timeStampPos1,timeStampPos2;
+               guint cpuId1, cpuId2;
+               
+               timeStampPos1 = lttv_traceset_position_get_timestamp(pos1);
+               timeStampPos2 = lttv_traceset_position_get_timestamp(pos2);
+               
+               
+               cpuId1 = lttv_traceset_position_get_cpuid(pos1);
+               cpuId2 = lttv_traceset_position_get_cpuid(pos2);
+               
+               if(timeStampPos1 == timeStampPos2 && cpuId1 == cpuId2){
+                       return 0;
+               }
+               else{
+                       return 1;
+               }
+       } else {
+               
+               return !res;
        }
 }
 
This page took 0.047923 seconds and 4 git commands to generate.