Skip to content

Commit 9cf1a1c

Browse files
committed
reorg: Introduce a posix/unistd module
Create a module for common Posix-specified definitions in `unistd.h`, which are then reexported by relevant targets. Populate this with the `STD{IN,OUT,ERR}_FILENO` constants to start, which have posix-specified values. Link: https://pubs.opengroup.org/onlinepubs/007904975/basedefs/unistd.h.html
1 parent 91fc98c commit 9cf1a1c

File tree

65 files changed

+254
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+254
-77
lines changed

src/fuchsia/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,9 +1516,6 @@ pub const F_OK: c_int = 0;
15161516
pub const R_OK: c_int = 4;
15171517
pub const W_OK: c_int = 2;
15181518
pub const X_OK: c_int = 1;
1519-
pub const STDIN_FILENO: c_int = 0;
1520-
pub const STDOUT_FILENO: c_int = 1;
1521-
pub const STDERR_FILENO: c_int = 2;
15221519
pub const SIGHUP: c_int = 1;
15231520
pub const SIGINT: c_int = 2;
15241521
pub const SIGQUIT: c_int = 3;

src/new/aix/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
//!
33
//! * Headers are not public
44
//! * Manual pages: <https://www.ibm.com/docs/en/aix> (under "Technical reference" for that version)
5+
6+
pub(crate) mod unistd;

src/new/aix/unistd.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Header: `unistd.h`
2+
3+
pub use crate::new::common::posix::unistd::{
4+
STDERR_FILENO,
5+
STDIN_FILENO,
6+
STDOUT_FILENO,
7+
};

src/new/apple_libc/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
//! Entrypoint for Apple headers, usually found as part of the Xcode SDK.
2+
//!
3+
//! <https://github.com/apple-oss-distributions/Libc/tree/main/include>
24
35
pub(crate) mod signal;
6+
pub(crate) mod unistd;

src/new/apple_libc/unistd.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Header: `unistd.h`
2+
3+
pub use crate::new::common::posix::unistd::{
4+
STDERR_FILENO,
5+
STDIN_FILENO,
6+
STDOUT_FILENO,
7+
};

src/new/bionic_libc/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
//! <https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/include/>
44
55
pub(crate) mod sys;
6+
pub(crate) mod unistd;

src/new/bionic_libc/unistd.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Header: `unistd.h`
2+
3+
pub use crate::new::common::posix::unistd::{
4+
STDERR_FILENO,
5+
STDIN_FILENO,
6+
STDOUT_FILENO,
7+
};

src/new/common/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@
1616
target_os = "netbsd",
1717
target_os = "openbsd",
1818
))]
19-
mod bsd;
19+
pub(crate) mod bsd;
2020

2121
#[cfg(any(
2222
target_os = "android",
2323
target_os = "emscripten",
2424
target_os = "l4re",
2525
target_os = "linux",
2626
))]
27-
mod linux_like;
27+
pub(crate) mod linux_like;
2828

2929
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
30-
mod freebsd_like;
30+
pub(crate) mod freebsd_like;
3131

3232
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
33-
mod netbsd_like;
33+
pub(crate) mod netbsd_like;
3434

3535
#[cfg(any(target_os = "illumos", target_os = "solaris"))]
36-
mod solarish;
36+
pub(crate) mod solarish;
3737

38-
mod posix;
38+
#[cfg(target_family = "unix")]
39+
pub(crate) mod posix;

src/new/common/posix/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
//! POSIX APIs that are used by a number of platforms
2+
3+
pub(crate) mod unistd;

src/new/common/posix/unistd.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//! Header: `unistd.h`
2+
//!
3+
//! <https://pubs.opengroup.org/onlinepubs/007904975/basedefs/unistd.h.html>
4+
5+
use crate::prelude::*;
6+
7+
pub const STDIN_FILENO: c_int = 0;
8+
pub const STDOUT_FILENO: c_int = 1;
9+
pub const STDERR_FILENO: c_int = 2;

0 commit comments

Comments
 (0)