make statev API public
[libfirm] / ir / stat / statev_t.h
1 /*
2  * Copyright (C) 1995-2008 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  */
25 #ifndef FIRM_STATEVENT_T_H
26 #define FIRM_STATEVENT_T_H
27
28 #include "statev.h"
29 #include <stdarg.h>
30
31 #ifdef DISABLE_STATEV
32
33 #define stat_ev_enabled                          0
34 #define stat_ev_dbl(name, val)                   ((void)0)
35 #define stat_ev_int(name, val)                   ((void)0)
36 #define stat_ev_ull(name, val)                   ((void)0)
37 #define stat_ev(name)                            ((void)0)
38
39 #define stat_ev_cnt_decl(var)                    ((void)0)
40 #define stat_ev_cnt_inc(var)                     ((void)0)
41 #define stat_ev_cnt_done(name, var)              ((void)0)
42 #define stat_ev_tim_push()                       ((void)0)
43 #define stat_ev_tim_pop(name)                    ((void)0)
44
45 #define stat_ev_ctx_push(key)                    ((void)0)
46 #define stat_ev_ctx_push_str(key, str)           ((void)0)
47 #define stat_ev_ctx_push_fmt(key, fmt, value)    ((void)0)
48 #define stat_ev_ctx_pop(key)                     ((void)0)
49
50 #else
51
52 void stat_ev_tim_push(void);
53 void stat_ev_tim_pop(const char *name);
54
55 void do_stat_ev_int(const char *name, int value);
56 void do_stat_ev_dbl(const char *name, double value);
57 void do_stat_ev_ull(const char *name, unsigned long long value);
58 void do_stat_ev(const char *name);
59 void do_stat_ev_ctx_push_vfmt(const char *name, const char *fmt, va_list ap);
60 void do_stat_ev_ctx_pop(const char *key);
61
62 static inline void stat_ev_int_(const char *name, int value)
63 {
64         if (!stat_ev_enabled)
65                 return;
66         (do_stat_ev_int)(name, value);
67 }
68 static inline void stat_ev_dbl_(const char *name, double value)
69 {
70         if (!stat_ev_enabled)
71                 return;
72         (do_stat_ev_dbl)(name, value);
73 }
74 static inline void stat_ev_ull_(const char *name, unsigned long long value)
75 {
76         if (!stat_ev_enabled)
77                 return;
78         (do_stat_ev_ull)(name, value);
79 }
80 static inline void stat_ev_(const char *name)
81 {
82         if (!stat_ev_enabled)
83                 return;
84         (do_stat_ev)(name);
85 }
86 static inline void stat_ev_ctx_push_fmt_(const char *name, const char *fmt, ...)
87 {
88         if (!stat_ev_enabled)
89                 return;
90         va_list ap;
91         va_start(ap, fmt);
92         do_stat_ev_ctx_push_vfmt(name, fmt, ap);
93         va_end(ap);
94 }
95 static inline void stat_ev_ctx_push_str_(const char *name, const char *str)
96 {
97         stat_ev_ctx_push_fmt_(name, "%s", str);
98 }
99 static inline void stat_ev_ctx_pop_(const char *key)
100 {
101         if (!stat_ev_enabled)
102                 return;
103         do_stat_ev_ctx_pop(key);
104 }
105 #define stat_ev_int(name, value)        stat_ev_int_(name, value)
106 #define stat_ev_dbl(name, value)        stat_ev_dbl_(name, value)
107 #define stat_ev_ull(name, value)        stat_ev_ull_(name, value)
108 #define stat_ev(name)                   stat_ev_(name)
109 #define stat_ev_ctx_push_fmt(name, fmt, value) \
110                                         stat_ev_ctx_push_fmt_(name, fmt, value)
111 #define stat_ev_ctx_push_str(name, str) stat_ev_ctx_push_str_(name, str)
112 #define stat_ev_ctx_pop(name)           stat_ev_ctx_pop_(name)
113
114 #define stat_ev_cnt_decl(var)       int stat_ev_cnt_var_ ## var = 0
115 #define stat_ev_cnt_inc(var)        do { ++stat_ev_cnt_var_ ## var; } while(0)
116 #define stat_ev_cnt_done(var, name) stat_ev_int((name), stat_ev_cnt_var_ ## var)
117
118 #endif
119
120 #endif