-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathutil.h
70 lines (60 loc) · 1.77 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Wrappers around strtoull/strtoll that are safer and easier to
* use. For tests and assumptions, see internal_tests.c.
*
* str a NULL-terminated base decimal 10 unsigned integer
* out out parameter, if conversion succeeded
*
* returns true if conversion succeeded.
*/
bool safe_strtoull(const char *str, uint64_t *out);
bool safe_strtoll(const char *str, int64_t *out);
bool safe_strtoul(const char *str, uint32_t *out);
bool safe_strtol(const char *str, int32_t *out);
/* This was stolen from the glibc docs.
Why they'd write documentation to show how to do this vs. just
provide the function is unclear.
*/
int timeval_subtract(struct timeval *result,
struct timeval *x, struct timeval *y);
/**
* Convert a timeval to a simple double.
*
* This is generally useful for deltas.
*/
double timeval_to_double(struct timeval tv);
struct moxi_stats {
double min;
double max;
double avg;
double stddev;
double ninetyfifth;
};
/**
* Compute some statistics over a sequence.
*
* @param out accumulated stats for input values
* @param vals input values (note: these will be reordered)
* @param num_values the number of values to be processed
*/
void compute_stats(struct moxi_stats *out, double *vals, int num_vals);
/* should be fixed in libconflate instead */
#ifdef __gcc_attribute__
#undef __gcc_attribute__
#endif
#ifdef __GCC
# define __gcc_attribute__ __attribute__
#else
# define __gcc_attribute__(x)
#endif
/**
* Vararg variant of perror that makes for more useful error messages
* when reporting with parameters.
*
* @param fmt a printf format
*/
void vperror(const char *fmt, ...)
__gcc_attribute__ ((format (printf, 1, 2)));
#undef __gcc_attribute__
uint64_t ntohll(uint64_t value);
uint64_t htonll(uint64_t value);