X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/07ce716b44d53a070fc2358ec727bb1975198200..10beade7f2e5b5b7f318c3847602cc1ddbf09c99:/src/gras/DataDesc/cbps.c diff --git a/src/gras/DataDesc/cbps.c b/src/gras/DataDesc/cbps.c index fdea5ebd3c..b64eb2f10c 100644 --- a/src/gras/DataDesc/cbps.c +++ b/src/gras/DataDesc/cbps.c @@ -1,10 +1,7 @@ -/* $Id$ */ - /* cbps - persistant states for callbacks */ -/* Copyright (c) 2003 Olivier Aumage. */ -/* Copyright (c) 2003, 2004 Martin Quinson. */ -/* All rights reserved. */ +/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team. + * 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. */ @@ -86,17 +83,18 @@ gras_cbps_v_push(gras_cbps_t ps, char *varname = (char *) xbt_strdup(name); xbt_ex_t e; - DEBUG2("push(%s,%p)", name, (void *) data); + XBT_DEBUG("push(%s,%p)", name, (void *) data); TRY { varstack = xbt_dict_get(ps->space, name); - } CATCH(e) { + } + CATCH(e) { if (e.category != mismatch_error) RETHROW; - DEBUG1("Create a new variable stack for '%s' into the space", name); + XBT_DEBUG("Create a new variable stack for '%s' into the space", name); varstack = xbt_dynar_new(sizeof(gras_cbps_elm_t *), NULL); - xbt_dict_set(ps->space, varname, (void **) varstack, NULL); + xbt_dict_set(ps->space, name, (void **) varstack, NULL); xbt_ex_free(e); /* leaking, you think? only if you do not close all the openned blocks ;) */ } @@ -108,7 +106,7 @@ gras_cbps_v_push(gras_cbps_t ps, xbt_dynar_push(varstack, &var); xbt_dynar_pop(ps->frames, &frame); - DEBUG4("Push %s (%p @%p) into frame %p", varname, (void *) varname, + XBT_DEBUG("Push %s (%p @%p) into frame %p", varname, (void *) varname, (void *) &varname, (void *) frame); xbt_dynar_push(frame, &varname); xbt_dynar_push(ps->frames, &frame); @@ -123,25 +121,26 @@ void gras_cbps_v_pop(gras_cbps_t ps, const char *name, gras_datadesc_type_t * ddt, void **res) { - xbt_dynar_t varstack=NULL, frame=NULL; + xbt_dynar_t varstack = NULL, frame = NULL; gras_cbps_elm_t var = NULL; void *data = NULL; xbt_ex_t e; - DEBUG1("pop(%s)", name); + XBT_DEBUG("pop(%s)", name); TRY { varstack = xbt_dict_get(ps->space, name); - } CATCH(e) { + } + CATCH(e) { if (e.category != mismatch_error) RETHROW; xbt_ex_free(e); - THROW1(not_found_error, 1, "Asked to pop the non-existant %s", name); + THROWF(not_found_error, 1, "Asked to pop the non-existant %s", name); } xbt_dynar_pop(varstack, &var); if (!xbt_dynar_length(varstack)) { - DEBUG1("Last incarnation of %s poped. Kill it", name); + XBT_DEBUG("Last incarnation of %s poped. Kill it", name); xbt_dict_remove(ps->space, name); xbt_dynar_free(&varstack); } @@ -189,7 +188,7 @@ gras_cbps_v_set(gras_cbps_t ps, xbt_dynar_t dynar = NULL; gras_cbps_elm_t elm = NULL; - DEBUG1("set(%s)", name); + XBT_DEBUG("set(%s)", name); dynar = xbt_dict_get_or_null(ps->space, name); if (dynar == NULL) { @@ -223,7 +222,7 @@ void *gras_cbps_v_get(gras_cbps_t ps, const char *name, xbt_dynar_t dynar = NULL; gras_cbps_elm_t elm = NULL; - DEBUG1("get(%s)", name); + XBT_DEBUG("get(%s)", name); dynar = xbt_dict_get(ps->space, name); xbt_dynar_pop(dynar, &elm); xbt_dynar_push(dynar, &elm); @@ -252,7 +251,7 @@ void gras_cbps_block_begin(gras_cbps_t ps) xbt_dynar_t dynar = NULL; - DEBUG0(">>> Block begin"); + XBT_DEBUG(">>> Block begin"); dynar = xbt_dynar_new(sizeof(char *), NULL); xbt_dynar_push(ps->frames, &dynar); } @@ -265,7 +264,7 @@ void gras_cbps_block_end(gras_cbps_t ps) unsigned int cursor = 0; char *name = NULL; - xbt_assert0(xbt_dynar_length(ps->frames), + xbt_assert(xbt_dynar_length(ps->frames), "More block_end than block_begin"); xbt_dynar_pop(ps->frames, &frame); @@ -274,7 +273,7 @@ void gras_cbps_block_end(gras_cbps_t ps) xbt_dynar_t varstack = NULL; gras_cbps_elm_t var = NULL; - DEBUG2("Get ride of %s (%p)", name, (void *) name); + XBT_DEBUG("Get ride of %s (%p)", name, (void *) name); varstack = xbt_dict_get(ps->space, name); xbt_dynar_pop(varstack, &var); @@ -289,14 +288,14 @@ void gras_cbps_block_end(gras_cbps_t ps) free(name); } xbt_dynar_free_container(&frame); /* we just emptied it */ - DEBUG0("<<< Block end"); + XBT_DEBUG("<<< Block end"); } /** \brief Push a new integer value into the cbps. */ void gras_cbps_i_push(gras_cbps_t ps, int val) { - DEBUG1("push %d as a size", val); + XBT_DEBUG("push %d as a size", val); xbt_dynar_push_as(ps->lints, int, val); } @@ -305,10 +304,10 @@ int gras_cbps_i_pop(gras_cbps_t ps) { int ret; - xbt_assert0(xbt_dynar_length(ps->lints) > 0, + xbt_assert(xbt_dynar_length(ps->lints) > 0, "gras_cbps_i_pop: no value to pop"); ret = xbt_dynar_pop_as(ps->lints, int); - DEBUG1("pop %d as a size", ret); + XBT_DEBUG("pop %d as a size", ret); return ret; } @@ -327,8 +326,8 @@ int gras_datadesc_cb_pop(gras_datadesc_type_t ignored, gras_cbps_t vars, /* ************************* */ /** \brief Cb to push an integer. Must be attached to the field you want to push */ -void gras_datadesc_cb_push_int(gras_datadesc_type_t ignored, gras_cbps_t vars, - void *data) +void gras_datadesc_cb_push_int(gras_datadesc_type_t ignored, + gras_cbps_t vars, void *data) { int *i = (int *) data; gras_cbps_i_push(vars, (int) *i); @@ -369,7 +368,7 @@ void gras_datadesc_cb_push_int_mult(gras_datadesc_type_t ignored, { int old = *(int *) data; int new = gras_cbps_i_pop(vars); - DEBUG2("push %d x %d as a size", old, new); + XBT_DEBUG("push %d x %d as a size", old, new); gras_cbps_i_push(vars, old * new); } @@ -380,7 +379,7 @@ void gras_datadesc_cb_push_uint_mult(gras_datadesc_type_t ignored, unsigned int old = *(unsigned int *) data; unsigned int new = gras_cbps_i_pop(vars); - DEBUG2("push %d x %d as a size", old, new); + XBT_DEBUG("push %d x %d as a size", old, new); gras_cbps_i_push(vars, (int) (old * new)); } @@ -402,6 +401,6 @@ void gras_datadesc_cb_push_ulint_mult(gras_datadesc_type_t ignored, unsigned long int old = *(unsigned long int *) data; unsigned long int new = gras_cbps_i_pop(vars); - DEBUG2("push %ld x %ld as a size", old, new); + XBT_DEBUG("push %ld x %ld as a size", old, new); gras_cbps_i_push(vars, (int) (old * new)); }