X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fstat%2Fcounter.h;h=780735c4403b61d8f727cd31ea2c1afe50c47621;hb=3da5ed2598245b896255bc444aaa1768f6098cfe;hp=27d097b83bf7e9bca7d0317fb9a29a92f2e62ad1;hpb=cc6c81cfca9c224e26bf8033fd6dad1158546502;p=libfirm diff --git a/ir/stat/counter.h b/ir/stat/counter.h index 27d097b83..780735c44 100644 --- a/ir/stat/counter.h +++ b/ir/stat/counter.h @@ -1,15 +1,30 @@ /* - * Project: libFIRM - * File name: ir/ir/counter.h - * Purpose: Statistics for Firm. Counter implementation. - * Author: Michael Beck - * Created: - * CVS-ID: $Id$ - * Copyright: (c) 2004 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. */ -#ifndef _COUNTER_H_ -#define _COUNTER_H_ + +/** + * @file + * @brief Statistics for Firm. Counter implementation. + * @author Michael Beck + * @version $Id$ + */ +#ifndef FIRM_STAT_COUNTER_H +#define FIRM_STAT_COUNTER_H #include #include @@ -25,10 +40,13 @@ typedef struct _counter_t { unsigned cnt[STAT_CNT_NUM]; } counter_t; +/** initializes a counter with zero */ +#define ZERO_CNT { { 0 } } + /** * increase a counter */ -static INLINE void cnt_inc(counter_t *cnt) +static inline void cnt_inc(counter_t *cnt) { int i; @@ -41,12 +59,12 @@ static INLINE void cnt_inc(counter_t *cnt) /** * decrease a counter */ -static INLINE void cnt_dec(counter_t *cnt) +static inline void cnt_dec(counter_t *cnt) { int i; for (i = 0; i < STAT_CNT_NUM; ++i) { - if (--cnt->cnt[i] != -1) + if (--cnt->cnt[i] != (unsigned) -1) break; } } @@ -54,7 +72,7 @@ static INLINE void cnt_dec(counter_t *cnt) /** * set a counter to zero */ -static INLINE void cnt_clr(counter_t *cnt) +static inline void cnt_clr(counter_t *cnt) { memset(cnt->cnt, 0, sizeof(cnt->cnt)); } @@ -62,7 +80,7 @@ static INLINE void cnt_clr(counter_t *cnt) /** * add a counter to another */ -static INLINE void cnt_add(counter_t *dst, const counter_t *src) +static inline void cnt_add(counter_t *dst, const counter_t *src) { int i, carry = 0; @@ -80,7 +98,7 @@ static INLINE void cnt_add(counter_t *dst, const counter_t *src) /** * add an (positive) integer to an counter */ -static INLINE void cnt_add_i(counter_t *dst, int src) +static inline void cnt_add_i(counter_t *dst, int src) { int i; unsigned carry = src; @@ -100,10 +118,11 @@ static INLINE void cnt_add_i(counter_t *dst, int src) /** * compare two counter */ -static INLINE int cnt_cmp(const counter_t *a, const counter_t *b) +static inline int cnt_cmp(const counter_t *a, const counter_t *b) { int i; - unsigned va, vb; + unsigned va = 0; + unsigned vb = 0; for (i = STAT_CNT_NUM - 1 ; i >= 0; --i) { va = a->cnt[i]; @@ -121,7 +140,7 @@ static INLINE int cnt_cmp(const counter_t *a, const counter_t *b) /** * convert a counter into a double */ -static INLINE double cnt_to_dbl(const counter_t *a) +static inline double cnt_to_dbl(const counter_t *a) { int i; double res = 0.0, scale = 1.0, tmp; @@ -140,7 +159,7 @@ static INLINE double cnt_to_dbl(const counter_t *a) /** * convert a counter into an unsigned */ -static INLINE unsigned cnt_to_uint(const counter_t *a) +static inline unsigned cnt_to_uint(const counter_t *a) { int i; @@ -154,7 +173,7 @@ static INLINE unsigned cnt_to_uint(const counter_t *a) /** * check, if a counter is equal to an unsigned */ -static INLINE int cnt_eq(const counter_t *a, unsigned value) +static inline int cnt_eq(const counter_t *a, unsigned value) { int i; @@ -168,7 +187,7 @@ static INLINE int cnt_eq(const counter_t *a, unsigned value) /** * check, if a counter as greater than an unsigned */ -static INLINE int cnt_gt(const counter_t *a, unsigned value) +static inline int cnt_gt(const counter_t *a, unsigned value) { int i; @@ -179,4 +198,4 @@ static INLINE int cnt_gt(const counter_t *a, unsigned value) return a->cnt[0] > value; } -#endif /* _COUNTER_H_ */ +#endif /* FIRM_STAT_COUNTER_H */