]>
Commit | Line | Data |
---|---|---|
090089c4 | 1 | /* |
77b1029d | 2 | * Copyright (C) 1996-2020 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 | |
9d90e665 | 12 | #if HAVE_TIME_H |
13 | #include <time.h> | |
14 | #endif | |
cc192b50 | 15 | #if HAVE_ARPA_INET_H |
16 | #include <arpa/inet.h> | |
17 | #endif | |
090089c4 | 18 | |
e6ccf245 | 19 | SQUIDCEXTERN int tvSubUsec(struct timeval, struct timeval); |
20 | SQUIDCEXTERN double tvSubDsec(struct timeval, struct timeval); | |
e6ccf245 | 21 | SQUIDCEXTERN void Tolower(char *); |
30a4f2a8 | 22 | |
e6ccf245 | 23 | SQUIDCEXTERN time_t parse_iso3307_time(const char *buf); |
6ad85e8a | 24 | |
e6ccf245 | 25 | SQUIDCEXTERN double xpercent(double part, double whole); |
26 | SQUIDCEXTERN int xpercentInt(double part, double whole); | |
27 | SQUIDCEXTERN double xdiv(double nom, double denom); | |
7021844c | 28 | |
e6ccf245 | 29 | SQUIDCEXTERN const char *xitoa(int num); |
47f6e231 | 30 | SQUIDCEXTERN const char *xint64toa(int64_t num); |
7021844c | 31 | |
d96ceb8e | 32 | typedef struct { |
33 | size_t count; | |
34 | size_t bytes; | |
35 | size_t gb; | |
36 | } gb_t; | |
37 | ||
38 | /* gb_type operations */ | |
39 | #define gb_flush_limit (0x3FFFFFFF) | |
40 | #define gb_inc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; (gb)->count++; } | |
41 | #define gb_incb(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; } | |
42 | #define gb_incc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->count+= delta; } | |
43 | extern double gb_to_double(const gb_t *); | |
e6ccf245 | 44 | SQUIDCEXTERN const char *double_to_str(char *buf, int buf_size, double value); |
d96ceb8e | 45 | extern const char *gb_to_str(const gb_t *); |
46 | extern void gb_flush(gb_t *); /* internal, do not use this */ | |
47 | ||
2d72d4fd | 48 | /* |
49 | * Returns the amount of known allocated memory | |
50 | */ | |
51 | int statMemoryAccounted(void); | |
52 | ||
43d1bbe4 FC |
53 | SQUIDCEXTERN unsigned int RoundTo(const unsigned int num, const unsigned int what); |
54 | ||
b5638623 | 55 | #endif /* SQUID_UTIL_H */ |
f53969cc | 56 |