X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fstat%2Fdistrib.c;h=08c358dc2dbefc01a1e050afb67c113c70aa7934;hb=2af4a97900b435e35d7c20350604e3863aff2b4c;hp=4a74b0416fb4faeeabae76fc848463a860995d90;hpb=f430a768a5b70618597871d6bbc1c212d2b325c1;p=libfirm diff --git a/ir/stat/distrib.c b/ir/stat/distrib.c index 4a74b0416..08c358dc2 100644 --- a/ir/stat/distrib.c +++ b/ir/stat/distrib.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -23,9 +23,7 @@ * @author Michael Beck * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #include "hashptr.h" #include "irtools.h" @@ -60,9 +58,7 @@ static int int_cmp_fun(const void *elt, const void *key) { * create a new distribution table */ 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); @@ -112,7 +108,7 @@ static distrib_entry_t *distrib_get_entry(distrib_tbl_t *tbl, const void *object if (elem) return elem; - elem = obstack_alloc(&tbl->cnts, sizeof(*elem)); + elem = OALLOC(&tbl->cnts, distrib_entry_t); /* clear counter */ cnt_clr(&elem->cnt); @@ -135,7 +131,7 @@ void stat_add_distrib_tbl(distrib_tbl_t *tbl, const void *object, const counter_ * adds a new key count into the integer distribution table */ 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); } /* @@ -151,7 +147,7 @@ void stat_inc_distrib_tbl(distrib_tbl_t *tbl, const void *object) { * increases key count by one */ 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)); } /* @@ -168,7 +164,7 @@ void stat_insert_distrib_tbl(distrib_tbl_t *tbl, const void *object) { * if key is already present, nothing happens */ 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)); } /* @@ -201,12 +197,12 @@ double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl) { 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)) { - int value = (int)entry->object; + int value = PTR_TO_INT(entry->object); if (value < min) min = value; @@ -241,7 +237,7 @@ double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl) { 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); } } else {