Minor changes
[libfirm] / ir / stat / statev.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Statistic events.
23  * @author      Sebastian Hack
24  * @date        17.06.2007
25  * @version     $Id$
26  */
27
28 #ifndef FIRM_STATEVENT_H
29 #define FIRM_STATEVENT_H
30
31 #ifndef FIRM_STATISTICS
32
33 #define stat_ev_do(expr)
34 #define stat_ev_dbl(name, val)
35
36 #define stat_ev_cnt_decl(var)
37 #define stat_ev_cnt_inc(var)
38 #define stat_ev_cnt_done(name, var)
39 #define stat_ev(name)
40
41 #define stat_ev_ctx_push_fobj(key, firm_object)
42 #define stat_ev_ctx_push(key, value)
43 #define stat_ev_ctx_pop()
44 #define stat_ev_begin(prefix)
45 #define stat_ev_end()
46 #define stat_ev_flush()
47
48 #else
49
50 extern int stat_ev_enabled;
51
52 #define stat_ev_do(expr)            (stat_ev_enabled ? ((expr), 1) : 0)
53
54 #define stat_ev_dbl(name, val)      do { if (stat_ev_enabled) { stat_ev_emit(name, val); } } while(0)
55
56 #define stat_ev_cnt_decl(var)       int stat_ev_cnt_var_ ## var = 0
57 #define stat_ev_cnt_inc(var)        do { ++stat_ev_cnt_var_ ## var; } while(0)
58 #define stat_ev_cnt_done(var, name) stat_ev_dbl((name), stat_ev_cnt_var_ ## var)
59
60 #define stat_ev(name)               stat_ev_dbl((name), 0.0)
61
62 void stat_ev_ctx_push_fobj(const char *key, const void *firm_object);
63 void stat_ev_ctx_push(const char *key, const char *value);
64 void stat_ev_ctx_pop(void);
65 void stat_ev_emit(const char *name, double val);
66 void stat_ev_begin(const char *prefix);
67 void stat_ev_end(void);
68 void stat_ev_flush(void);
69
70 #endif
71
72 #endif /* FIRM_STATEVENT_H */