Skip to content

Commit 6a8341a

Browse files
authored
Make termios constants support AIX (#476)
1 parent 26f1d86 commit 6a8341a

File tree

6 files changed

+67
-14
lines changed

6 files changed

+67
-14
lines changed

examples/process.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,24 @@ fn main() -> io::Result<()> {
5454
println!("Nproc Limit: {:?}", getrlimit(Resource::Nproc));
5555
#[cfg(not(target_os = "solaris"))]
5656
println!("Nofile Limit: {:?}", getrlimit(Resource::Nofile));
57-
#[cfg(not(any(solarish, target_os = "haiku")))]
57+
#[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))]
5858
println!("Memlock Limit: {:?}", getrlimit(Resource::Memlock));
5959
#[cfg(not(target_os = "openbsd"))]
6060
println!("As Limit: {:?}", getrlimit(Resource::As));
61-
#[cfg(not(any(bsd, solarish, target_os = "haiku")))]
61+
#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
6262
println!("Locks Limit: {:?}", getrlimit(Resource::Locks));
63-
#[cfg(not(any(bsd, solarish, target_os = "haiku")))]
63+
#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
6464
println!("Sigpending Limit: {:?}", getrlimit(Resource::Sigpending));
65-
#[cfg(not(any(bsd, solarish, target_os = "haiku")))]
65+
#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
6666
println!("Msgqueue Limit: {:?}", getrlimit(Resource::Msgqueue));
67-
#[cfg(not(any(bsd, solarish, target_os = "haiku")))]
67+
#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
6868
println!("Nice Limit: {:?}", getrlimit(Resource::Nice));
69-
#[cfg(not(any(bsd, solarish, target_os = "haiku")))]
69+
#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
7070
println!("Rtprio Limit: {:?}", getrlimit(Resource::Rtprio));
7171
#[cfg(not(any(
7272
bsd,
7373
solarish,
74+
target_os = "aix",
7475
target_os = "android",
7576
target_os = "emscripten",
7677
target_os = "haiku",

examples/stdio.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
125125
#[cfg(not(any(
126126
bsd,
127127
solarish,
128+
target_os = "aix",
128129
target_os = "emscripten",
129130
target_os = "haiku",
130131
target_os = "redox",
@@ -139,7 +140,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
139140
if (term.c_oflag & OPOST) != 0 {
140141
print!(" OPOST");
141142
}
142-
#[cfg(not(any(bsd, target_os = "redox")))]
143+
#[cfg(not(any(bsd, target_os = "aix", target_os = "redox")))]
143144
if (term.c_oflag & OLCUC) != 0 {
144145
print!(" OLCUC");
145146
}
@@ -171,7 +172,7 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
171172
if (term.c_oflag & NLDLY) != 0 {
172173
print!(" NLDLY");
173174
}
174-
#[cfg(not(any(bsd, solarish, target_os = "redox")))]
175+
#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "redox")))]
175176
if (term.c_oflag & CRDLY) != 0 {
176177
print!(" CRDLY");
177178
}
@@ -204,7 +205,13 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
204205
if (term.c_cflag & CBAUD) != 0 {
205206
print!(" CBAUD");
206207
}
207-
#[cfg(not(any(bsd, solarish, target_os = "haiku", target_os = "redox")))]
208+
#[cfg(not(any(
209+
bsd,
210+
solarish,
211+
target_os = "aix",
212+
target_os = "haiku",
213+
target_os = "redox"
214+
)))]
208215
if (term.c_cflag & CBAUDEX) != 0 {
209216
print!(" CBAUDEX");
210217
}

src/backend/libc/io/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ bitflags! {
5858
/// `O_CLOEXEC`
5959
#[cfg(not(any(
6060
apple,
61+
target_os = "aix",
6162
target_os = "android",
6263
target_os = "redox",
6364
)))] // Android 5.0 has dup3, but libc doesn't have bindings

src/backend/libc/termios/types.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub const VMIN: usize = c::VMIN as usize;
113113

