diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2022-10-29 05:58:41 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2022-10-29 05:58:41 -0400 |
| commit | 48a2783969b0a43200514a5b4e9cce57be4e5b46 (patch) | |
| tree | 0f7cc577dd9090938d842250e1d1986d3d05aa0e /lib/std/os | |
| parent | e20d2b3151607fe078b43331ea27d5b34f95360b (diff) | |
| parent | 20925b2f5c5c0ae20fdc0574e5d4e5740d17b4d6 (diff) | |
| download | zig-48a2783969b0a43200514a5b4e9cce57be4e5b46.tar.gz zig-48a2783969b0a43200514a5b4e9cce57be4e5b46.zip | |
cbe: implement optional slice representation change
Diffstat (limited to 'lib/std/os')
| -rw-r--r-- | lib/std/os/linux.zig | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 8ca20bc330..da9ea74327 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -804,6 +804,63 @@ pub fn exit_group(status: i32) noreturn { unreachable; } +/// flags for the `reboot' system call. +pub const LINUX_REBOOT = struct { + /// First magic value required to use _reboot() system call. + pub const MAGIC1 = enum(u32) { + MAGIC1 = 0xfee1dead, + _, + }; + + /// Second magic value required to use _reboot() system call. + pub const MAGIC2 = enum(u32) { + MAGIC2 = 672274793, + MAGIC2A = 85072278, + MAGIC2B = 369367448, + MAGIC2C = 537993216, + _, + }; + + /// Commands accepted by the _reboot() system call. + pub const CMD = enum(u32) { + /// Restart system using default command and mode. + RESTART = 0x01234567, + + /// Stop OS and give system control to ROM monitor, if any. + HALT = 0xCDEF0123, + + /// Ctrl-Alt-Del sequence causes RESTART command. + CAD_ON = 0x89ABCDEF, + + /// Ctrl-Alt-Del sequence sends SIGINT to init task. + CAD_OFF = 0x00000000, + + /// Stop OS and remove all power from system, if possible. + POWER_OFF = 0x4321FEDC, + + /// Restart system using given command string. + RESTART2 = 0xA1B2C3D4, + + /// Suspend system using software suspend if compiled in. + SW_SUSPEND = 0xD000FCE2, + + /// Restart system using a previously loaded Linux kernel + KEXEC = 0x45584543, + + _, + }; +}; + +pub fn reboot(magic: LINUX_REBOOT.MAGIC1, magic2: LINUX_REBOOT.MAGIC2, cmd: LINUX_REBOOT.CMD, arg: ?*const anyopaque) usize { + return std.os.linux.syscall4( + .reboot, + @enumToInt(magic), + @enumToInt(magic2), + @enumToInt(cmd), + @ptrToInt(arg), + ); +} + pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize { return syscall3(.getrandom, @ptrToInt(buf), count, flags); } @@ -3208,6 +3265,21 @@ pub const sockaddr = extern struct { queue_id: u32, shared_umem_fd: u32, }; + + /// Address structure for vSockets + pub const vm = extern struct { + family: sa_family_t = AF.VSOCK, + reserved1: u16 = 0, + port: u32, + cid: u32, + flags: u8, + + /// The total size of this structure should be exactly the same as that of struct sockaddr. + zero: [3]u8 = [_]u8{0} ** 3, + comptime { + std.debug.assert(@sizeOf(vm) == @sizeOf(sockaddr)); + } + }; }; pub const mmsghdr = extern struct { |
