// SPDX-License-Identifier: MPL-2.0
// (c) Hare authors <https://harelang.org>

// Taken from NetBSD's sys/sysctl.h

export def CTL_KERN: u32			= 1; // "high kernel": proc, limits
export def CTL_VM: u32				= 2; // virtual memory
export def CTL_VFS: u32				= 3; // file system, mount type is next
export def CTL_NET: u32				= 4; // network, see socket.h
export def CTL_DEBUG: u32			= 5; // debugging parameters
export def CTL_HW: u32				= 6; // generic CPU/io
export def CTL_MACHDEP: u32			= 7; // machine dependent
export def CTL_USER: u32			= 8; // user-level
export def CTL_DDB: u32				= 9; // in-kernel debugger
export def CTL_PROC: u32			= 10; // per-proc attr
export def CTL_VENDOR: u32			= 11; // vendor-specific data
export def CTL_EMUL: u32			= 12; // emulation-specific data
export def CTL_SECURITY: u32			= 13; // security

export def KERN_OSTYPE: u32			= 1; // string: system version
export def KERN_OSRELEASE: u32			= 2; // string: system release
export def KERN_OSREV: u32			= 3; // int: system revision
export def KERN_VERSION: u32			= 4; // string: compile time info
export def KERN_MAXVNODES: u32			= 5; // int: max vnodes
export def KERN_MAXPROC: u32			= 6; // int: max processes
export def KERN_MAXFILES: u32			= 7; // int: max open files
export def KERN_ARGMAX: u32			= 8; // int: max arguments to exec
export def KERN_SECURELVL: u32			= 9; // int: system security level
export def KERN_HOSTNAME: u32			= 10; // string: hostname
export def KERN_HOSTID: u32			= 11; // int: host identifier
export def KERN_CLOCKRATE: u32			= 12; // struct: struct clockinfo
export def KERN_VNODE: u32			= 13; // struct: vnode structures
export def KERN_PROC: u32			= 14; // struct: process entries
export def KERN_FILE: u32			= 15; // struct: file entries
export def KERN_PROF: u32			= 16; // node: kernel profiling info
export def KERN_POSIX1: u32			= 17; // int: POSIX.1 version
export def KERN_NGROUPS: u32			= 18; // int: # of supplemental group ids
export def KERN_JOB_CONTROL: u32		= 19; // int: is job control available
export def KERN_SAVED_IDS: u32			= 20; // int: saved set-user/group-ID
export def KERN_OBOOTTIME: u32			= 21; // struct: time kernel was booted
export def KERN_DOMAINNAME: u32			= 22; // string: (YP) domainname
export def KERN_MAXPARTITIONS: u32		= 23; // int: number of partitions/disk
export def KERN_RAWPARTITION: u32		= 24; // int: raw partition number
export def KERN_NTPTIME: u32			= 25; // struct: extended-precision time
export def KERN_TIMEX: u32			= 26; // struct: ntp timekeeping state
export def KERN_AUTONICETIME: u32		= 27; // int: proc time before autonice
export def KERN_AUTONICEVAL: u32		= 28; // int: auto nice value
export def KERN_RTC_OFFSET: u32			= 29; // int: offset of rtc from gmt
export def KERN_ROOT_DEVICE: u32		= 30; // string: root device
export def KERN_MSGBUFSIZE: u32			= 31; // int: max # of chars in msg buffer
export def KERN_FSYNC: u32			= 32; // int: file synchronization support
export def KERN_OLDSYSVMSG: u32			= 33; // old: SysV message queue support
export def KERN_OLDSYSVSEM: u32			= 34; // old: SysV semaphore support
export def KERN_OLDSYSVSHM: u32			= 35; // old: SysV shared memory support
export def KERN_OLDSHORTCORENAME: u32		= 36; // old, unimplemented
export def KERN_SYNCHRONIZED_IO: u32		= 37; // int: POSIX synchronized I/O
export def KERN_IOV_MAX: u32			= 38; // int: max iovec's for readv(2) etc.
export def KERN_MBUF: u32			= 39; // node: mbuf parameters
export def KERN_MAPPED_FILES: u32		= 40; // int: POSIX memory mapped files
export def KERN_MEMLOCK: u32			= 41; // int: POSIX memory locking
export def KERN_MEMLOCK_RANGE: u32		= 42; // int: POSIX memory range locking
export def KERN_MEMORY_PROTECTION: u32		= 43; // int: POSIX memory protections
export def KERN_LOGIN_NAME_MAX: u32		= 44; // int: max length login name + NUL
export def KERN_DEFCORENAME: u32		= 45; // old: sort core name format
export def KERN_LOGSIGEXIT: u32			= 46; // int: log signaled processes
export def KERN_PROC2: u32			= 47; // struct: process entries
export def KERN_PROC_ARGS: u32			= 48; // struct: process argv/env
export def KERN_FSCALE: u32			= 49; // int: fixpt FSCALE
export def KERN_CCPU: u32			= 50; // old: fixpt ccpu
export def KERN_CP_TIME: u32			= 51; // struct: CPU time counters
export def KERN_OLDSYSVIPC_INFO: u32		= 52; // old: number of valid kern ids
export def KERN_MSGBUF: u32			= 53; // kernel message buffer
export def KERN_CONSDEV: u32			= 54; // dev_t: console terminal device
export def KERN_MAXPTYS: u32			= 55; // int: maximum number of ptys
export def KERN_PIPE: u32			= 56; // node: pipe limits
export def KERN_MAXPHYS: u32			= 57; // int: kernel value of MAXPHYS
export def KERN_SBMAX: u32			= 58; // int: max socket buffer size
export def KERN_TKSTAT: u32			= 59; // tty in/out counters
export def KERN_MONOTONIC_CLOCK: u32		= 60; // int: POSIX monotonic clock
export def KERN_URND: u32			= 61; // int: random integer from urandom
export def KERN_LABELSECTOR: u32		= 62; // int: disklabel sector
export def KERN_LABELOFFSET: u32		= 63; // int: offset of label within sector
export def KERN_LWP: u32			= 64; // struct: lwp entries
export def KERN_FORKFSLEEP: u32			= 65; // int: sleep length on failed fork
export def KERN_POSIX_THREADS: u32		= 66; // int: POSIX Threads option
export def KERN_POSIX_SEMAPHORES: u32		= 67; // int: POSIX Semaphores option
export def KERN_POSIX_BARRIERS: u32		= 68; // int: POSIX Barriers option
export def KERN_POSIX_TIMERS: u32		= 69; // int: POSIX Timers option
export def KERN_POSIX_SPIN_LOCKS: u32		= 70; // int: POSIX Spin Locks option
export def KERN_POSIX_READER_WRITER_LOCKS: u32	= 71; // int: POSIX R/W Locks option
export def KERN_DUMP_ON_PANIC: u32		= 72; // int: dump on panic
export def KERN_SOMAXKVA: u32			= 73; // int: max socket kernel virtual mem
export def KERN_ROOT_PARTITION: u32		= 74; // int: root partition
export def KERN_DRIVERS: u32			= 75; // struct: driver names and majors #s
export def KERN_BUF: u32			= 76; // struct: buffers
export def KERN_FILE2: u32			= 77; // struct: file entries
export def KERN_VERIEXEC: u32			= 78; // node: verified exec
export def KERN_CP_ID: u32			= 79; // struct: cpu id numbers
export def KERN_HARDCLOCK_TICKS: u32		= 80; // int: number of hardclock ticks
export def KERN_ARND: u32			= 81; // void *buf, size_t siz random
export def KERN_SYSVIPC: u32			= 82; // node: SysV IPC parameters
export def KERN_BOOTTIME: u32			= 83; // struct: time kernel was booted
export def KERN_EVCNT: u32			= 84; // struct: evcnts
export def KERN_SOFIXEDBUF: u32			= 85; // bool: fixed socket buffer sizes
export def KERN_PROC_ALL: u32			= 0; // everything
export def KERN_PROC_PID: u32			= 1; // by process id
export def KERN_PROC_PGRP: u32			= 2; // by process group id
export def KERN_PROC_SESSION: u32		= 3; // by session of pid
export def KERN_PROC_TTY: u32			= 4; // by controlling tty
export def KERN_PROC_UID: u32			= 5; // by effective uid
export def KERN_PROC_RUID: u32			= 6; // by real uid
export def KERN_PROC_GID: u32			= 7; // by effective gid
export def KERN_PROC_RGID: u32			= 8; // by real gid
export def KERN_PROC_TTY_NODEV: u32		= NODEV: u32; // no controlling tty
export def KERN_PROC_TTY_REVOKE: u32		= -2; // revoked tty
export def KERN_PROC_ARGV: u32			= 1; // argv
export def KERN_PROC_NARGV: u32			= 2; // number of strings in above
export def KERN_PROC_ENV: u32			= 3; // environ
export def KERN_PROC_NENV: u32			= 4; // number of strings in above
export def KERN_PROC_PATHNAME: u32		= 5; // path to executable
export def KERN_PROC_CWD: u32			= 6; // current working dir
export def KERN_SYSVIPC_INFO: u32		= 1; // struct: number of valid kern ids
export def KERN_SYSVIPC_MSG: u32		= 2; // int: SysV message queue support
export def KERN_SYSVIPC_SEM: u32		= 3; // int: SysV semaphore support
export def KERN_SYSVIPC_SHM: u32		= 4; // int: SysV shared memory support
export def KERN_SYSVIPC_SHMMAX: u32		= 5; // int: max shared memory segment size (bytes)
export def KERN_SYSVIPC_SHMMNI: u32		= 6; // int: max number of shared memory identifiers
export def KERN_SYSVIPC_SHMSEG: u32		= 7; // int: max shared memory segments per process
export def KERN_SYSVIPC_SHMMAXPGS: u32		= 8; // int: max amount of shared memory (pages)
export def KERN_SYSVIPC_SHMUSEPHYS: u32		= 9; // int: physical memory usage
export def KERN_SYSVIPC_MSG_INFO: u32		= 4; // msginfo and msgid_ds
export def KERN_SYSVIPC_SEM_INFO: u32		= 5; // seminfo and semid_ds
export def KERN_SYSVIPC_SHM_INFO: u32		= 6; // shminfo and shmid_ds
export def KERN_TKSTAT_NIN: u32			= 1; // total input character
export def KERN_TKSTAT_NOUT: u32		= 2; // total output character
export def KERN_TKSTAT_CANCC: u32		= 3; // canonical input character
export def KERN_TKSTAT_RAWCC: u32		= 4; // raw input character
export def KERN_BUF_ALL: u32			= 0; // all buffers
export def KERN_BUFSLOP: u32			= 20;
export def KERN_FILE_BYFILE: u32		= 1;
export def KERN_FILE_BYPID: u32			= 2;
export def KERN_FILESLOP: u32			= 10;
export def KERN_EVCNT_COUNT_ANY: u32		= 0;
export def KERN_EVCNT_COUNT_NONZERO: u32	= 1;

