diff --git a/src/header/termios/cbindgen.toml b/src/header/termios/cbindgen.toml index 638af3b3aaabba283aa91ca0833e42681c6a6731..eafb3c12af334829c3f5d35c043a29f8e6991fda 100644 --- a/src/header/termios/cbindgen.toml +++ b/src/header/termios/cbindgen.toml @@ -5,5 +5,9 @@ style = "Tag" no_includes = true cpp_compat = true +[defines] +"target_os=linux" = "__linux__" +"target_os=redox" = "__redox__" + [enum] prefix_with_name = true diff --git a/src/header/termios/linux.rs b/src/header/termios/linux.rs new file mode 100644 index 0000000000000000000000000000000000000000..1bbfbf39340c0dc39f39c60af5c84319fad19548 --- /dev/null +++ b/src/header/termios/linux.rs @@ -0,0 +1,113 @@ +/* c_cc { */ +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VTIME: usize = 5; +pub const VMIN: usize = 6; +pub const VSWTC: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VEOL: usize = 11; +pub const VREPRINT: usize = 12; +pub const VDISCARD: usize = 13; +pub const VWERASE: usize = 14; +pub const VLNEXT: usize = 15; +pub const VEOL2: usize = 16; +pub const NCCS: usize = 32; +/* } c_cc */ + +/* c_iflag { */ +pub const IGNBRK: usize = 0o000_001; +pub const BRKINT: usize = 0o000_002; +pub const IGNPAR: usize = 0o000_004; +pub const PARMRK: usize = 0o000_010; +pub const INPCK: usize = 0o000_020; +pub const ISTRIP: usize = 0o000_040; +pub const INLCR: usize = 0o000_100; +pub const IGNCR: usize = 0o000_200; +pub const ICRNL: usize = 0o000_400; +pub const IUCLC: usize = 0o001_000; +pub const IXON: usize = 0o002_000; +pub const IXANY: usize = 0o004_000; +pub const IXOFF: usize = 0o010_000; +pub const IMAXBEL: usize = 0o020_000; +pub const IUTF8: usize = 0o040_000; +/* } c_iflag */ + +/* c_oflag { */ +pub const OPOST: usize = 0o000_001; +pub const OLCUC: usize = 0o000_002; +pub const ONLCR: usize = 0o000_004; +pub const OCRNL: usize = 0o000_010; +pub const ONOCR: usize = 0o000_020; +pub const ONLRET: usize = 0o000_040; +pub const OFILL: usize = 0o000_100; +pub const OFDEL: usize = 0o000_200; + +pub const VTDLY: usize = 0o040_000; +pub const VT0: usize = 0o000_000; +pub const VT1: usize = 0o040_000; +/* } c_oflag */ + +/* c_cflag { */ +pub const B0: usize = 0o000_000; +pub const B50: usize = 0o000_001; +pub const B75: usize = 0o000_002; +pub const B110: usize = 0o000_003; +pub const B134: usize = 0o000_004; +pub const B150: usize = 0o000_005; +pub const B200: usize = 0o000_006; +pub const B300: usize = 0o000_007; +pub const B600: usize = 0o000_010; +pub const B1200: usize = 0o000_011; +pub const B1800: usize = 0o000_012; +pub const B2400: usize = 0o000_013; +pub const B4800: usize = 0o000_014; +pub const B9600: usize = 0o000_015; +pub const B19200: usize = 0o000_016; +pub const B38400: usize = 0o000_017; + +pub const B57600: usize = 0o010_001; +pub const B115200: usize = 0o010_002; +pub const B230400: usize = 0o010_003; +pub const B460800: usize = 0o010_004; +pub const B500000: usize = 0o010_005; +pub const B576000: usize = 0o010_006; +pub const B921600: usize = 0o010_007; +pub const B1000000: usize = 0o010_010; +pub const B1152000: usize = 0o010_011; +pub const B1500000: usize = 0o010_012; +pub const B2000000: usize = 0o010_013; +pub const B2500000: usize = 0o010_014; +pub const B3000000: usize = 0o010_015; +pub const B3500000: usize = 0o010_016; +pub const B4000000: usize = 0o010_017; + +pub const CSIZE: usize = 0o000_060; +pub const CS5: usize = 0o000_000; +pub const CS6: usize = 0o000_020; +pub const CS7: usize = 0o000_040; +pub const CS8: usize = 0o000_060; + +pub const CSTOPB: usize = 0o000_100; +pub const CREAD: usize = 0o000_200; +pub const PARENB: usize = 0o000_400; +pub const PARODD: usize = 0o001_000; +pub const HUPCL: usize = 0o002_000; +pub const CLOCAL: usize = 0o004_000; +/* } c_clfag */ + +/* c_lflag { */ +pub const ISIG: usize = 0o000_001; +pub const ICANON: usize = 0o000_002; +pub const ECHO: usize = 0o000_010; +pub const ECHOE: usize = 0o000_020; +pub const ECHOK: usize = 0o000_040; +pub const ECHONL: usize = 0o000_100; +pub const NOFLSH: usize = 0o000_200; +pub const TOSTOP: usize = 0o000_400; +pub const IEXTEN: usize = 0o100_000; +/* } c_lflag */ diff --git a/src/header/termios/mod.rs b/src/header/termios/mod.rs index d406996655026267e303267e93da94e9f9740249..f5d1705785a95e8c6568e5edf13ef25939cc4b3e 100644 --- a/src/header/termios/mod.rs +++ b/src/header/termios/mod.rs @@ -5,114 +5,20 @@ use crate::{ platform::{self, types::*}, }; +pub use self::sys::*; + +#[cfg(target_os = "linux")] +#[path = "linux.rs"] +pub mod sys; + +#[cfg(target_os = "redox")] +#[path = "redox.rs"] +pub mod sys; + pub type cc_t = u8; pub type speed_t = u32; pub type tcflag_t = u32; -pub const NCCS: usize = 32; - -pub const VINTR: usize = 0; -pub const VQUIT: usize = 1; -pub const VERASE: usize = 2; -pub const VKILL: usize = 3; -pub const VEOF: usize = 4; -pub const VTIME: usize = 5; -pub const VMIN: usize = 6; -pub const VSWTC: usize = 7; -pub const VSTART: usize = 8; -pub const VSTOP: usize = 9; -pub const VSUSP: usize = 10; -pub const VEOL: usize = 11; -pub const VREPRINT: usize = 12; -pub const VDISCARD: usize = 13; -pub const VWERASE: usize = 14; -pub const VLNEXT: usize = 15; -pub const VEOL2: usize = 16; - -pub const IGNBRK: usize = 0o000_001; -pub const BRKINT: usize = 0o000_002; -pub const IGNPAR: usize = 0o000_004; -pub const PARMRK: usize = 0o000_010; -pub const INPCK: usize = 0o000_020; -pub const ISTRIP: usize = 0o000_040; -pub const INLCR: usize = 0o000_100; -pub const IGNCR: usize = 0o000_200; -pub const ICRNL: usize = 0o000_400; -pub const IUCLC: usize = 0o001_000; -pub const IXON: usize = 0o002_000; -pub const IXANY: usize = 0o004_000; -pub const IXOFF: usize = 0o010_000; -pub const IMAXBEL: usize = 0o020_000; -pub const IUTF8: usize = 0o040_000; - -pub const OPOST: usize = 0o000_001; -pub const OLCUC: usize = 0o000_002; -pub const ONLCR: usize = 0o000_004; -pub const OCRNL: usize = 0o000_010; -pub const ONOCR: usize = 0o000_020; -pub const ONLRET: usize = 0o00_0040; -pub const OFILL: usize = 0o000_100; -pub const OFDEL: usize = 0o000_200; - -pub const VTDLY: usize = 0o040_000; -pub const VT0: usize = 0o000_000; -pub const VT1: usize = 0o040_000; - -pub const B0: usize = 0o000_000; -pub const B50: usize = 0o000_001; -pub const B75: usize = 0o000_002; -pub const B110: usize = 0o000_003; -pub const B134: usize = 0o000_004; -pub const B150: usize = 0o000_005; -pub const B200: usize = 0o000_006; -pub const B300: usize = 0o000_007; -pub const B600: usize = 0o000_010; -pub const B1200: usize = 0o000_011; -pub const B1800: usize = 0o000_012; -pub const B2400: usize = 0o000_013; -pub const B4800: usize = 0o000_014; -pub const B9600: usize = 0o000_015; -pub const B19200: usize = 0o000_016; -pub const B38400: usize = 0o000_017; - -pub const B57600: usize = 0o010_001; -pub const B115200: usize = 0o010_002; -pub const B230400: usize = 0o010_003; -pub const B460800: usize = 0o010_004; -pub const B500000: usize = 0o010_005; -pub const B576000: usize = 0o010_006; -pub const B921600: usize = 0o010_007; -pub const B1000000: usize = 0o010_010; -pub const B1152000: usize = 0o010_011; -pub const B1500000: usize = 0o010_012; -pub const B2000000: usize = 0o010_013; -pub const B2500000: usize = 0o010_014; -pub const B3000000: usize = 0o010_015; -pub const B3500000: usize = 0o010_016; -pub const B4000000: usize = 0o010_017; - -pub const CSIZE: usize = 0o000_060; -pub const CS5: usize = 0o000_000; -pub const CS6: usize = 0o000_020; -pub const CS7: usize = 0o000_040; -pub const CS8: usize = 0o000_060; -pub const CSTOPB: usize = 0o000_100; -pub const CREAD: usize = 0o000_200; -pub const PARENB: usize = 0o000_400; -pub const PARODD: usize = 0o001_000; -pub const HUPCL: usize = 0o002_000; -pub const CLOCAL: usize = 0o004_000; - -pub const ISIG: usize = 0o000_001; -pub const ICANON: usize = 0o000_002; -pub const ECHO: usize = 0o000_010; -pub const ECHOE: usize = 0o000_020; -pub const ECHOK: usize = 0o000_040; -pub const ECHONL: usize = 0o000_100; -pub const NOFLSH: usize = 0o000_200; -pub const TOSTOP: usize = 0o000_400; -pub const IEXTEN: usize = 0o100_000; - pub const TCOOFF: usize = 0; pub const TCOON: usize = 1; pub const TCIOFF: usize = 2; diff --git a/src/header/termios/redox.rs b/src/header/termios/redox.rs new file mode 100644 index 0000000000000000000000000000000000000000..2b52146ced8aeb9c6b5ac8dbe53584b15a582770 --- /dev/null +++ b/src/header/termios/redox.rs @@ -0,0 +1,106 @@ +/* c_cc { */ +pub const VEOF: usize = 0; +pub const VEOL: usize = 1; +pub const VEOL2: usize = 2; +pub const VERASE: usize = 3; +pub const VWERASE: usize = 4; +pub const VKILL: usize = 5; +pub const VREPRINT: usize = 6; +pub const VSWTC: usize = 7; +pub const VINTR: usize = 8; +pub const VQUIT: usize = 9; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 12; +pub const VSTOP: usize = 13; +pub const VLNEXT: usize = 14; +pub const VDISCARD: usize = 15; +pub const VMIN: usize = 16; +pub const VTIME: usize = 17; +pub const NCCS: usize = 32; +/* } c_cc */ + +/* c_iflag { */ +pub const IGNBRK: usize = 0o000_001; +pub const BRKINT: usize = 0o000_002; +pub const IGNPAR: usize = 0o000_004; +pub const PARMRK: usize = 0o000_010; +pub const INPCK: usize = 0o000_020; +pub const ISTRIP: usize = 0o000_040; +pub const INLCR: usize = 0o000_100; +pub const IGNCR: usize = 0o000_200; +pub const ICRNL: usize = 0o000_400; +pub const IXON: usize = 0o001_000; +pub const IXOFF: usize = 0o002_000; +/* } c_iflag */ + +/* c_oflag { */ +pub const OPOST: usize = 0o000_001; +pub const ONLCR: usize = 0o000_002; +pub const OLCUC: usize = 0o000_004; +pub const OCRNL: usize = 0o000_010; +pub const ONOCR: usize = 0o000_020; +pub const ONLRET: usize = 0o000_040; +pub const OFILL: usize = 0o0000_100; +pub const OFDEL: usize = 0o0000_200; +/* } c_oflag */ + +/* c_cflag { */ +pub const B0: usize = 0o000_000; +pub const B50: usize = 0o000_001; +pub const B75: usize = 0o000_002; +pub const B110: usize = 0o000_003; +pub const B134: usize = 0o000_004; +pub const B150: usize = 0o000_005; +pub const B200: usize = 0o000_006; +pub const B300: usize = 0o000_007; +pub const B600: usize = 0o000_010; +pub const B1200: usize = 0o000_011; +pub const B1800: usize = 0o000_012; +pub const B2400: usize = 0o000_013; +pub const B4800: usize = 0o000_014; +pub const B9600: usize = 0o000_015; +pub const B19200: usize = 0o000_016; +pub const B38400: usize = 0o000_017; + +pub const B57600: usize = 0o0_020; +pub const B115200: usize = 0o0_021; +pub const B230400: usize = 0o0_022; +pub const B460800: usize = 0o0_023; +pub const B500000: usize = 0o0_024; +pub const B576000: usize = 0o0_025; +pub const B921600: usize = 0o0_026; +pub const B1000000: usize = 0o0_027; +pub const B1152000: usize = 0o0_030; +pub const B1500000: usize = 0o0_031; +pub const B2000000: usize = 0o0_032; +pub const B2500000: usize = 0o0_033; +pub const B3000000: usize = 0o0_034; +pub const B3500000: usize = 0o0_035; +pub const B4000000: usize = 0o0_036; + +pub const CSIZE: usize = 0o001_400; +pub const CS5: usize = 0o000_000; +pub const CS6: usize = 0o000_400; +pub const CS7: usize = 0o001_000; +pub const CS8: usize = 0o001_400; + +pub const CSTOPB: usize = 0o002_000; +pub const CREAD: usize = 0o004_000; +pub const PARENB: usize = 0o010_000; +pub const PARODD: usize = 0o020_000; +pub const HUPCL: usize = 0o040_000; + +pub const CLOCAL: usize = 0o0100000; +/* } c_clfag */ + +/* c_lflag { */ +pub const ISIG: usize = 0x0000_0080; +pub const ICANON: usize = 0x0000_0100; +pub const ECHO: usize = 0x0000_0008; +pub const ECHOE: usize = 0x0000_0002; +pub const ECHOK: usize = 0x0000_0004; +pub const ECHONL: usize = 0x0000_0010; +pub const NOFLSH: usize = 0x8000_0000; +pub const TOSTOP: usize = 0x0040_0000; +pub const IEXTEN: usize = 0x0000_0400; +/* } c_lflag */