xref: /openbsd/share/man/man9/kstat_kv_init.9 (revision 09467b48)
1.\" $OpenBSD: kstat_kv_init.9,v 1.1 2020/07/06 11:48:03 dlg 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: July 6 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
52of kstat_kv structures that can be exported to userland using the
53kstat API.
54.Pp
55A kstat key/value data payload for a kstat structure
56.Po
57created using
58.Xr kstat_create 9
59with
60.Dv KSTAT_T_KV
61as the
62.Fa type
63argument
64.Pc
65is a series of kstat_kv structures in memory.
66kstat_kv values are typed, and the memory used to store values of
67different types is either inline as part of the structure, or is
68extra bytes following a structure of a specified length.
69.\" .Pp
70.\" kstat_kv structures contain the following fields:
71.Pp
72.Fn kstat_kv_init
73initialises the kstat_kv structure
74.Fa kv
75with a name specified as
76.Fa key .
77The type of the value is specified as
78.Fa type .
79.Pp
80.Fn kstat_kv_unit_init
81initialises the kstat_kv structure
82.Fa kv
83with a name specified as
84.Fa key .
85The integer or counter type of the value is specified as
86.Fa type ,
87and specifies the units for the values in
88.Fa unit .
89.Pp
90A kstat_kv structure can be initialised at compile time with the
91.Fn KSTAT_KV_INITIALIZER
92macro.
93The kstat_kv structure will be declared with the name
94.Fa key
95with the type of the values as
96.Fa type .
97.Pp
98A kstat_kv structure can be initialised at compile time with the
99.Fn KSTAT_KV_UNIT_INITIALIZER
100macro.
101The kstat_kv structure will be declared with the name
102.Fa key
103with the integer or counter type of the values as
104.Fa type ,
105and specifies the units for the values in
106.Fa unit .
107.Sh SEE ALSO
108.Xr kstat_create 9
109