Skip to content

Commit e98597a

Browse files
committed
Remove direct dependency on libc
1 parent dd2a4e2 commit e98597a

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ serde = { version = "1.0.117", optional = true }
2222
serde_derive = { version = "1.0.117", optional = true }
2323
cfg-if = "1.0.0"
2424

25-
[target.'cfg(not(windows))'.dependencies]
26-
libc = "0.2"
27-
2825
[target.'cfg(windows)'.dependencies]
2926
winapi = { version = "0.3.9", features = ["winnt", "winbase", "processenv", "handleapi", "ntdef", "fileapi", "std"] }
3027

src/clircle_unix.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ use crate::{Clircle, Stdio};
33
use std::convert::TryFrom;
44
use std::fs::File;
55
use std::io::{self, Seek};
6+
use std::os::fd::AsRawFd;
67
use std::os::unix::fs::MetadataExt;
78
use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd};
89
use std::{cmp, hash, ops};
910

10-
/// Re-export of libc
11-
pub use libc;
12-
1311
/// Implementation of `Clircle` for Unix.
1412
#[derive(Debug)]
1513
pub struct UnixIdentifier {
@@ -80,9 +78,9 @@ impl TryFrom<Stdio> for UnixIdentifier {
8078

8179
fn try_from(stdio: Stdio) -> Result<Self, Self::Error> {
8280
let fd = match stdio {
83-
Stdio::Stdin => libc::STDIN_FILENO,
84-
Stdio::Stdout => libc::STDOUT_FILENO,
85-
Stdio::Stderr => libc::STDERR_FILENO,
81+
Stdio::Stdin => io::stdin().as_raw_fd(),
82+
Stdio::Stdout => io::stdout().as_raw_fd(),
83+
Stdio::Stderr => io::stderr().as_raw_fd(),
8684
};
8785
// Safety: It is okay to create the file, because it won't be dropped later since the
8886
// `owns_fd` field is not set.

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
cfg_if::cfg_if! {
4848
if #[cfg(unix)] {
4949
mod clircle_unix;
50-
pub use clircle_unix::{libc, UnixIdentifier};
50+
pub use clircle_unix::UnixIdentifier;
5151
/// Identifies a file. The type is aliased according to the target platform.
5252
pub type Identifier = UnixIdentifier;
5353
} else if #[cfg(windows)] {

0 commit comments

Comments
 (0)