114114
/// `VSWTC`
115115
#[cfg(not(any(
116+
target_os = "aix",
116117
target_os = "dragonfly",
117118
target_os = "freebsd",
118119
target_os = "haiku",
@@ -142,11 +143,11 @@ pub const VEOL: usize = c::VEOL as usize;
142143
pub const VREPRINT: usize = c::VREPRINT as usize;
143144

144145
/// `VDISCARD`
145-
#[cfg(not(target_os = "haiku"))]
146+
#[cfg(not(any(target_os = "aix", target_os = "haiku")))]
146147
pub const VDISCARD: usize = c::VDISCARD as usize;
147148

148149
/// `VWERASE`
149-
#[cfg(not(target_os = "haiku"))]
150+
#[cfg(not(any(target_os = "aix", target_os = "haiku")))]
150151
pub const VWERASE: usize = c::VWERASE as usize;
151152

152153
/// `VLNEXT`
@@ -219,6 +220,7 @@ pub const IMAXBEL: c::c_uint = c::IMAXBEL;
219220

220221
/// `IUTF8`
221222
#[cfg(not(any(
223+
target_os = "aix",
222224
target_os = "dragonfly",
223225
target_os = "emscripten",
224226
target_os = "freebsd",
@@ -239,6 +241,7 @@ pub const OPOST: c::c_uint = c::OPOST;
239241

240242
/// `OLCUC`
241243
#[cfg(not(any(
244+
target_os = "aix",
242245
target_os = "dragonfly",
243246
target_os = "freebsd",
244247
target_os = "ios",
@@ -676,16 +679,20 @@ pub const B19200: Speed = c::B19200;
676679
pub const B38400: Speed = c::B38400;
677680

678681
/// `B57600`
682+
#[cfg(not(target_os = "aix"))]
679683
pub const B57600: Speed = c::B57600;
680684

681685
/// `B115200`
686+
#[cfg(not(target_os = "aix"))]
682687
pub const B115200: Speed = c::B115200;
683688

684689
/// `B230400`
690+
#[cfg(not(target_os = "aix"))]
685691
pub const B230400: Speed = c::B230400;
686692

687693
/// `B460800`
688694
#[cfg(not(any(
695+
target_os = "aix",
689696
target_os = "dragonfly",
690697
target_os = "haiku",
691698
target_os = "ios",
@@ -696,6 +703,7 @@ pub const B460800: Speed = c::B460800;
696703

697704
/// `B500000`
698705
#[cfg(not(any(
706+
target_os = "aix",
699707
target_os = "dragonfly",
700708
target_os = "freebsd",
701709
target_os = "haiku",
@@ -710,6 +718,7 @@ pub const B500000: Speed = c::B500000;
710718

711719
/// `B576000`
712720
#[cfg(not(any(
721+
target_os = "aix",
713722
target_os = "dragonfly",
714723
target_os = "freebsd",
715724
target_os = "haiku",
@@ -724,6 +733,7 @@ pub const B576000: Speed = c::B576000;
724733

725734
/// `B921600`
726735
#[cfg(not(any(
736+
target_os = "aix",
727737
target_os = "dragonfly",
728738
target_os = "haiku",
729739
target_os = "ios",
@@ -734,19 +744,21 @@ pub const B921600: Speed = c::B921600;
734744

735745
/// `B1000000`
736746
#[cfg(not(any(
747+
target_os = "aix",
737748
target_os = "dragonfly",
738749
target_os = "freebsd",
739750
target_os = "haiku",
740751
target_os = "ios",
741752
target_os = "macos",
742753
target_os = "netbsd",
743754
target_os = "openbsd",
744-
target_os = "solaris",
755+
target_os = "solaris"
745756
)))]
746757
pub const B1000000: Speed = c::B1000000;
747758

748759
/// `B1152000`
749760
#[cfg(not(any(
761+
target_os = "aix",
750762
target_os = "dragonfly",
751763
target_os = "freebsd",
752764
target_os = "haiku",
@@ -760,6 +772,7 @@ pub const B1152000: Speed = c::B1152000;
760772