export def HW_MACHINE: u32			= 1; // string: machine class
export def HW_MODEL: u32			= 2; // string: specific machine model
export def HW_NCPU: u32				= 3; // int: number of cpus
export def HW_BYTEORDER: u32			= 4; // int: machine byte order
export def HW_PHYSMEM: u32			= 5; // int: total memory (bytes)
export def HW_USERMEM: u32			= 6; // int: non-kernel memory (bytes)
export def HW_PAGESIZE: u32			= 7; // int: software page size
export def HW_DISKNAMES: u32			= 8; // string: disk drive names
export def HW_IOSTATS: u32			= 9; // struct: iostats[]
export def HW_MACHINE_ARCH: u32			= 10; // string: machine architecture
export def HW_ALIGNBYTES: u32			= 11; // int: ALIGNBYTES for the kernel
export def HW_CNMAGIC: u32			= 12; // string: console magic sequence(s)
export def HW_PHYSMEM64: u32			= 13; // quad: total memory (bytes)
export def HW_USERMEM64: u32			= 14; // quad: non-kernel memory (bytes)
export def HW_IOSTATNAMES: u32			= 15; // string: iostat names
export def HW_NCPUONLINE: u32			= 16; // number CPUs online

export def USER_CS_PATH: u32			= 1; // string: _CS_PATH
export def USER_BC_BASE_MAX: u32		= 2; // int: BC_BASE_MAX
export def USER_BC_DIM_MAX: u32			= 3; // int: BC_DIM_MAX
export def USER_BC_SCALE_MAX: u32		= 4; // int: BC_SCALE_MAX
export def USER_BC_STRING_MAX: u32		= 5; // int: BC_STRING_MAX
export def USER_COLL_WEIGHTS_MAX: u32		= 6; // int: COLL_WEIGHTS_MAX
export def USER_EXPR_NEST_MAX: u32		= 7; // int: EXPR_NEST_MAX
export def USER_LINE_MAX: u32			= 8; // int: LINE_MAX
export def USER_RE_DUP_MAX: u32			= 9; // int: RE_DUP_MAX
export def USER_POSIX2_VERSION: u32		= 10; // int: POSIX2_VERSION
export def USER_POSIX2_C_BIND: u32		= 11; // int: POSIX2_C_BIND
export def USER_POSIX2_C_DEV: u32		= 12; // int: POSIX2_C_DEV
export def USER_POSIX2_CHAR_TERM: u32		= 13; // int: POSIX2_CHAR_TERM
export def USER_POSIX2_FORT_DEV: u32		= 14; // int: POSIX2_FORT_DEV
export def USER_POSIX2_FORT_RUN: u32		= 15; // int: POSIX2_FORT_RUN
export def USER_POSIX2_LOCALEDEF: u32		= 16; // int: POSIX2_LOCALEDEF
export def USER_POSIX2_SW_DEV: u32		= 17; // int: POSIX2_SW_DEV
export def USER_POSIX2_UPE: u32			= 18; // int: POSIX2_UPE
export def USER_STREAM_MAX: u32			= 19; // int: POSIX2_STREAM_MAX
export def USER_TZNAME_MAX: u32			= 20; // int: _POSIX_TZNAME_MAX
export def USER_ATEXIT_MAX: u32			= 21; // int: {ATEXIT_MAX}

