| author | |
| committer | |
| log | e97fa8b03803dfb5d2046d9b2ebecbee85a0e1f9 |
| tree | f7bf8e4ae4b742fa7eaae4eb4150e2b35a883257 |
| parent | 20abc0caeeb8a9cc1cc1fe8c8ae318ec2906cc24 |
This creates `tc_cflag_t` even though such a type is not defined by
libc.
I also collected the missing flag bits from all the operating systems.6 files changed, 178 insertions(+), 81 deletions(-)
lib/std/c.zig+147-5| ... | ... | @@ -795,7 +795,7 @@ pub const termios = switch (native_os) { |
| 795 | 795 | .macos, .ios, .tvos, .watchos => extern struct { |
| 796 | 796 | iflag: tc_iflag_t, |
| 797 | 797 | oflag: tc_oflag_t, |
| 798 | cflag: tcflag_t, | |
| 798 | cflag: tc_cflag_t, | |
| 799 | 799 | lflag: tcflag_t, |
| 800 | 800 | cc: [NCCS]cc_t, |
| 801 | 801 | ispeed: speed_t align(8), |
| ... | ... | @@ -804,7 +804,7 @@ pub const termios = switch (native_os) { |
| 804 | 804 | .freebsd, .kfreebsd, .netbsd, .dragonfly, .openbsd => extern struct { |
| 805 | 805 | iflag: tc_iflag_t, |
| 806 | 806 | oflag: tc_oflag_t, |
| 807 | cflag: tcflag_t, | |
| 807 | cflag: tc_cflag_t, | |
| 808 | 808 | lflag: tcflag_t, |
| 809 | 809 | cc: [NCCS]cc_t, |
| 810 | 810 | ispeed: speed_t, |
| ... | ... | @@ -813,7 +813,7 @@ pub const termios = switch (native_os) { |
| 813 | 813 | .haiku => extern struct { |
| 814 | 814 | iflag: tc_iflag_t, |
| 815 | 815 | oflag: tc_oflag_t, |
| 816 | cflag: tcflag_t, | |
| 816 | cflag: tc_cflag_t, | |
| 817 | 817 | lflag: tcflag_t, |
| 818 | 818 | line: cc_t, |
| 819 | 819 | ispeed: speed_t, |
| ... | ... | @@ -823,14 +823,14 @@ pub const termios = switch (native_os) { |
| 823 | 823 | .solaris, .illumos => extern struct { |
| 824 | 824 | iflag: tc_iflag_t, |
| 825 | 825 | oflag: tc_oflag_t, |
| 826 | cflag: tcflag_t, | |
| 826 | cflag: tc_cflag_t, | |
| 827 | 827 | lflag: tcflag_t, |
| 828 | 828 | cc: [NCCS]cc_t, |
| 829 | 829 | }, |
| 830 | 830 | .emscripten, .wasi => extern struct { |
| 831 | 831 | iflag: tc_iflag_t, |
| 832 | 832 | oflag: tc_oflag_t, |
| 833 | cflag: tcflag_t, | |
| 833 | cflag: tc_cflag_t, | |
| 834 | 834 | lflag: tcflag_t, |
| 835 | 835 | line: std.c.cc_t, |
| 836 | 836 | cc: [NCCS]cc_t, |
| ... | ... | @@ -1041,6 +1041,148 @@ pub const tc_oflag_t = switch (native_os) { |
| 1041 | 1041 | else => @compileError("target libc does not have tc_oflag_t"), |
| 1042 | 1042 | }; |
| 1043 | 1043 | |
| 1044 | pub const CSIZE = switch (native_os) { | |
| 1045 | .linux => std.os.linux.CSIZE, | |
| 1046 | .haiku => enum(u1) { CS7, CS8 }, | |
| 1047 | else => enum(u2) { CS5, CS6, CS7, CS8 }, | |
| 1048 | }; | |
| 1049 | ||
| 1050 | pub const tc_cflag_t = switch (native_os) { | |
| 1051 | .linux => std.os.linux.tc_cflag_t, | |
| 1052 | .macos, .ios, .tvos, .watchos => packed struct(u32) { | |
| 1053 | CIGNORE: bool = false, | |
| 1054 | _1: u5 = 0, | |
| 1055 | CSTOPB: bool = false, | |
| 1056 | _7: u1 = 0, | |
| 1057 | CSIZE: CSIZE = .CS5, | |
| 1058 | _10: u1 = 0, | |
| 1059 | CREAD: bool = false, | |
| 1060 | PARENB: bool = false, | |
| 1061 | PARODD: bool = false, | |
| 1062 | HUPCL: bool = false, | |
| 1063 | CLOCAL: bool = false, | |
| 1064 | CCTS_OFLOW: bool = false, | |
| 1065 | CRTS_IFLOW: bool = false, | |
| 1066 | CDTR_IFLOW: bool = false, | |
| 1067 | CDSR_OFLOW: bool = false, | |
| 1068 | CCAR_OFLOW: bool = false, | |
| 1069 | _: u11 = 0, | |
| 1070 | }, | |
| 1071 | .freebsd, .kfreebsd => packed struct(u32) { | |
| 1072 | CIGNORE: bool = false, | |
| 1073 | _1: u7 = 0, | |
| 1074 | CSIZE: CSIZE = .CS5, | |
| 1075 | CSTOPB: bool = false, | |
| 1076 | CREAD: bool = false, | |
| 1077 | PARENB: bool = false, | |
| 1078 | PARODD: bool = false, | |
| 1079 | HUPCL: bool = false, | |
| 1080 | CLOCAL: bool = false, | |
| 1081 | CCTS_OFLOW: bool = false, | |
| 1082 | CRTS_IFLOW: bool = false, | |
| 1083 | CDTR_IFLOW: bool = false, | |
| 1084 | CDSR_OFLOW: bool = false, | |
| 1085 | CCAR_OFLOW: bool = false, | |
| 1086 | CNO_RTSDTR: bool = false, | |
| 1087 | _: u10 = 0, | |
| 1088 | }, | |
| 1089 | .netbsd => packed struct(u32) { | |
| 1090 | CIGNORE: bool = false, | |
| 1091 | _1: u7 = 0, | |
| 1092 | CSIZE: CSIZE = .CS5, | |
| 1093 | CSTOPB: bool = false, | |
| 1094 | CREAD: bool = false, | |
| 1095 | PARENB: bool = false, | |
| 1096 | PARODD: bool = false, | |
| 1097 | HUPCL: bool = false, | |
| 1098 | CLOCAL: bool = false, | |
| 1099 | CRTSCTS: bool = false, | |
| 1100 | CDTRCTS: bool = false, | |
| 1101 | _18: u2 = 0, | |
| 1102 | MDMBUF: bool = false, | |
| 1103 | _: u11 = 0, | |
| 1104 | }, | |
| 1105 | .dragonfly => packed struct(u32) { | |
| 1106 | CIGNORE: bool = false, | |
| 1107 | _1: u7 = 0, | |
| 1108 | CSIZE: CSIZE = .CS5, | |
| 1109 | CSTOPB: bool = false, | |
| 1110 | CREAD: bool = false, | |
| 1111 | PARENB: bool = false, | |
| 1112 | PARODD: bool = false, | |
| 1113 | HUPCL: bool = false, | |
| 1114 | CLOCAL: bool = false, | |
| 1115 | CCTS_OFLOW: bool = false, | |
| 1116 | CRTS_IFLOW: bool = false, | |
| 1117 | CDTR_IFLOW: bool = false, | |
| 1118 | CDSR_OFLOW: bool = false, | |
| 1119 | CCAR_OFLOW: bool = false, | |
| 1120 | _: u11 = 0, | |
| 1121 | }, | |
| 1122 | .openbsd => packed struct(u32) { | |
| 1123 | CIGNORE: bool = false, | |
| 1124 | _1: u7 = 0, | |
| 1125 | CSIZE: CSIZE = .CS5, | |
| 1126 | CSTOPB: bool = false, | |
| 1127 | CREAD: bool = false, | |
| 1128 | PARENB: bool = false, | |
| 1129 | PARODD: bool = false, | |
| 1130 | HUPCL: bool = false, | |
| 1131 | CLOCAL: bool = false, | |
| 1132 | CRTSCTS: bool = false, | |
| 1133 | _17: u3 = 0, | |
| 1134 | MDMBUF: bool = false, | |
| 1135 | _: u11 = 0, | |
| 1136 | }, | |
| 1137 | .haiku => packed struct(u32) { | |
| 1138 | _0: u5 = 0, | |
| 1139 | CSIZE: CSIZE = .CS7, | |
| 1140 | CSTOPB: bool = false, | |
| 1141 | CREAD: bool = false, | |
| 1142 | PARENB: bool = false, | |
| 1143 | PARODD: bool = false, | |
| 1144 | HUPCL: bool = false, | |
| 1145 | CLOCAL: bool = false, | |
| 1146 | XLOBLK: bool = false, | |
| 1147 | CTSFLOW: bool = false, | |
| 1148 | RTSFLOW: bool = false, | |
| 1149 | _: u17 = 0, | |
| 1150 | }, | |
| 1151 | .solaris, .illumos => packed struct(u32) { | |
| 1152 | _0: u4 = 0, | |
| 1153 | CSIZE: CSIZE = .CS5, | |
| 1154 | CSTOPB: bool = false, | |
| 1155 | CREAD: bool = false, | |
| 1156 | PARENB: bool = false, | |
| 1157 | PARODD: bool = false, | |
| 1158 | HUPCL: bool = false, | |
| 1159 | CLOCAL: bool = false, | |
| 1160 | RCV1EN: bool = false, | |
| 1161 | XMT1EN: bool = false, | |
| 1162 | LOBLK: bool = false, | |
| 1163 | XCLUDE: bool = false, | |
| 1164 | _16: u4 = 0, | |
| 1165 | PAREXT: bool = false, | |
| 1166 | CBAUDEXT: bool = false, | |
| 1167 | CIBAUDEXT: bool = false, | |
| 1168 | _23: u7 = 0, | |
| 1169 | CRTSXOFF: bool = false, | |
| 1170 | CRTSCTS: bool = false, | |
| 1171 | }, | |
| 1172 | .wasi, .emscripten => packed struct(u32) { | |
| 1173 | _0: u4 = 0, | |
| 1174 | CSIZE: CSIZE = .CS5, | |
| 1175 | CSTOPB: bool = false, | |
| 1176 | CREAD: bool = false, | |
| 1177 | PARENB: bool = false, | |
| 1178 | PARODD: bool = false, | |
| 1179 | HUPCL: bool = false, | |
| 1180 | CLOCAL: bool = false, | |
| 1181 | _: u20 = 0, | |
| 1182 | }, | |
| 1183 | else => @compileError("target libc does not have tc_cflag_t"), | |
| 1184 | }; | |
| 1185 | ||
| 1044 | 1186 | pub const tcflag_t = switch (native_os) { |
| 1045 | 1187 | .linux => std.os.linux.tcflag_t, |
| 1046 | 1188 | .macos, .ios, .tvos, .watchos => u64, |
lib/std/c/darwin.zig-20| ... | ... | @@ -2692,26 +2692,6 @@ pub const SHUT = struct { |
| 2692 | 2692 | pub const RDWR = 2; |
| 2693 | 2693 | }; |
| 2694 | 2694 | |
| 2695 | pub const CIGNORE: tcflag_t = 0x00000001; // ignore control flags | |
| 2696 | pub const CSIZE: tcflag_t = 0x00000300; // character size mask | |
| 2697 | pub const CS5: tcflag_t = 0x00000000; // 5 bits (pseudo) | |
| 2698 | pub const CS6: tcflag_t = 0x00000100; // 6 bits | |
| 2699 | pub const CS7: tcflag_t = 0x00000200; // 7 bits | |
| 2700 | pub const CS8: tcflag_t = 0x00000300; // 8 bits | |
| 2701 | pub const CSTOPB: tcflag_t = 0x0000040; // send 2 stop bits | |
| 2702 | pub const CREAD: tcflag_t = 0x00000800; // enable receiver | |
| 2703 | pub const PARENB: tcflag_t = 0x00001000; // parity enable | |
| 2704 | pub const PARODD: tcflag_t = 0x00002000; // odd parity, else even | |
| 2705 | pub const HUPCL: tcflag_t = 0x00004000; // hang up on last close | |
| 2706 | pub const CLOCAL: tcflag_t = 0x00008000; // ignore modem status lines | |
| 2707 | pub const CCTS_OFLOW: tcflag_t = 0x00010000; // CTS flow control of output | |
| 2708 | pub const CRTSCTS: tcflag_t = (CCTS_OFLOW | CRTS_IFLOW); | |
| 2709 | pub const CRTS_IFLOW: tcflag_t = 0x00020000; // RTS flow control of input | |
| 2710 | pub const CDTR_IFLOW: tcflag_t = 0x00040000; // DTR flow control of input | |
| 2711 | pub const CDSR_OFLOW: tcflag_t = 0x00080000; // DSR flow control of output | |
| 2712 | pub const CCAR_OFLOW: tcflag_t = 0x00100000; // DCD flow control of output | |
| 2713 | pub const MDMBUF: tcflag_t = 0x00100000; // old name for CCAR_OFLOW | |
| 2714 | ||
| 2715 | 2695 | pub const ECHOKE: tcflag_t = 0x00000001; // visual erase for line kill |
| 2716 | 2696 | pub const ECHOE: tcflag_t = 0x00000002; // visually erase chars |
| 2717 | 2697 | pub const ECHOK: tcflag_t = 0x00000004; // echo NL after line kill |
lib/std/c/netbsd.zig-21| ... | ... | @@ -806,27 +806,6 @@ pub const T = struct { |
| 806 | 806 | pub const IOCXMTFRAME = 0x80087444; |
| 807 | 807 | }; |
| 808 | 808 | |
| 809 | ||
| 810 | // Control flags - hardware control of terminal | |
| 811 | pub const CIGNORE: tcflag_t = 0x00000001; // ignore control flags | |
| 812 | pub const CSIZE: tcflag_t = 0x00000300; // character size mask | |
| 813 | pub const CS5: tcflag_t = 0x00000000; // 5 bits (pseudo) | |
| 814 | pub const CS6: tcflag_t = 0x00000100; // 6 bits | |
| 815 | pub const CS7: tcflag_t = 0x00000200; // 7 bits | |
| 816 | pub const CS8: tcflag_t = 0x00000300; // 8 bits | |
| 817 | pub const CSTOPB: tcflag_t = 0x00000400; // send 2 stop bits | |
| 818 | pub const CREAD: tcflag_t = 0x00000800; // enable receiver | |
| 819 | pub const PARENB: tcflag_t = 0x00001000; // parity enable | |
| 820 | pub const PARODD: tcflag_t = 0x00002000; // odd parity, else even | |
| 821 | pub const HUPCL: tcflag_t = 0x00004000; // hang up on last close | |
| 822 | pub const CLOCAL: tcflag_t = 0x00008000; // ignore modem status lines | |
| 823 | pub const CRTSCTS: tcflag_t = 0x00010000; // RTS/CTS full-duplex flow control | |
| 824 | pub const CRTS_IFLOW: tcflag_t = CRTSCTS; // XXX compat | |
| 825 | pub const CCTS_OFLOW: tcflag_t = CRTSCTS; // XXX compat | |
| 826 | pub const CDTRCTS: tcflag_t = 0x00020000; // DTR/CTS full-duplex flow control | |
| 827 | pub const MDMBUF: tcflag_t = 0x00100000; // DTR/DCD hardware flow control | |
| 828 | pub const CHWFLOW: tcflag_t = (MDMBUF | CRTSCTS | CDTRCTS); // all types of hw flow control | |
| 829 | ||
| 830 | 809 | // Commands passed to tcsetattr() for setting the termios structure. |
| 831 | 810 | pub const TCSA = struct { |
| 832 | 811 | pub const NOW = 0; // make change immediate |
lib/std/c/openbsd.zig-21| ... | ... | @@ -768,27 +768,6 @@ pub const AUTH = struct { |
| 768 | 768 | pub const ALLOW: c_int = (OKAY | ROOTOKAY | SECURE); |
| 769 | 769 | }; |
| 770 | 770 | |
| 771 | ||
| 772 | ||
| 773 | // Control flags - hardware control of terminal | |
| 774 | pub const CIGNORE: tcflag_t = 0x00000001; // ignore control flags | |
| 775 | pub const CSIZE: tcflag_t = 0x00000300; // character size mask | |
| 776 | pub const CS5: tcflag_t = 0x00000000; // 5 bits (pseudo) | |
| 777 | pub const CS6: tcflag_t = 0x00000100; // 6 bits | |
| 778 | pub const CS7: tcflag_t = 0x00000200; // 7 bits | |
| 779 | pub const CS8: tcflag_t = 0x00000300; // 8 bits | |
| 780 | pub const CSTOPB: tcflag_t = 0x00000400; // send 2 stop bits | |
| 781 | pub const CREAD: tcflag_t = 0x00000800; // enable receiver | |
| 782 | pub const PARENB: tcflag_t = 0x00001000; // parity enable | |
| 783 | pub const PARODD: tcflag_t = 0x00002000; // odd parity, else even | |
| 784 | pub const HUPCL: tcflag_t = 0x00004000; // hang up on last close | |
| 785 | pub const CLOCAL: tcflag_t = 0x00008000; // ignore modem status lines | |
| 786 | pub const CRTSCTS: tcflag_t = 0x00010000; // RTS/CTS full-duplex flow control | |
| 787 | pub const CRTS_IFLOW: tcflag_t = CRTSCTS; // XXX compat | |
| 788 | pub const CCTS_OFLOW: tcflag_t = CRTSCTS; // XXX compat | |
| 789 | pub const MDMBUF: tcflag_t = 0x00100000; // DTR/DCD hardware flow control | |
| 790 | pub const CHWFLOW: tcflag_t = (MDMBUF | CRTSCTS); // all types of hw flow control | |
| 791 | ||
| 792 | 771 | // Commands passed to tcsetattr() for setting the termios structure. |
| 793 | 772 | pub const TCSA = struct { |
| 794 | 773 | pub const NOW = 0; // make change immediate |
lib/std/os.zig+2| ... | ... | @@ -184,11 +184,13 @@ pub const uid_t = system.uid_t; |
| 184 | 184 | pub const user_desc = system.user_desc; |
| 185 | 185 | pub const utsname = system.utsname; |
| 186 | 186 | |
| 187 | pub const CSIZE = system.CSIZE; | |
| 187 | 188 | pub const NCCS = system.NCCS; |
| 188 | 189 | pub const speed_t = system.speed_t; |
| 189 | 190 | pub const tcflag_t = system.tcflag_t; |
| 190 | 191 | pub const tc_iflag_t = system.tc_iflag_t; |
| 191 | 192 | pub const tc_oflag_t = system.tc_oflag_t; |
| 193 | pub const tc_cflag_t = system.tc_cflag_t; | |
| 192 | 194 | |
| 193 | 195 | pub const F_OK = system.F_OK; |
| 194 | 196 | pub const R_OK = system.R_OK; |
lib/std/os/linux.zig+29-14| ... | ... | @@ -5120,6 +5120,33 @@ pub const tc_oflag_t = switch (native_arch) { |
| 5120 | 5120 | }, |
| 5121 | 5121 | }; |
| 5122 | 5122 | |
| 5123 | pub const CSIZE = enum(u2) { CS5, CS6, CS7, CS8 }; | |
| 5124 | ||
| 5125 | pub const tc_cflag_t = switch (native_arch) { | |
| 5126 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) { | |
| 5127 | _0: u8 = 0, | |
| 5128 | CSIZE: CSIZE = .CS5, | |
| 5129 | CSTOPB: bool = false, | |
| 5130 | CREAD: bool = false, | |
| 5131 | PARENB: bool = false, | |
| 5132 | PARODD: bool = false, | |
| 5133 | HUPCL: bool = false, | |
| 5134 | CLOCAL: bool = false, | |
| 5135 | _: u16 = 0, | |
| 5136 | }, | |
| 5137 | else => packed struct(u32) { | |
| 5138 | _0: u4 = 0, | |
| 5139 | CSIZE: CSIZE = .CS5, | |
| 5140 | CSTOPB: bool = false, | |
| 5141 | CREAD: bool = false, | |
| 5142 | PARENB: bool = false, | |
| 5143 | PARODD: bool = false, | |
| 5144 | HUPCL: bool = false, | |
| 5145 | CLOCAL: bool = false, | |
| 5146 | _: u20 = 0, | |
| 5147 | }, | |
| 5148 | }; | |
| 5149 | ||
| 5123 | 5150 | pub const cc_t = switch (native_arch) { |
| 5124 | 5151 | .mips, .mipsel, .mips64, .mips64el => enum(u8) { |
| 5125 | 5152 | VINTR = 0, |
| ... | ... | @@ -5182,18 +5209,6 @@ pub const cc_t = switch (native_arch) { |
| 5182 | 5209 | |
| 5183 | 5210 | pub const tcflag_t = u32; |
| 5184 | 5211 | |
| 5185 | pub const CSIZE: tcflag_t = 48; | |
| 5186 | pub const CS5: tcflag_t = 0; | |
| 5187 | pub const CS6: tcflag_t = 16; | |
| 5188 | pub const CS7: tcflag_t = 32; | |
| 5189 | pub const CS8: tcflag_t = 48; | |
| 5190 | pub const CSTOPB: tcflag_t = 64; | |
| 5191 | pub const CREAD: tcflag_t = 128; | |
| 5192 | pub const PARENB: tcflag_t = 256; | |
| 5193 | pub const PARODD: tcflag_t = 512; | |
| 5194 | pub const HUPCL: tcflag_t = 1024; | |
| 5195 | pub const CLOCAL: tcflag_t = 2048; | |
| 5196 | ||
| 5197 | 5212 | pub const ISIG: tcflag_t = 1; |
| 5198 | 5213 | pub const ICANON: tcflag_t = 2; |
| 5199 | 5214 | pub const ECHO: tcflag_t = 8; |
| ... | ... | @@ -5215,7 +5230,7 @@ pub const termios = switch (native_arch) { |
| 5215 | 5230 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => extern struct { |
| 5216 | 5231 | iflag: tc_iflag_t, |
| 5217 | 5232 | oflag: tc_oflag_t, |
| 5218 | cflag: tcflag_t, | |
| 5233 | cflag: tc_cflag_t, | |
| 5219 | 5234 | lflag: tcflag_t, |
| 5220 | 5235 | cc: [NCCS]cc_t, |
| 5221 | 5236 | line: cc_t, |
| ... | ... | @@ -5225,7 +5240,7 @@ pub const termios = switch (native_arch) { |
| 5225 | 5240 | else => extern struct { |
| 5226 | 5241 | iflag: tc_iflag_t, |
| 5227 | 5242 | oflag: tc_oflag_t, |
| 5228 | cflag: tcflag_t, | |
| 5243 | cflag: tc_cflag_t, | |
| 5229 | 5244 | lflag: tcflag_t, |
| 5230 | 5245 | line: cc_t, |
| 5231 | 5246 | cc: [NCCS]cc_t, |