X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/445e3dba28e14444eb6e4f385e838bc53ee83d3f..16bc1811129a94d231281b954689d284525bf6a1:/src/surf/trace_mgr.c diff --git a/src/surf/trace_mgr.c b/src/surf/trace_mgr.c index d349c22efb..80db05db81 100644 --- a/src/surf/trace_mgr.c +++ b/src/surf/trace_mgr.c @@ -1,7 +1,9 @@ -/* Authors: Arnaud Legrand */ +/* $Id$ */ + +/* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it - under the terms of the license (GNU LGPL) which comes with this package. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" #include "xbt/error.h" @@ -41,7 +43,7 @@ tmgr_trace_t tmgr_trace_new(const char *filename) FILE *f = NULL; int linecount = 0; char line[256]; - xbt_heap_float_t periodicity = -1.0; /* No periodicity by default */ + double periodicity = -1.0; /* No periodicity by default */ s_tmgr_event_t event; tmgr_event_t last_event = NULL; @@ -52,8 +54,7 @@ tmgr_trace_t tmgr_trace_new(const char *filename) } if ((f = fopen(filename, "r")) == NULL) { - CRITICAL1("Cannot open file '%s'\n", filename); - xbt_abort(); + xbt_assert1(0, "Cannot open file '%s'", filename); } trace = xbt_new0(s_tmgr_trace_t, 1); @@ -64,36 +65,32 @@ tmgr_trace_t tmgr_trace_new(const char *filename) if ((line[0] == '#') || (line[0] == '\n') || (line[0] == '%')) continue; - if (sscanf(line, "PERIODICITY " XBT_HEAP_FLOAT_T "\n", &(periodicity)) + if (sscanf(line, "PERIODICITY " "%lg" "\n", &(periodicity)) == 1) { if (periodicity <= 0) { - CRITICAL2("%s,%d: Syntax error. Periodicity has to be positive\n", - filename, linecount); - xbt_abort(); + xbt_assert2(0, + "%s,%d: Syntax error. Periodicity has to be positive", + filename, linecount); } continue; } if (sscanf - (line, XBT_HEAP_FLOAT_T " " XBT_MAXMIN_FLOAT_T "\n", &event.delta, - &event.value) != 2) { - CRITICAL2("%s,%d: Syntax error\n", filename, linecount); - xbt_abort(); + (line, "%lg" " " "%lg" "\n", &event.delta, &event.value) != 2) { + xbt_assert2(0, "%s,%d: Syntax error", filename, linecount); } if (last_event) { if ((last_event->delta = event.delta - last_event->delta) <= 0) { - CRITICAL2("%s,%d: Invalid trace value, events have to be sorted\n", - filename, linecount); - xbt_abort(); + xbt_assert2(0, + "%s,%d: Invalid trace value, events have to be sorted", + filename, linecount); } } xbt_dynar_push(trace->event_list, &event); last_event = xbt_dynar_get_ptr(trace->event_list, xbt_dynar_length(trace->event_list) - 1); -/* printf(XBT_HEAP_FLOAT_T " " XBT_MAXMIN_FLOAT_T "\n", event.delta, */ -/* event.value); */ } if (periodicity > 0) { @@ -120,8 +117,9 @@ void tmgr_trace_free(tmgr_trace_t trace) xbt_free(trace); } -tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, tmgr_trace_t trace, - xbt_heap_float_t start_time, int offset, +tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, + tmgr_trace_t trace, + double start_time, int offset, void *resource) { tmgr_trace_event_t trace_event = NULL; @@ -132,15 +130,15 @@ tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, tmgr_trace_t t trace_event->idx = offset; trace_event->resource = resource; - if (trace_event->idx >= xbt_dynar_length(trace->event_list)) - xbt_abort(); + xbt_assert0((trace_event->idx < xbt_dynar_length(trace->event_list)), + "You're refering to an event that does not exist!"); xbt_heap_push(history->heap, trace_event, start_time); return trace_event; } -xbt_heap_float_t tmgr_history_next_date(tmgr_history_t history) +double tmgr_history_next_date(tmgr_history_t history) { if (xbt_heap_size(history->heap)) return (xbt_heap_maxkey(history->heap)); @@ -149,11 +147,11 @@ xbt_heap_float_t tmgr_history_next_date(tmgr_history_t history) } tmgr_trace_event_t tmgr_history_get_next_event_leq(tmgr_history_t history, - xbt_heap_float_t date, - xbt_maxmin_float_t * value, + double date, + double *value, void **resource) { - xbt_heap_float_t event_date = xbt_heap_maxkey(history->heap); + double event_date = xbt_heap_maxkey(history->heap); tmgr_trace_event_t trace_event = NULL; tmgr_event_t event = NULL; tmgr_trace_t trace = NULL;