The OpenD Programming Language

1 /**
2   * D header file for Darwin 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.darwin.sys.sysctl;
9 
10 version (OSX)
11     version = Darwin;
12 else version (iOS)
13     version = Darwin;
14 else version (TVOS)
15     version = Darwin;
16 else version (WatchOS)
17     version = Darwin;
18 
19 version (Darwin):
20 extern (C):
21 nothrow:
22 @nogc:
23 
24 // Top-level identifiers
25 enum
26 {
27     CTL_UNSPEC   = 0,
28     CTL_KERN     = 1,
29     CTL_VM       = 2,
30     CTL_VFS      = 3,
31     CTL_NET      = 4,
32     CTL_DEBUG    = 5,
33     CTL_HW       = 6,
34     CTL_MACHDEP  = 7,
35     CTL_USER     = 8,
36     CTL_MAXID    = 9,
37 }
38 
39 // CTL_KERN identifiers
40 enum
41 {
42     KERN_OSTYPE             = 1,
43     KERN_OSRELEASE          = 2,
44     KERN_OSREV              = 3,
45     KERN_VERSION            = 4,
46     KERN_MAXVNODES          = 5,
47     KERN_MAXPROC            = 6,
48     KERN_MAXFILES           = 7,
49     KERN_ARGMAX             = 8,
50     KERN_SECURELVL          = 9,
51     KERN_HOSTNAME           = 10,
52     KERN_HOSTID             = 11,
53     KERN_CLOCKRATE          = 12,
54     KERN_VNODE              = 13,
55     KERN_PROC               = 14,
56     KERN_FILE               = 15,
57     KERN_PROF               = 16,
58     KERN_POSIX1             = 17,
59     KERN_NGROUPS            = 18,
60     KERN_JOB_CONTROL        = 19,
61     KERN_SAVED_IDS          = 20,
62     KERN_BOOTTIME           = 21,
63     KERN_NISDOMAINNAME      = 22,
64     KERN_DOMAINNAME         = KERN_NISDOMAINNAME,
65     KERN_MAXPARTITIONS      = 23,
66     KERN_KDEBUG             = 24,
67     KERN_UPDATEINTERVAL     = 25,
68     KERN_OSRELDATE          = 26,
69     KERN_NTP_PLL            = 27,
70     KERN_BOOTFILE           = 28,
71     KERN_MAXFILESPERPROC    = 29,
72     KERN_MAXPROCPERUID      = 30,
73     KERN_DUMPDEV            = 31,
74     KERN_IPC                = 32,
75     KERN_DUMMY              = 33,
76     KERN_PS_STRINGS         = 34,
77     KERN_USRSTACK32         = 35,
78     KERN_LOGSIGEXIT         = 36,
79     KERN_SYMFILE            = 37,
80     KERN_PROCARGS           = 38,
81     KERN_NETBOOT            = 40,
82     KERN_SYSV               = 42,
83     KERN_AFFINITY           = 43,
84     KERN_TRANSLATE          = 44,
85     KERN_CLASSIC            = KERN_TRANSLATE,
86     KERN_EXEC               = 45,
87     KERN_CLASSICHANDLER     = KERN_EXEC,
88     KERN_AIOMAX             = 46,
89     KERN_AIOPROCMAX         = 47,
90     KERN_AIOTHREADS         = 48,
91     KERN_PROCARGS2          = 49,
92     KERN_COREFILE           = 50,
93     KERN_COREDUMP           = 51,
94     KERN_SUGID_COREDUMP     = 52,
95     KERN_PROCDELAYTERM      = 53,
96     KERN_SHREG_PRIVATIZABLE = 54,
97     KERN_LOW_PRI_WINDOW     = 56,
98     KERN_LOW_PRI_DELAY      = 57,
99     KERN_POSIX              = 58,
100     KERN_USRSTACK64         = 59,
101     KERN_NX_PROTECTION      = 60,
102     KERN_TFP                = 61,
103     KERN_PROCNAME           = 62,
104     KERN_THALTSTACK         = 63,
105     KERN_SPECULATIVE_READS  = 64,
106     KERN_OSVERSION          = 65,
107     KERN_SAFEBOOT           = 66,
108     KERN_RAGEVNODE          = 68,
109     KERN_TTY                = 69,
110     KERN_CHECKOPENEVT       = 70,
111     KERN_THREADNAME         = 71,
112     KERN_MAXID              = 72,
113 }
114 
115 // KERN_RAGEVNODE types
116 enum
117 {
118     KERN_RAGE_PROC     = 1,
119     KERN_RAGE_THREAD   = 2,
120     KERN_UNRAGE_PROC   = 3,
121     KERN_UNRAGE_THREAD = 4,
122 }
123 
124 // KERN_OPENEVT types
125 enum
126 {
127     KERN_OPENEVT_PROC   = 1,
128     KERN_UNOPENEVT_PROC = 2,
129 }
130 
131 // KERN_TFP types
132 enum
133 {
134     KERN_TFP_POLICY = 1,
135 }
136 
137 // KERN_TFP_POLICY values
138 enum
139 {
140     KERN_TFP_POLICY_DENY    = 0,
141     KERN_TFP_POLICY_DEFAULT = 2,
142 }
143 
144 // KERN_PROC subtypes
145 enum
146 {
147     KERN_PROC_ALL     = 0,
148     KERN_PROC_PID     = 1,
149     KERN_PROC_PGRP    = 2,
150     KERN_PROC_SESSION = 3,
151     KERN_PROC_TTY     = 4,
152     KERN_PROC_UID     = 5,
153     KERN_PROC_RUID    = 6,
154     KERN_PROC_LCID    = 7,
155 }
156 
157 // KERN_VFSNSPACE subtypes
158 enum
159 {
160     KERN_VFSNSPACE_HANDLE_PROC   = 1,
161     KERN_VFSNSPACE_UNHANDLE_PROC = 2,
162 }
163 
164 // KERN_IPC identifiers
165 enum
166 {
167     KIPC_MAXSOCKBUF     = 1,
168     KIPC_SOCKBUF_WASTE  = 2,
169     KIPC_SOMAXCONN      = 3,
170     KIPC_MAX_LINKHDR    = 4,
171     KIPC_MAX_PROTOHDR   = 5,
172     KIPC_MAX_HDR        = 6,
173     KIPC_MAX_DATALEN    = 7,
174     KIPC_MBSTAT         = 8,
175     KIPC_NMBCLUSTERS    = 9,
176     KIPC_SOQLIMITCOMPAT = 10,
177 }
178 
179 // CTL_VM identifiers
180 enum
181 {
182     VM_METER      = 1,
183     VM_LOADAVG    = 2,
184     VM_MACHFACTOR = 4,
185     VM_SWAPUSAGE  = 5,
186     VM_MAXID      = 6,
187 }
188 
189 // CTL_HW identifiers
190 enum
191 {
192     HW_MACHINE      = 1,
193     HW_MODEL        = 2,
194     HW_NCPU         = 3,
195     HW_BYTEORDER    = 4,
196     HW_PHYSMEM      = 5,
197     HW_USERMEM      = 6,
198     HW_PAGESIZE     = 7,
199     HW_DISKNAMES    = 8,
200     HW_DISKSTATS    = 9,
201     HW_EPOCH        = 10,
202     HW_FLOATINGPT   = 11,
203     HW_MACHINE_ARCH = 12,
204     HW_VECTORUNIT   = 13,
205     HW_BUS_FREQ     = 14,
206     HW_CPU_FREQ     = 15,
207     HW_CACHELINE    = 16,
208     HW_L1ICACHESIZE = 17,
209     HW_L1DCACHESIZE = 18,
210     HW_L2SETTINGS   = 19,
211     HW_L2CACHESIZE  = 20,
212     HW_L3SETTINGS   = 21,
213     HW_L3CACHESIZE  = 22,
214     HW_TB_FREQ      = 23,
215     HW_MEMSIZE      = 24,
216     HW_AVAILCPU     = 25,
217     HW_MAXID        = 26,
218 }
219 
220 // CTL_USER identifiers
221 enum
222 {
223     USER_CS_PATH           = 1,
224     USER_BC_BASE_MAX       = 2,
225     USER_BC_DIM_MAX        = 3,
226     USER_BC_SCALE_MAX      = 4,
227     USER_BC_STRING_MAX     = 5,
228     USER_COLL_WEIGHTS_MAX  = 6,
229     USER_EXPR_NEST_MAX     = 7,
230     USER_LINE_MAX          = 8,
231     USER_RE_DUP_MAX        = 9,
232     USER_POSIX2_VERSION    = 10,
233     USER_POSIX2_C_BIND     = 11,
234     USER_POSIX2_C_DEV      = 12,
235     USER_POSIX2_CHAR_TERM  = 13,
236     USER_POSIX2_FORT_DEV   = 14,
237     USER_POSIX2_FORT_RUN   = 15,
238     USER_POSIX2_LOCALEDEF  = 16,
239     USER_POSIX2_SW_DEV     = 17,
240     USER_POSIX2_UPE        = 18,
241     USER_STREAM_MAX        = 19,
242     USER_TZNAME_MAX        = 20,
243     USER_MAXID             = 21,
244 }
245 
246 ///
247 int sysctl(const int* name, uint namelen, void* oldp, size_t* oldlenp,
248            const void* newp, size_t newlen);
249 ///
250 int sysctlbyname(const char* name, void* oldp, size_t* oldlenp,
251                  const void* newp, size_t newlen);
252 ///
253 int sysctlnametomib(const char* sname, int* name, size_t* namelenp);