util.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9#ifndef SQUID_UTIL_H
10#define SQUID_UTIL_H
11
12#if HAVE_ARPA_INET_H
13#include <arpa/inet.h>
14#endif
15
16SQUIDCEXTERN void Tolower(char *);
17
18SQUIDCEXTERN double xpercent(double part, double whole);
19SQUIDCEXTERN int xpercentInt(double part, double whole);
20SQUIDCEXTERN double xdiv(double nom, double denom);
21
22SQUIDCEXTERN const char *xitoa(int num);
23SQUIDCEXTERN const char *xint64toa(int64_t num);
24
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 *);
37SQUIDCEXTERN const char *double_to_str(char *buf, int buf_size, double value);
38extern const char *gb_to_str(const gb_t *);
39extern void gb_flush(gb_t *); /* internal, do not use this */
40
41/*
42 * Returns the amount of known allocated memory
43 */
44int statMemoryAccounted(void);
45
46SQUIDCEXTERN unsigned int RoundTo(const unsigned int num, const unsigned int what);
47
48#endif /* SQUID_UTIL_H */
49
#define SQUIDCEXTERN
Definition: squid.h:21
Definition: util.h:25
size_t bytes
Definition: util.h:27
size_t count
Definition: util.h:26
size_t gb
Definition: util.h:28
SQUIDCEXTERN int xpercentInt(double part, double whole)
Definition: util.c:46
SQUIDCEXTERN double xpercent(double part, double whole)
Definition: util.c:40
void gb_flush(gb_t *)
Definition: util.c:77
SQUIDCEXTERN double xdiv(double nom, double denom)
Definition: util.c:53
SQUIDCEXTERN const char * xint64toa(int64_t num)
Definition: util.c:69
const char * gb_to_str(const gb_t *)
Definition: util.c:105
SQUIDCEXTERN const char * double_to_str(char *buf, int buf_size, double value)
Definition: util.c:90
double gb_to_double(const gb_t *)
Definition: util.c:84
SQUIDCEXTERN const char * xitoa(int num)
Definition: util.c:60
int statMemoryAccounted(void)
SQUIDCEXTERN void Tolower(char *)
Definition: util.c:28
SQUIDCEXTERN unsigned int RoundTo(const unsigned int num, const unsigned int what)
Definition: util.c:134

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors