xref: /openbsd-src/share/man/man9/kstat_kv_init.9 (revision 7592d7ef816c3d29a9fa4f76a60699357c41809d)
1.\" $OpenBSD: kstat_kv_init.9,v 1.2 2020/08/10 11:33:58 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 David Gwynne <dlg@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: August 10 2020 $
18.Dt KSTAT_KV_INIT 9
19.Os
20.Sh NAME
21.Nm kstat_kv_init ,
22.Nm kstat_kv_unit_init ,
23.Nm KSTAT_KV_INITIALIZER ,
24.Nm KSTAT_KV_UNIT_INITIALIZER
25.Nd kernel statistic key/value data API
26.Sh SYNOPSIS
27.In sys/kstat.h
28.Ft void
29.Fo kstat_kv_init
30.Fa "struct kstat_kv *kv"
31.Fa "const char *key"
32.Fa "enum kstat_kv_type type"
33.Fc
34.Ft void
35.Fo kstat_kv_unit_init
36.Fa "struct kstat_kv *kv"
37.Fa "const char *key"
38.Fa "enum kstat_kv_type type"
39.Fa "enum kstat_kv_unit unit"
40.Fc
41.Fo KSTAT_KV_INITIALIZER
42.Fa "const char *name"
43.Fa "enum kstat_kv_type type"
44.Fc
45.Fo KSTAT_KV_UNIT_INITIALIZER
46.Fa "const char *name"
47.Fa "enum kstat_kv_type type"
48.Fa "enum kstat_kv_unit unit"
49.Fc
50.Sh DESCRIPTION
51The kstat key/value data API supports the creation and maintenance of
52.Vt kstat_kv
53structures that can be exported to userland using the kstat API.
54.Pp
55A kstat key/value data payload for a
56.Vt kstat
57structure
58.Po
59created using
60.Xr kstat_create 9
61with
62.Dv KSTAT_T_KV
63as the
64.Fa type
65argument
66.Pc
67is a series of
68.Vt kstat_kv
69structures in memory.
70kstat_kv values are typed, and the memory used to store values of
71different types is either inline as part of the structure, or is
72extra bytes following a structure of a specified length.
73.\" .Pp
74.\" kstat_kv structures contain the following fields:
75.Pp
76.Fn kstat_kv_init
77initialises
78.Fa kv
79with a name specified as
80.Fa key .
81The type of the value is specified as
82.Fa type .
83.Pp
84.Fn kstat_kv_unit_init
85initialises
86.Fa kv
87with a name specified as
88.Fa key .
89The integer or counter type of the value is specified as
90.Fa type ,
91and specifies the units for the values in
92.Fa unit .
93.Pp
94A
95.Vt kstat_kv
96structure can be initialised at compile time with the
97.Fn KSTAT_KV_INITIALIZER
98macro.
99The
100.Vt kstat_kv
101structure will be declared with the name
102.Fa key
103with the type of the values as
104.Fa type .
105.Pp
106A
107.Vt kstat_kv
108structure can be initialised at compile time with the
109.Fn KSTAT_KV_UNIT_INITIALIZER
110macro.
111The
112.Vt kstat_kv
113structure will be declared with the name
114.Fa key
115with the integer or counter type of the values as
116.Fa type ,
117and specifies the units for the values in
118.Fa unit .
119.Sh SEE ALSO
120.Xr kstat_create 9
121.Sh HISTORY
122These functions first appeared in
123.Ox 6.8 .
124.Sh AUTHORS
125.An David Gwynne Aq Mt dlg@openbsd.org
126