-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #1082 - IsaacWoods:core_cvoid, r=alexcrichton
Re-export core::ffi::c_void if it exists This is the second part of the implementation of [RFC 2521](rust-lang/rfcs#2521), replacing the definition of `c_void` in libc with a re-export of the type from `core::ffi::c_void` on builds it exists for. This uses the re-export for rustc version `1.31.0` or greater, as `1.30.x` was the current nightly when [the PR for the changes to libcore and libstd](rust-lang/rust#53910) was merged, so I'm assuming the first nightly they will appear in will be `1.31.0`; is this acceptable? cc rust-lang/rust#53856
- Loading branch information
Showing
4 changed files
with
70 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::env; | ||
use std::process::Command; | ||
use std::str; | ||
|
||
fn main() { | ||
/* | ||
* If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it | ||
* must define an incompatible type to retain backwards-compatibility. | ||
*/ | ||
if rustc_minor_version().expect("Failed to get rustc version") >= 31 { | ||
println!("cargo:rustc-cfg=core_cvoid"); | ||
} | ||
} | ||
|
||
fn rustc_minor_version() -> Option<u32> { | ||
macro_rules! otry { | ||
($e:expr) => { | ||
match $e { | ||
Some(e) => e, | ||
None => return None, | ||
} | ||
}; | ||
} | ||
|
||
let rustc = otry!(env::var_os("RUSTC")); | ||
let output = otry!(Command::new(rustc).arg("--version").output().ok()); | ||
let version = otry!(str::from_utf8(&output.stdout).ok()); | ||
let mut pieces = version.split('.'); | ||
|
||
if pieces.next() != Some("rustc 1") { | ||
return None; | ||
} | ||
|
||
otry!(pieces.next()).parse().ok() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters