pci core: assert ENOSPC when add capability
[qemu/cris-port.git] / include / qemu / qdist.h
blobf30050c2d1c2462c6125e4494afd3aa91bad78d9
1 /*
2 * Copyright (C) 2016, Emilio G. Cota <cota@braap.org>
4 * License: GNU GPL, version 2 or later.
5 * See the COPYING file in the top-level directory.
6 */
7 #ifndef QEMU_QDIST_H
8 #define QEMU_QDIST_H
10 #include "qemu/osdep.h"
11 #include "qemu-common.h"
12 #include "qemu/bitops.h"
15 * Samples with the same 'x value' end up in the same qdist_entry,
16 * e.g. inc(0.1) and inc(0.1) end up as {x=0.1, count=2}.
18 * Binning happens only at print time, so that we retain the flexibility to
19 * choose the binning. This might not be ideal for workloads that do not care
20 * much about precision and insert many samples all with different x values;
21 * in that case, pre-binning (e.g. entering both 0.115 and 0.097 as 0.1)
22 * should be considered.
24 struct qdist_entry {
25 double x;
26 unsigned long count;
29 struct qdist {
30 struct qdist_entry *entries;
31 size_t n;
32 size_t size;
35 #define QDIST_PR_BORDER BIT(0)
36 #define QDIST_PR_LABELS BIT(1)
37 /* the remaining options only work if PR_LABELS is set */
38 #define QDIST_PR_NODECIMAL BIT(2)
39 #define QDIST_PR_PERCENT BIT(3)
40 #define QDIST_PR_100X BIT(4)
41 #define QDIST_PR_NOBINRANGE BIT(5)
43 void qdist_init(struct qdist *dist);
44 void qdist_destroy(struct qdist *dist);
46 void qdist_add(struct qdist *dist, double x, long count);
47 void qdist_inc(struct qdist *dist, double x);
48 double qdist_xmin(const struct qdist *dist);
49 double qdist_xmax(const struct qdist *dist);
50 double qdist_avg(const struct qdist *dist);
51 unsigned long qdist_sample_count(const struct qdist *dist);
52 size_t qdist_unique_entries(const struct qdist *dist);
54 /* callers must free the returned string with g_free() */
55 char *qdist_pr_plain(const struct qdist *dist, size_t n_groups);
57 /* callers must free the returned string with g_free() */
58 char *qdist_pr(const struct qdist *dist, size_t n_groups, uint32_t opt);
60 /* Only qdist code and test code should ever call this function */
61 void qdist_bin__internal(struct qdist *to, const struct qdist *from, size_t n);
63 #endif /* QEMU_QDIST_H */