export def PROC_CURPROC: u32			= ~(1 << 31);
export def PROC_PID_CORENAME: u32		= 1;
export def PROC_PID_LIMIT: u32			= 2;
export def PROC_PID_STOPFORK: u32		= 3;
export def PROC_PID_STOPEXEC: u32		= 4;
export def PROC_PID_STOPEXIT: u32		= 5;
export def PROC_PID_PAXFLAGS: u32		= 6;
export def PROC_PID_LIMIT_CPU: u32		= (RLIMIT_CPU+1): u32;
export def PROC_PID_LIMIT_FSIZE: u32		= (RLIMIT_FSIZE+1): u32;
export def PROC_PID_LIMIT_DATA: u32		= (RLIMIT_DATA+1): u32;
export def PROC_PID_LIMIT_STACK: u32		= (RLIMIT_STACK+1): u32;
export def PROC_PID_LIMIT_CORE: u32		= (RLIMIT_CORE+1): u32;
export def PROC_PID_LIMIT_RSS: u32		= (RLIMIT_RSS+1): u32;
export def PROC_PID_LIMIT_MEMLOCK: u32		= (RLIMIT_MEMLOCK+1): u32;
export def PROC_PID_LIMIT_NPROC: u32		= (RLIMIT_NPROC+1): u32;
export def PROC_PID_LIMIT_NOFILE: u32		= (RLIMIT_NOFILE+1): u32;
export def PROC_PID_LIMIT_SBSIZE: u32		= (RLIMIT_SBSIZE+1): u32;
export def PROC_PID_LIMIT_AS: u32		= (RLIMIT_AS+1): u32;
export def PROC_PID_LIMIT_NTHR: u32		= (RLIMIT_NTHR+1): u32;
export def PROC_PID_LIMIT_TYPE_SOFT: u32	= 1;
export def PROC_PID_LIMIT_TYPE_HARD: u32	= 2;

export def EMUL_LINUX: u32			= 1;
export def EMUL_LINUX32: u32			= 5;
