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
2f8e6da
..
1002faa
100644
(file)
--- a/
ir/stat/distrib.c
+++ b/
ir/stat/distrib.c
@@
-23,9
+23,7
@@
* @author Michael Beck
* @version $Id$
*/
* @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"
@@
-35,21
+33,24
@@
/**
* calculates a hash value for an address
*/
/**
* calculates a hash value for an address
*/
-static unsigned addr_hash(const void *object) {
+static unsigned addr_hash(const void *object)
+{
return HASH_PTR(object);
}
/**
* calculates a hash value for an integer
*/
return HASH_PTR(object);
}
/**
* calculates a hash value for an integer
*/
-static unsigned int_hash(const void *object) {
+static unsigned int_hash(const void *object)
+{
return (unsigned)PTR_TO_INT(object);
}
/**
* compare function for integer distribution tables
*/
return (unsigned)PTR_TO_INT(object);
}
/**
* compare function for integer distribution tables
*/
-static int int_cmp_fun(const void *elt, const void *key) {
+static int int_cmp_fun(const void *elt, const void *key)
+{
const distrib_entry_t *p1 = elt;
const distrib_entry_t *p2 = key;
const distrib_entry_t *p1 = elt;
const distrib_entry_t *p2 = key;
@@
-59,10
+60,9
@@
static int int_cmp_fun(const void *elt, const void *key) {
/*
* create a new distribution table
*/
/*
* 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 *stat_new_distrib_tbl(pset_cmp_fun cmp_func, distrib_hash_fun hash_func)
+{
+ distrib_tbl_t *res = XMALLOC(distrib_tbl_t);
obstack_init(&res->cnts);
obstack_init(&res->cnts);
@@
-77,7
+77,8
@@
distrib_tbl_t *stat_new_distrib_tbl(pset_cmp_fun cmp_func, distrib_hash_fun hash
/*
* create a new distribution table for an integer distribution
*/
/*
* create a new distribution table for an integer distribution
*/
-distrib_tbl_t *stat_new_int_distrib_tbl(void) {
+distrib_tbl_t *stat_new_int_distrib_tbl(void)
+{
distrib_tbl_t *res = stat_new_distrib_tbl(int_cmp_fun, int_hash);
if (res)
distrib_tbl_t *res = stat_new_distrib_tbl(int_cmp_fun, int_hash);
if (res)
@@
-89,7
+90,8
@@
distrib_tbl_t *stat_new_int_distrib_tbl(void) {
/*
* destroy a distribution table
*/
/*
* destroy a distribution table
*/
-void stat_delete_distrib_tbl(distrib_tbl_t *tbl) {
+void stat_delete_distrib_tbl(distrib_tbl_t *tbl)
+{
if (tbl) {
/* free all entries */
obstack_free(&tbl->cnts, NULL);
if (tbl) {
/* free all entries */
obstack_free(&tbl->cnts, NULL);
@@
-102,7
+104,8
@@
void stat_delete_distrib_tbl(distrib_tbl_t *tbl) {
/**
* Returns the associates distrib_entry_t for an object
*/
/**
* Returns the associates distrib_entry_t for an object
*/
-static distrib_entry_t *distrib_get_entry(distrib_tbl_t *tbl, const void *object) {
+static distrib_entry_t *distrib_get_entry(distrib_tbl_t *tbl, const void *object)
+{
distrib_entry_t key;
distrib_entry_t *elem;
distrib_entry_t key;
distrib_entry_t *elem;
@@
-112,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);
@@
-125,7
+128,8
@@
static distrib_entry_t *distrib_get_entry(distrib_tbl_t *tbl, const void *object
/*
* adds a new object count into the distribution table
*/
/*
* adds a new object count into the distribution table
*/
-void stat_add_distrib_tbl(distrib_tbl_t *tbl, const void *object, const counter_t *cnt) {
+void stat_add_distrib_tbl(distrib_tbl_t *tbl, const void *object, const counter_t *cnt)
+{
distrib_entry_t *elem = distrib_get_entry(tbl, object);
cnt_add(&elem->cnt, cnt);
distrib_entry_t *elem = distrib_get_entry(tbl, object);
cnt_add(&elem->cnt, cnt);
@@
-134,14
+138,16
@@
void stat_add_distrib_tbl(distrib_tbl_t *tbl, const void *object, const counter_
/*
* adds a new key count into the integer distribution table
*/
/*
* 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) {
+void stat_add_int_distrib_tbl(distrib_tbl_t *tbl, int key, const counter_t *cnt)
+{
stat_add_distrib_tbl(tbl, INT_TO_PTR(key), cnt);
}
/*
* increases object count by one
*/
stat_add_distrib_tbl(tbl, INT_TO_PTR(key), cnt);
}
/*
* increases object count by one
*/
-void stat_inc_distrib_tbl(distrib_tbl_t *tbl, const void *object) {
+void stat_inc_distrib_tbl(distrib_tbl_t *tbl, const void *object)
+{
distrib_entry_t *elem = distrib_get_entry(tbl, object);
cnt_inc(&elem->cnt);
distrib_entry_t *elem = distrib_get_entry(tbl, object);
cnt_inc(&elem->cnt);
@@
-150,7
+156,8
@@
void stat_inc_distrib_tbl(distrib_tbl_t *tbl, const void *object) {
/*
* increases key count by one
*/
/*
* increases key count by one
*/
-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, INT_TO_PTR(key));
}
stat_inc_distrib_tbl(tbl, INT_TO_PTR(key));
}
@@
-158,7
+165,8
@@
void stat_inc_int_distrib_tbl(distrib_tbl_t *tbl, int key) {
* inserts a new object with count 0 into the distribution table
* if object is already present, nothing happens
*/
* inserts a new object with count 0 into the distribution table
* if object is already present, nothing happens
*/
-void stat_insert_distrib_tbl(distrib_tbl_t *tbl, const void *object) {
+void stat_insert_distrib_tbl(distrib_tbl_t *tbl, const void *object)
+{
/* executed for side effect */
(void)distrib_get_entry(tbl, object);
}
/* executed for side effect */
(void)distrib_get_entry(tbl, object);
}
@@
-167,14
+175,16
@@
void stat_insert_distrib_tbl(distrib_tbl_t *tbl, const void *object) {
* inserts a new key with count 0 into the integer distribution table
* if key is already present, nothing happens
*/
* inserts a new key with count 0 into the integer distribution table
* if key is already present, nothing happens
*/
-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, INT_TO_PTR(key));
}
/*
* returns the sum over all counters in a distribution table
*/
stat_insert_distrib_tbl(tbl, INT_TO_PTR(key));
}
/*
* returns the sum over all counters in a distribution table
*/
-int stat_get_count_distrib_tbl(distrib_tbl_t *tbl) {
+int stat_get_count_distrib_tbl(distrib_tbl_t *tbl)
+{
distrib_entry_t *entry;
counter_t cnt = ZERO_CNT;
distrib_entry_t *entry;
counter_t cnt = ZERO_CNT;
@@
-186,7
+196,8
@@
int stat_get_count_distrib_tbl(distrib_tbl_t *tbl) {
/*
* calculates the mean value of a distribution
*/
/*
* calculates the mean value of a distribution
*/
-double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl) {
+double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl)
+{
distrib_entry_t *entry;
unsigned count;
double sum;
distrib_entry_t *entry;
unsigned count;
double sum;
@@
-231,7
+242,8
@@
double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl) {
/*
* calculates the average value of a distribution
*/
/*
* calculates the average value of a distribution
*/
-double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl) {
+double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl)
+{
distrib_entry_t *entry;
unsigned count = 0;
double sum = 0.0;
distrib_entry_t *entry;
unsigned count = 0;
double sum = 0.0;
@@
-257,7
+269,8
@@
double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl) {
/**
* iterates over all entries in a distribution table
*/
/**
* iterates over all entries in a distribution table
*/
-void stat_iterate_distrib_tbl(const distrib_tbl_t *tbl, eval_distrib_entry_fun eval, void *env) {
+void stat_iterate_distrib_tbl(const distrib_tbl_t *tbl, eval_distrib_entry_fun eval, void *env)
+{
distrib_entry_t *entry;
foreach_pset(tbl->hash_map, entry)
distrib_entry_t *entry;
foreach_pset(tbl->hash_map, entry)