1 /**
2   * D header file for NetBSD sys/sysctl.h
3   *
4   * Copyright: Copyright © 2021, The D Language Foundation
5   * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
6   * Authors: Iain Buclaw
7   */
8 module core.sys.netbsd.sys.sysctl;
9 
10 version (NetBSD):
11 extern (C):
12 nothrow:
13 @nogc:
14 
15 // Top-level identifiers
16 enum
17 {
18     CTL_UNSPEC   = 0,
19     CTL_KERN     = 1,
20     CTL_VM       = 2,
21     CTL_VFS      = 3,
22     CTL_NET      = 4,
23     CTL_DEBUG    = 5,
24     CTL_HW       = 6,
25     CTL_MACHDEP  = 7,
26     CTL_DDB      = 9,
27     CTL_PROC     = 10,
28     CTL_VENDOR   = 11,
29     CTL_EMUL     = 12,
30     CTL_SECURITY = 13,
31 }
32 
33 // CTL_KERN identifiers
34 enum
35 {
36     KERN_OSTYPE            = 1,
37     KERN_OSRELEASE         = 2,
38     KERN_OSREV             = 3,
39     KERN_VERSION           = 4,
40     KERN_MAXVNODES         = 5,
41     KERN_MAXPROC           = 6,
42     KERN_MAXFILES          = 7,
43     KERN_ARGMAX            = 8,
44     KERN_SECURELVL         = 9,
45     KERN_HOSTNAME          = 10,
46     KERN_HOSTID            = 11,
47     KERN_CLOCKRATE         = 12,
48     KERN_VNODE             = 13,
49     KERN_PROC              = 14,
50     KERN_FILE              = 15,
51     KERN_PROF              = 16,
52     KERN_POSIX1            = 17,
53     KERN_NGROUPS           = 18,
54     KERN_JOB_CONTROL       = 19,
55     KERN_SAVED_IDS         = 20,
56     KERN_OBOOTTIME         = 21,
57     KERN_DOMAINNAME        = 22,
58     KERN_MAXPARTITIONS     = 23,
59     KERN_RAWPARTITION      = 24,
60     KERN_NTPTIME           = 25,
61     KERN_TIMEX             = 26,
62     KERN_AUTONICETIME      = 27,
63     KERN_AUTONICEVAL       = 28,
64     KERN_RTC_OFFSET        = 29,
65     KERN_ROOT_DEVICE       = 30,
66     KERN_MSGBUFSIZE        = 31,
67     KERN_FSYNC             = 32,
68     KERN_OLDSYSVMSG        = 33,
69     KERN_OLDSYSVSEM        = 34,
70     KERN_OLDSYSVSHM        = 35,
71     KERN_OLDSHORTCORENAME  = 36,
72     KERN_SYNCHRONIZED_IO   = 37,
73     KERN_IOV_MAX           = 38,
74     KERN_MBUF              = 39,
75     KERN_MAPPED_FILES      = 40,
76     KERN_MEMLOCK           = 41,
77     KERN_MEMLOCK_RANGE     = 42,
78     KERN_MEMORY_PROTECTION = 43,
79     KERN_LOGIN_NAME_MAX    = 44,
80     KERN_DEFCORENAME       = 45,
81     KERN_LOGSIGEXIT        = 46,
82     KERN_PROC2             = 47,
83     KERN_PROC_ARGS         = 48,
84     KERN_FSCALE            = 49,
85     KERN_CCPU              = 50,
86     KERN_CP_TIME           = 51,
87     KERN_OLDSYSVIPC_INFO   = 52,
88     KERN_MSGBUF            = 53,
89     KERN_CONSDEV           = 54,
90     KERN_MAXPTYS           = 55,
91     KERN_PIPE              = 56,
92     KERN_MAXPHYS           = 57,
93     KERN_SBMAX             = 58,
94     KERN_TKSTAT            = 59,
95     KERN_MONOTONIC_CLOCK   = 60,
96     KERN_URND              = 61,
97     KERN_LABELSECTOR       = 62,
98     KERN_LABELOFFSET       = 63,
99     KERN_LWP               = 64,
100     KERN_FORKFSLEEP        = 65,
101     KERN_POSIX_THREADS     = 66,
102     KERN_POSIX_SEMAPHORES  = 67,
103     KERN_POSIX_BARRIERS    = 68,
104     KERN_POSIX_TIMERS      = 69,
105     KERN_POSIX_SPIN_LOCKS  = 70,
106     KERN_POSIX_READER_WRITER_LOCKS = 71,
107     KERN_DUMP_ON_PANIC     = 72,
108     KERN_SOMAXKVA          = 73,
109     KERN_ROOT_PARTITION    = 74,
110     KERN_DRIVERS           = 75,
111     KERN_BUF               = 76,
112     KERN_FILE2             = 77,
113     KERN_VERIEXEC          = 78,
114     KERN_CP_ID             = 79,
115     KERN_HARDCLOCK_TICKS   = 80,
116     KERN_ARND              = 81,
117     KERN_SYSVIPC           = 82,
118     KERN_BOOTTIME          = 83,
119     KERN_EVCNT             = 84,
120     KERN_SOFIXEDBUF        = 85,
121 }
122 
123 // KERN_PROC subtypes
124 enum
125 {
126     KERN_PROC_ALL     = 0,
127     KERN_PROC_PID     = 1,
128     KERN_PROC_PGRP    = 2,
129     KERN_PROC_SESSION = 3,
130     KERN_PROC_TTY     = 4,
131     KERN_PROC_UID     = 5,
132     KERN_PROC_RUID    = 6,
133     KERN_PROC_KTHREAD = 7,
134     KERN_PROC_RGID    = 8,
135 }
136 
137 // KERN_PROC_ARGS subtypes
138 enum
139 {
140     KERN_PROC_ARGV     = 1,
141     KERN_PROC_NARGV    = 2,
142     KERN_PROC_ENV      = 3,
143     KERN_PROC_NENV     = 4,
144     KERN_PROC_PATHNAME = 5,
145     KERN_PROC_CWD      = 6,
146 }
147 
148 // KERN_SYSVIPC subtypes
149 enum
150 {
151     KERN_SYSVIPC_INFO       = 1,
152     KERN_SYSVIPC_MSG        = 2,
153     KERN_SYSVIPC_SEM        = 3,
154     KERN_SYSVIPC_SHM        = 4,
155     KERN_SYSVIPC_SHMMAX     = 5,
156     KERN_SYSVIPC_SHMMNI     = 6,
157     KERN_SYSVIPC_SHMSEG     = 7,
158     KERN_SYSVIPC_SHMMAXPGS  = 8,
159     KERN_SYSVIPC_SHMUSEPHYS = 9,
160 }
161 
162 // KERN_SYSVIPC_INFO subtypes
163 enum
164 {
165     KERN_SYSVIPC_MSG_INFO = 4,
166     KERN_SYSVIPC_SEM_INFO = 5,
167     KERN_SYSVIPC_SHM_INFO = 6,
168 }
169 
170 // KERN_TKSTAT subtypes
171 enum
172 {
173     KERN_TKSTAT_NIN   = 1,
174     KERN_TKSTAT_NOUT  = 2,
175     KERN_TKSTAT_CANCC = 3,
176     KERN_TKSTAT_RAWCC = 4,
177 }
178 
179 // KERN_BUF subtypes
180 enum
181 {
182     KERN_BUF_ALL = 0,
183 }
184 
185 // KERN_FILE
186 enum
187 {
188     KERN_FILE_BYFILE = 1,
189     KERN_FILE_BYPID  = 2,
190     KERN_FILESLOP    = 10,
191 }
192 
193 // KERN_EVCNT
194 enum
195 {
196     KERN_EVCNT_COUNT_ANY = 0,
197     KERN_EVCNT_COUNT_NONZERO = 1,
198 }
199 
200 // CTL_HW identifiers
201 enum
202 {
203     HW_MACHINE      = 1,
204     HW_MODEL        = 2,
205     HW_NCPU         = 3,
206     HW_BYTEORDER    = 4,
207     HW_PHYSMEM      = 5,
208     HW_USERMEM      = 6,
209     HW_PAGESIZE     = 7,
210     HW_DISKNAMES    = 8,
211     HW_IOSTATS      = 9,
212     HW_MACHINE_ARCH = 10,
213     HW_ALIGNBYTES   = 11,
214     HW_CNMAGIC      = 12,
215     HW_PHYSMEM64    = 13,
216     HW_USERMEM64    = 14,
217     HW_IOSTATNAMES  = 15,
218     HW_NCPUONLINE   = 16,
219 }
220 
221 //  CTL_USER definitions
222 enum
223 {
224     USER_CS_PATH          = 1,
225     USER_BC_BASE_MAX      = 2,
226     USER_BC_DIM_MAX       = 3,
227     USER_BC_SCALE_MAX     = 4,
228     USER_BC_STRING_MAX    = 5,
229     USER_COLL_WEIGHTS_MAX = 6,
230     USER_EXPR_NEST_MAX    = 7,
231     USER_LINE_MAX         = 8,
232     USER_RE_DUP_MAX       = 9,
233     USER_POSIX2_VERSION   = 10,
234     USER_POSIX2_C_BIND    = 11,
235     USER_POSIX2_C_DEV     = 12,
236     USER_POSIX2_CHAR_TERM = 13,
237     USER_POSIX2_FORT_DEV  = 14,
238     USER_POSIX2_FORT_RUN  = 15,
239     USER_POSIX2_LOCALEDEF = 16,
240     USER_POSIX2_SW_DEV    = 17,
241     USER_POSIX2_UPE       = 18,
242     USER_STREAM_MAX       = 19,
243     USER_TZNAME_MAX       = 20,
244     USER_ATEXIT_MAX       = 21,
245 }
246 
247 ///
248 int sysctl(const int* name, uint namelen, void* oldp, size_t* oldlenp,
249            const void* newp, size_t newlen);
250 ///
251 int sysctlbyname(const char* name, void* oldp, size_t* oldlenp,
252                  const void* newp, size_t newlen);
253 ///
254 int sysctlnametomib(const char* sname, int* name, size_t* namelenp);