761773
/// `B1500000`
762774
#[cfg(not(any(
775+
target_os = "aix",
763776
target_os = "dragonfly",
764777
target_os = "freebsd",
765778
target_os = "haiku",
@@ -773,6 +786,7 @@ pub const B1500000: Speed = c::B1500000;
773786

774787
/// `B2000000`
775788
#[cfg(not(any(
789+
target_os = "aix",
776790
target_os = "dragonfly",
777791
target_os = "freebsd",
778792
target_os = "haiku",
@@ -788,6 +802,7 @@ pub const B2000000: Speed = c::B2000000;
788802
#[cfg(not(any(
789803
target_arch = "sparc",
790804
target_arch = "sparc64",
805+
target_os = "aix",
791806
target_os = "dragonfly",
792807
target_os = "freebsd",
793808
target_os = "haiku",
@@ -803,6 +818,7 @@ pub const B2500000: Speed = c::B2500000;
803818
#[cfg(not(any(
804819
target_arch = "sparc",
805820
target_arch = "sparc64",
821+
target_os = "aix",
806822
target_os = "dragonfly",
807823
target_os = "freebsd",
808824
target_os = "haiku",
@@ -818,6 +834,7 @@ pub const B3000000: Speed = c::B3000000;
818834
#[cfg(not(any(
819835
target_arch = "sparc",
820836
target_arch = "sparc64",
837+
target_os = "aix",
821838
target_os = "dragonfly",
822839
target_os = "freebsd",
823840
target_os = "haiku",
@@ -833,6 +850,7 @@ pub const B3500000: Speed = c::B3500000;
833850
#[cfg(not(any(
834851
target_arch = "sparc",
835852
target_arch = "sparc64",
853+
target_os = "aix",
836854
target_os = "dragonfly",
837855
target_os = "freebsd",
838856
target_os = "haiku",
@@ -967,6 +985,7 @@ pub const CBAUD: c::c_uint = c::CBAUD;
967985

968986
/// `CBAUDEX`
969987
#[cfg(not(any(
988+
target_os = "aix",
970989
target_os = "dragonfly",
971990
target_os = "freebsd",
972991
target_os = "haiku",
@@ -1003,6 +1022,7 @@ pub const CIBAUD: c::tcflag_t = 0o77600000;
10031022

10041023
/// `CMSPAR`
10051024
#[cfg(not(any(
1025+
target_os = "aix",
10061026
target_os = "dragonfly",
10071027
target_os = "emscripten",
10081028
target_os = "freebsd",
@@ -1018,7 +1038,12 @@ pub const CIBAUD: c::tcflag_t = 0o77600000;
10181038
pub const CMSPAR: c::c_uint = c::CMSPAR;
10191039

10201040
/// `CRTSCTS`
1021-
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
1041+
#[cfg(not(any(
1042+
target_os = "aix",
1043+
target_os = "ios",
1044+
target_os = "macos",
1045+
target_os = "redox",
1046+
)))]
10221047
pub const CRTSCTS: c::c_uint = c::CRTSCTS;
10231048

10241049
/// `XCASE`
@@ -1047,6 +1072,7 @@ pub const PENDIN: c::c_uint = c::PENDIN;
10471072

10481073
/// `EXTPROC`
10491074
#[cfg(not(any(
1075+
target_os = "aix",
10501076
target_os = "haiku",
10511077
target_os = "ios",
10521078
target_os = "macos",
@@ -1056,6 +1082,7 @@ pub const EXTPROC: c::c_uint = c::EXTPROC;
10561082

10571083
/// `XTABS`
10581084
#[cfg(not(any(
1085+
target_os = "aix",
10591086
target_os = "dragonfly",
10601087
target_os = "freebsd",
10611088
target_os = "haiku",

src/io/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ mod stdio;
4040
#[cfg(any(target_os = "android", target_os = "linux"))]
4141
pub use crate::backend::io::epoll;
4242
pub use close::close;
43+
#[cfg(not(any(windows, target_os = "wasi")))]
44+
pub use dup::{dup, dup2};
4345
#[cfg(not(any(windows, target_os = "aix", target_os = "wasi")))]
44-
pub use dup::{dup, dup2, dup3, DupFlags};
46+
pub use dup::{dup3, DupFlags};
4547
pub use errno::{retry_on_intr, Errno, Result};
4648
#[cfg(any(target_os = "android", target_os = "linux"))]
4749
pub use eventfd::{eventfd, EventfdFlags};

