projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
we can do without the odd align.h
[libfirm]
/
ir
/
stat
/
distrib.c
diff --git
a/ir/stat/distrib.c
b/ir/stat/distrib.c
index
205ba79
..
1002faa
100644
(file)
--- a/
ir/stat/distrib.c
+++ b/
ir/stat/distrib.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 1995-200
7
University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-200
8
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
*
* This file is part of libFirm.
*
@@
-17,18
+17,13
@@
* PURPOSE.
*/
* PURPOSE.
*/
-/*
- * Project: libFIRM
- * File name: ir/ir/distrib.c
- * Purpose: Statistics for Firm. Distribution tables.
- * Author: Michael Beck
- * Created:
- * CVS-ID: $Id$
- * Copyright: (c) 2004 Universität Karlsruhe
+/**
+ * @file
+ * @brief Statistics for Firm. Distribution tables.
+ * @author Michael Beck
+ * @version $Id$
*/
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#include "hashptr.h"
#include "irtools.h"
#include "hashptr.h"
#include "irtools.h"
@@
-67,9
+62,7
@@
static int int_cmp_fun(const void *elt, const void *key)
*/
distrib_tbl_t *stat_new_distrib_tbl(pset_cmp_fun cmp_func, distrib_hash_fun hash_func)
{
*/
distrib_tbl_t *stat_new_distrib_tbl(pset_cmp_fun cmp_func, distrib_hash_fun hash_func)
{
- distrib_tbl_t *res;
-
- res = xmalloc(sizeof(*res));
+ distrib_tbl_t *res = XMALLOC(distrib_tbl_t);
obstack_init(&res->cnts);
obstack_init(&res->cnts);
@@
-122,7
+115,7
@@
static distrib_entry_t *distrib_get_entry(distrib_tbl_t *tbl, const void *object
if (elem)
return elem;
if (elem)
return elem;
- elem =
obstack_alloc(&tbl->cnts, sizeof(*elem)
);
+ elem =
OALLOC(&tbl->cnts, distrib_entry_t
);
/* clear counter */
cnt_clr(&elem->cnt);
/* clear counter */
cnt_clr(&elem->cnt);
@@
-147,7
+140,7
@@
void stat_add_distrib_tbl(distrib_tbl_t *tbl, const void *object, const counter_
*/
void stat_add_int_distrib_tbl(distrib_tbl_t *tbl, int key, const counter_t *cnt)
{
*/
void stat_add_int_distrib_tbl(distrib_tbl_t *tbl, int key, const counter_t *cnt)
{
- stat_add_distrib_tbl(tbl,
(const void *)key
, cnt);
+ stat_add_distrib_tbl(tbl,
INT_TO_PTR(key)
, cnt);
}
/*
}
/*
@@
-165,7
+158,7
@@
void stat_inc_distrib_tbl(distrib_tbl_t *tbl, const void *object)
*/
void stat_inc_int_distrib_tbl(distrib_tbl_t *tbl, int key)
{
*/
void stat_inc_int_distrib_tbl(distrib_tbl_t *tbl, int key)
{
- stat_inc_distrib_tbl(tbl,
(const void *)key
);
+ stat_inc_distrib_tbl(tbl,
INT_TO_PTR(key)
);
}
/*
}
/*
@@
-184,7
+177,7
@@
void stat_insert_distrib_tbl(distrib_tbl_t *tbl, const void *object)
*/
void stat_insert_int_distrib_tbl(distrib_tbl_t *tbl, int key)
{
*/
void stat_insert_int_distrib_tbl(distrib_tbl_t *tbl, int key)
{
- stat_insert_distrib_tbl(tbl,
(const void *)key
);
+ stat_insert_distrib_tbl(tbl,
INT_TO_PTR(key)
);
}
/*
}
/*
@@
-219,23
+212,22
@@
double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl)
return 0.0;
min =
return 0.0;
min =
- max =
(int)entry->object
;
+ max =
PTR_TO_INT(entry->object)
;
sum = cnt_to_dbl(&entry->cnt);
for (entry = pset_next(tbl->hash_map); entry; entry = pset_next(tbl->hash_map)) {
sum = cnt_to_dbl(&entry->cnt);
for (entry = pset_next(tbl->hash_map); entry; entry = pset_next(tbl->hash_map)) {
- int value =
(int)entry->object
;
+ int value =
PTR_TO_INT(entry->object)
;
if (value < min)
min = value;
if (value < min)
min = value;
- if (value > max)
;
+ if (value > max)
max = value;
sum += cnt_to_dbl(&entry->cnt);
}
count = max - min + 1;
max = value;
sum += cnt_to_dbl(&entry->cnt);
}
count = max - min + 1;
- }
- else {
+ } else {
sum = 0.0;
count = 0;
foreach_pset(tbl->hash_map, entry) {
sum = 0.0;
count = 0;
foreach_pset(tbl->hash_map, entry) {
@@
-261,11
+253,10
@@
double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl)
return 0.0;
foreach_pset(tbl->hash_map, entry) {
return 0.0;
foreach_pset(tbl->hash_map, entry) {
- sum += cnt_to_dbl(&entry->cnt) *
(int)entry->object
;
+ sum += cnt_to_dbl(&entry->cnt) *
PTR_TO_INT(entry->object)
;
count += cnt_to_uint(&entry->cnt);
}
count += cnt_to_uint(&entry->cnt);
}
- }
- else {
+ } else {
foreach_pset(tbl->hash_map, entry) {
sum += cnt_to_dbl(&entry->cnt);
++count;
foreach_pset(tbl->hash_map, entry) {
sum += cnt_to_dbl(&entry->cnt);
++count;