2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Statistic events.
23 * @author Sebastian Hack
35 #include "bestatevent.h"
44 static ev_env_t envs[STACK_SIZE];
45 static unsigned sp = 0;
47 void be_stat_ev_push(const char **tags, int n_tags, FILE *f)
52 assert(sp < STACK_SIZE && "stat event stack full");
56 for(i = 0; i < n_tags; ++i) {
57 strncat(env->tag, tags[i], sizeof(env->tag));
58 strncat(env->tag, ";", sizeof(env->tag));
60 env->tag[sizeof(env->tag) - 1] = '\0';
64 void be_stat_ev_pop(void)
72 void be_stat_ev(const char *ev, int value)
83 fprintf(env->f, "%s%s;%d\n", env->tag, ev, value);
86 void be_stat_ev_l(const char *ev, long value)
97 fprintf(env->f, "%s%s;%ld\n", env->tag, ev, value);
100 void be_stat_ev_dbl(const char *ev, double value)
111 fprintf(env->f, "%s%s;%f\n", env->tag, ev, value);
114 void be_stat_ev_ull(const char *ev, ulong64 value)
125 fprintf(env->f, "%s%s;%" ULL_FMT "\n", env->tag, ev, value);
128 int be_stat_ev_is_active(void)
130 return sp > 0 && envs[sp - 1].f != NULL;