X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbestatevent.c;h=9b74757af890779d6d495bd8aad127b30cd42b38;hb=9276447aec4972df060349e162f583c4898dfec8;hp=f8854c37b1af5975f3fef3ea12e7c3f2e02f3fea;hpb=8b6be7e6885ce00f03f83626aaee50503ea12069;p=libfirm diff --git a/ir/be/bestatevent.c b/ir/be/bestatevent.c index f8854c37b..9b74757af 100644 --- a/ir/be/bestatevent.c +++ b/ir/be/bestatevent.c @@ -1,12 +1,36 @@ +/* + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /** - * Statistic events - * @date 3.9.2006 - * @author Sebastian Hack - * @cvs-id $Id$ + * @file + * @brief Statistic events. + * @author Sebastian Hack + * @date 03.09.2006 + * @version $Id$ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include +#include #include "bestatevent.h" @@ -18,7 +42,7 @@ typedef struct { } ev_env_t; static ev_env_t envs[STACK_SIZE]; -static int sp = 0; +static unsigned sp = 0; void be_stat_ev_push(const char **tags, int n_tags, FILE *f) { @@ -39,39 +63,69 @@ void be_stat_ev_push(const char **tags, int n_tags, FILE *f) void be_stat_ev_pop(void) { - if(sp > 0) { - envs[--sp].f = NULL; - } + if (sp == 0) + return; + + envs[--sp].f = NULL; } void be_stat_ev(const char *ev, int value) { - if(sp > 0) { - ev_env_t *env = &envs[sp - 1]; - if(env->f) - fprintf(env->f, "%s%s;%d\n", env->tag, ev, value); - } + ev_env_t *env; + + if (sp == 0) + return; + + env = &envs[sp - 1]; + if (env->f == NULL) + return; + + fprintf(env->f, "%s%s;%d\n", env->tag, ev, value); +} + +void be_stat_ev_l(const char *ev, long value) +{ + ev_env_t *env; + + if (sp == 0) + return; + + env = &envs[sp - 1]; + if (env->f == NULL) + return; + + fprintf(env->f, "%s%s;%ld\n", env->tag, ev, value); } void be_stat_ev_dbl(const char *ev, double value) { - if(sp > 0) { - ev_env_t *env = &envs[sp - 1]; - if(env->f) - fprintf(env->f, "%s%s;%f\n", env->tag, ev, value); - } + ev_env_t *env; + + if (sp == 0) + return; + + env = &envs[sp - 1]; + if (env->f == NULL) + return; + + fprintf(env->f, "%s%s;%f\n", env->tag, ev, value); } void be_stat_ev_ull(const char *ev, ulong64 value) { - if(sp > 0) { - ev_env_t *env = &envs[sp - 1]; - if(env->f) - fprintf(env->f, "%s%s;%" ULL_FMT "\n", env->tag, ev, value); - } + ev_env_t *env; + + if (sp == 0) + return; + + env = &envs[sp - 1]; + if (env->f == NULL) + return; + + fprintf(env->f, "%s%s;%" ULL_FMT "\n", env->tag, ev, value); } int be_stat_ev_is_active(void) { - return sp > 0 && envs[sp - 1].f; + return sp > 0 && envs[sp - 1].f != NULL; }