projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
convert opts to use the opt_manage framework
[libfirm]
/
ir
/
stat
/
statev.c
diff --git
a/ir/stat/statev.c
b/ir/stat/statev.c
index
3d61fac
..
1e78d6d
100644
(file)
--- a/
ir/stat/statev.c
+++ b/
ir/stat/statev.c
@@
-31,6
+31,7
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <regex.h>
#include "util.h"
#include "stat_timing.h"
#include "util.h"
#include "stat_timing.h"
@@
-39,39
+40,17
@@
#include "config.h"
#include "config.h"
-#if defined(FIRM_STATISTICS) && !defined(DISABLE_STATEV)
-
-#ifdef HAVE_REGEX_H
-#define FIRM_HAVE_REGEX
-#endif
-
-#if defined HAVE_LIBZ && defined HAVE_ZLIB_H
-#define FIRM_HAVE_LIBZ
-#endif
-
+#ifndef DISABLE_STATEV
#define MAX_TIMER 256
#define MAX_TIMER 256
-#ifdef FIRM_HAVE_LIBZ
-#include <zlib.h>
-
-#define mfprintf gzprintf
-static gzFile stat_ev_file = NULL;
-
-#else
-
-#define mfprintf fprintf
-static FILE* stat_ev_file = NULL;
-
-#endif /* FIRM_HAVE_LIBZ */
+static FILE* stat_ev_file = NULL;
int stat_ev_enabled = 0;
int stat_ev_timer_sp = 0;
timing_ticks_t stat_ev_timer_elapsed[MAX_TIMER];
timing_ticks_t stat_ev_timer_start[MAX_TIMER];
int stat_ev_enabled = 0;
int stat_ev_timer_sp = 0;
timing_ticks_t stat_ev_timer_elapsed[MAX_TIMER];
timing_ticks_t stat_ev_timer_start[MAX_TIMER];
-#ifdef FIRM_HAVE_REGEX
-#include <regex.h>
static regex_t regex;
static regex_t *filter = NULL;
static inline int key_matches(const char *key)
static regex_t regex;
static regex_t *filter = NULL;
static inline int key_matches(const char *key)
@@
-82,28
+61,12
@@
static inline int key_matches(const char *key)
return regexec(filter, key, 0, NULL, 0) == 0;
}
return regexec(filter, key, 0, NULL, 0) == 0;
}
-#else
-static char filter[128] = { '\0' };
-static inline int key_matches(const char *key)
-{
- int i = 0;
-
- for (i = 0; filter[i] != '\0'; ++i) {
- if (key[i] != filter[i])
- return 0;
- }
-
- return 1;
-}
-#endif /* FIRM_HAVE_REGEX */
-
-
void stat_ev_printf(char ev, const char *key, const char *fmt, ...)
{
if (!key_matches(key))
return;
void stat_ev_printf(char ev, const char *key, const char *fmt, ...)
{
if (!key_matches(key))
return;
-
m
fprintf(stat_ev_file, "%c;%s", ev, key);
+ fprintf(stat_ev_file, "%c;%s", ev, key);
if (fmt != NULL) {
char buf[256];
va_list args;
if (fmt != NULL) {
char buf[256];
va_list args;
@@
-111,31
+74,22
@@
void stat_ev_printf(char ev, const char *key, const char *fmt, ...)
va_start(args, fmt);
ir_vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
va_start(args, fmt);
ir_vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
-
m
fprintf(stat_ev_file, ";%s", buf);
+ fprintf(stat_ev_file, ";%s", buf);
}
}
-
m
fprintf(stat_ev_file, "\n");
+ fprintf(stat_ev_file, "\n");
}
void stat_ev_begin(const char *prefix, const char *filt)
{
char buf[512];
}
void stat_ev_begin(const char *prefix, const char *filt)
{
char buf[512];
-#ifdef FIRM_HAVE_LIBZ
- snprintf(buf, sizeof(buf), "%s.ev.gz", prefix);
- stat_ev_file = gzopen(buf, "wt9");
-#else
snprintf(buf, sizeof(buf), "%s.ev", prefix);
stat_ev_file = fopen(buf, "wt");
snprintf(buf, sizeof(buf), "%s.ev", prefix);
stat_ev_file = fopen(buf, "wt");
-#endif
if (filt && filt[0] != '\0') {
if (filt && filt[0] != '\0') {
-#ifdef FIRM_HAVE_REGEX
filter = NULL;
if (regcomp(®ex, filt, REG_EXTENDED) == 0)
filter = ®ex;
filter = NULL;
if (regcomp(®ex, filt, REG_EXTENDED) == 0)
filter = ®ex;
-#else
- strncpy(filter, filt, sizeof(filter) - sizeof(filter[0]));
-#endif /* FIRM_HAVE_REGEX */
}
stat_ev_enabled = stat_ev_file != NULL;
}
stat_ev_enabled = stat_ev_file != NULL;
@@
-144,13
+98,10
@@
void stat_ev_begin(const char *prefix, const char *filt)
void stat_ev_end(void)
{
if (stat_ev_file) {
void stat_ev_end(void)
{
if (stat_ev_file) {
-#ifdef FIRM_HAVE_LIBZ
- gzflush(stat_ev_file, 1);
- gzclose(stat_ev_file);
-#else
fclose(stat_ev_file);
fclose(stat_ev_file);
-#endif
}
}
+ if (filter != NULL)
+ regfree(filter);
}
#endif
}
#endif