src/termios/constants.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
2626
backend::termios::types::B9600 => Some(9600),
2727
backend::termios::types::B19200 => Some(19200),
2828
backend::termios::types::B38400 => Some(38400),
29+
#[cfg(not(target_os = "aix"))]
2930
backend::termios::types::B57600 => Some(57600),
31+
#[cfg(not(target_os = "aix"))]
3032
backend::termios::types::B115200 => Some(115_200),
33+
#[cfg(not(target_os = "aix"))]
3134
backend::termios::types::B230400 => Some(230_400),
3235
#[cfg(not(any(
36+
target_os = "aix",
3337
target_os = "dragonfly",
3438
target_os = "haiku",
3539
target_os = "ios",
@@ -38,6 +42,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
3842
)))]
3943
backend::termios::types::B460800 => Some(460_800),
4044
#[cfg(not(any(
45+
target_os = "aix",
4146
target_os = "dragonfly",
4247
target_os = "freebsd",
4348
target_os = "haiku",
@@ -50,6 +55,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
5055
)))]
5156
backend::termios::types::B500000 => Some(500_000),
5257
#[cfg(not(any(
58+
target_os = "aix",
5359
target_os = "dragonfly",
5460
target_os = "freebsd",
5561
target_os = "haiku",
@@ -62,6 +68,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
6268
)))]
6369
backend::termios::types::B576000 => Some(576_000),
6470
#[cfg(not(any(
71+
target_os = "aix",
6572
target_os = "dragonfly",
6673
target_os = "haiku",
6774
target_os = "ios",
@@ -70,6 +77,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
7077
)))]
7178
backend::termios::types::B921600 => Some(921_600),
7279
#[cfg(not(any(
80+
target_os = "aix",
7381
target_os = "dragonfly",
7482
target_os = "freebsd",
7583
target_os = "haiku",
@@ -81,6 +89,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
8189
)))]
8290
backend::termios::types::B1000000 => Some(1_000_000),
8391
#[cfg(not(any(
92+
target_os = "aix",
8493
target_os = "dragonfly",
8594
target_os = "freebsd",
8695
target_os = "haiku",
@@ -92,6 +101,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
92101
)))]
93102
backend::termios::types::B1152000 => Some(1_152_000),
94103
#[cfg(not(any(
104+
target_os = "aix",
95105
target_os = "dragonfly",
96106
target_os = "freebsd",
97107
target_os = "haiku",
@@ -103,6 +113,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
103113
)))]
104114
backend::termios::types::B1500000 => Some(1_500_000),
105115
#[cfg(not(any(
116+
target_os = "aix",
106117
target_os = "dragonfly",
107118
target_os = "freebsd",
108119
target_os = "haiku",
@@ -116,6 +127,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
116127
#[cfg(not(any(
117128
target_arch = "sparc",
118129
target_arch = "sparc64",
130+
target_os = "aix",
119131
target_os = "dragonfly",
120132
target_os = "freebsd",
121133
target_os = "haiku",
@@ -129,6 +141,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
129141
#[cfg(not(any(
130142
target_arch = "sparc",
131143
target_arch = "sparc64",
144+
target_os = "aix",
132145
target_os = "dragonfly",
133146
target_os = "freebsd",
134147
target_os = "haiku",
@@ -142,6 +155,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
142155
#[cfg(not(any(
143156
target_arch = "sparc",
144157
target_arch = "sparc64",
158+
target_os = "aix",
145159
target_os = "dragonfly",
146160
target_os = "freebsd",
147161
target_os = "haiku",
@@ -155,6 +169,7 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
155169
#[cfg(not(any(
156170
target_arch = "sparc",
157171
target_arch = "sparc64",
172+
target_os = "aix",
158173
target_os = "dragonfly",
159174
target_os = "freebsd",
160175
target_os = "haiku",

0 commit comments

Comments
 (0)