]> git.ipfire.org Git - thirdparty/squid.git/blame - include/util.h
Refactor memory pools statistics gathering (#1186)
[thirdparty/squid.git] / include / util.h
CommitLineData
090089c4 1/*
bf95c10a 2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
c5dd4956 3 *
5c193dec
AJ
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
090089c4 7 */
01fe0751 8
b5638623 9#ifndef SQUID_UTIL_H
10#define SQUID_UTIL_H
090089c4 11
cc192b50 12#if HAVE_ARPA_INET_H
13#include <arpa/inet.h>
14#endif
090089c4 15
e6ccf245 16SQUIDCEXTERN void Tolower(char *);
30a4f2a8 17
e6ccf245 18SQUIDCEXTERN double xpercent(double part, double whole);
19SQUIDCEXTERN int xpercentInt(double part, double whole);
20SQUIDCEXTERN double xdiv(double nom, double denom);
7021844c 21
e6ccf245 22SQUIDCEXTERN const char *xitoa(int num);
47f6e231 23SQUIDCEXTERN const char *xint64toa(int64_t num);
7021844c 24
d96ceb8e 25typedef struct {
26 size_t count;
27 size_t bytes;
28 size_t gb;
29} gb_t;
30
31/* gb_type operations */
32#define gb_flush_limit (0x3FFFFFFF)
33#define gb_inc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; (gb)->count++; }
34#define gb_incb(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; }
35#define gb_incc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->count+= delta; }
36extern double gb_to_double(const gb_t *);
e6ccf245 37SQUIDCEXTERN const char *double_to_str(char *buf, int buf_size, double value);
d96ceb8e 38extern const char *gb_to_str(const gb_t *);
39extern void gb_flush(gb_t *); /* internal, do not use this */
40
43d1bbe4
FC
41SQUIDCEXTERN unsigned int RoundTo(const unsigned int num, const unsigned int what);
42
b5638623 43#endif /* SQUID_UTIL_H */
f53969cc 44