Path: blob/main/core/kernel/src/wasm/posix/termios.zig
1068 views
pub fn keepalive() void {}1const termios = @cImport(@cInclude("termios.h"));2const std = @import("std");3const expect = std.testing.expect;4const errno = @cImport(@cInclude("errno.h"));56pub const constants = .{7.c_import = termios,8.names = [_][:0]const u8{9// c_iflag's:10"IGNBRK", "BRKINT", "IGNPAR",11"PARMRK", "INPCK", "ISTRIP",12"INLCR", "IGNCR", "ICRNL",13"IXON", "IXANY", "IXOFF",14"IMAXBEL", "IUTF8",15// c_oflag's:16"OPOST",17"ONLCR", "OCRNL", "ONOCR",18"ONLRET", "OFILL", "OFDEL",19// c_cflag's:20"CSIZE", "CS5", "CS6",21"CS7", "CS8", "CSTOPB",22"CREAD", "PARENB", "PARODD",23"HUPCL", "CLOCAL",24// c_lflag's25"ICANON",26"ISIG", "ECHO", "ECHOE",27"ECHOK", "ECHONL", "NOFLSH",28"TOSTOP", "IEXTEN",29},30};313233// ported from zig/lib/libc/wasi/libc-top-half/musl/src/termios/cfsetospeed.c34// basically just some pointless implementations that of course don't really matter.35pub export fn cfsetospeed(tio: *termios.termios, speed: termios.speed_t) c_int {36if ((speed & @bitCast(c_ulong, ~termios.CBAUD)) != 0) {37errno.errno = errno.EINVAL;38return -1;39}40tio.c_cflag &= @bitCast(c_ulong, ~termios.CBAUD);41tio.c_cflag |= speed;42return 0;43}4445//int cfsetispeed(struct termios *termios_p, speed_t speed);46pub export fn cfsetispeed(tio: *termios.termios, speed: termios.speed_t) c_int {47return if (speed != 0) cfsetospeed(tio, speed) else 0;48}4950export fn cfgetispeed(tio: *const termios.termios) termios.speed_t {51return tio.c_cflag & termios.CBAUD;52}5354//int cfsetospeed(struct termios *termios_p, speed_t speed);55export fn cfgetospeed(tio: *const termios.termios) termios.speed_t {56return cfgetispeed(tio);57}585960