From b0ba2de7676af63ba4c13d7184b3f630735e7e7b Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 28 Oct 2019 21:09:30 -0400 Subject: [PATCH] Add Linux test --- build.rs | 5 +++++ tests/const_fn.rs | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 tests/const_fn.rs diff --git a/build.rs b/build.rs index d5bcb525..fb1aae9b 100644 --- a/build.rs +++ b/build.rs @@ -7,6 +7,7 @@ fn main() { rustc_minor_version().expect("Failed to get rustc version"); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); + let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); if env::var("CARGO_FEATURE_USE_STD").is_ok() { @@ -72,6 +73,10 @@ fn main() { if rustc_dep_of_std { println!("cargo:rustc-cfg=libc_thread_local"); } + + if const_extern_fn_cargo_feature { + println!("cargo:rustc-cfg=libc_const_extern_fn"); + } } fn rustc_minor_version() -> Option { diff --git a/tests/const_fn.rs b/tests/const_fn.rs new file mode 100644 index 00000000..4c413c90 --- /dev/null +++ b/tests/const_fn.rs @@ -0,0 +1,5 @@ +#![cfg(libc_const_extern_fn)] // If this does not hold, the file is empty + +#[cfg(target_os = "linux")] +const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) }; +//^ if CMSG_SPACE is not const, this will fail to compile