Skip to content

Commit d08a3e8

Browse files
authored
Merge branch 'master' into utmpx_netbsd
2 parents e8106bd + 779a08b commit d08a3e8

File tree

18 files changed

+265
-37
lines changed

18 files changed

+265
-37
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libc"
3-
version = "0.2.64"
3+
version = "0.2.65"
44
authors = ["The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -28,6 +28,7 @@ std = []
2828
align = []
2929
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
3030
extra_traits = []
31+
const-extern-fn = []
3132
# use_std is deprecated, use `std` instead
3233
use_std = [ 'std' ]
3334

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Azure Status]][Azure] [![Cirrus-CI Status]][Cirrus-CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License]
1+
[![Azure Status]][Azure] [![Cirrus CI Status]][Cirrus CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License]
22

33
libc - Raw FFI bindings to platforms' system libraries
44
====
@@ -35,6 +35,9 @@ libc = "0.2"
3535
* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`.
3636
This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`.
3737

38+
* `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s.
39+
This features requires a nightly rustc
40+
3841
* **deprecated**: `use_std` is deprecated, and is equivalent to `std`.
3942

4043
## Rust version support
@@ -47,9 +50,9 @@ newer Rust features are only available on newer Rust toolchains:
4750
| `union` | 1.19.0 |
4851
| `const mem::size_of` | 1.24.0 |
4952
| `repr(align)` | 1.25.0 |
50-
| `extra_traits` | 1.25.0 |
53+
| `extra_traits` | 1.25.0 |
5154
| `core::ffi::c_void` | 1.30.0 |
52-
| `repr(packed(N))` | 1.33.0 |
55+
| `repr(packed(N))` | 1.33.0 |
5356

5457
## Platform support
5558

@@ -58,7 +61,7 @@ newer Rust features are only available on newer Rust toolchains:
5861
See
5962
[`ci/build.sh`](https://github.com/rust-lang/libc/blob/master/ci/build.sh)
6063
for the platforms on which `libc` is guaranteed to build for each Rust
61-
toolchain. The test-matrix at [Azure] and [Cirrus-CI] show the
64+
toolchain. The test-matrix at [Azure] and [Cirrus CI] show the
6265
platforms in which `libc` tests are run.
6366

6467
<div class="platform_docs"></div>
@@ -67,10 +70,10 @@ platforms in which `libc` tests are run.
6770

6871
This project is licensed under either of
6972

70-
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
73+
* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
7174
([LICENSE-APACHE](LICENSE-APACHE))
7275

73-
* [MIT License](http://opensource.org/licenses/MIT)
76+
* [MIT License](https://opensource.org/licenses/MIT)
7477
([LICENSE-MIT](LICENSE-MIT))
7578

7679
at your option.
@@ -85,16 +88,16 @@ instructions] for more information.
8588
Contributions in any form (issues, pull requests, etc.) to this project
8689
must adhere to Rust's [Code of Conduct].
8790

88-
[Code of Conduct]: https://www.rust-lang.org/en-US/conduct.html
91+
[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
8992

9093
Unless you explicitly state otherwise, any contribution intentionally submitted
9194
for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be
9295
dual licensed as above, without any additional terms or conditions.
9396

9497
[Azure Status]: https://dev.azure.com/rust-lang2/libc/_apis/build/status/rust-lang.libc?branchName=master
9598
[Azure]: https://dev.azure.com/rust-lang2/libc/_build/latest?definitionId=1&branchName=master
96-
[Cirrus-CI]: https://cirrus-ci.com/github/rust-lang/libc
97-
[Cirrus-CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg
99+
[Cirrus CI]: https://cirrus-ci.com/github/rust-lang/libc
100+
[Cirrus CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg
98101
[crates.io]: https://crates.io/crates/libc
99102
[Latest Version]: https://img.shields.io/crates/v/libc.svg
100103
[Documentation]: https://docs.rs/libc/badge.svg

build.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ use std::process::Command;
33
use std::str;
44

55
fn main() {
6-
let rustc_minor_ver =
7-
rustc_minor_version().expect("Failed to get rustc version");
6+
let (rustc_minor_ver, is_nightly) =
7+
rustc_minor_nightly().expect("Failed to get rustc version");
88
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
99
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
10+
let const_extern_fn_cargo_feature =
11+
env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
1012
let libc_ci = env::var("LIBC_CI").is_ok();
1113

1214
if env::var("CARGO_FEATURE_USE_STD").is_ok() {
@@ -72,9 +74,16 @@ fn main() {
7274
if rustc_dep_of_std {
7375
println!("cargo:rustc-cfg=libc_thread_local");
7476
}
77+
78+
if const_extern_fn_cargo_feature {
79+
if !is_nightly || rustc_minor_ver < 40 {
80+
panic!("const-extern-fn requires a nightly compiler >= 1.40")
81+
}
82+
println!("cargo:rustc-cfg=libc_const_extern_fn");
83+
}
7584
}
7685

77-
fn rustc_minor_version() -> Option<u32> {
86+
fn rustc_minor_nightly() -> Option<(u32, bool)> {
7887
macro_rules! otry {
7988
($e:expr) => {
8089
match $e {
@@ -93,7 +102,13 @@ fn rustc_minor_version() -> Option<u32> {
93102
return None;
94103
}
95104

96-
otry!(pieces.next()).parse().ok()
105+
let minor = pieces.next();
106+
let nightly_raw = otry!(otry!(pieces.next()).split('-').nth(1));
107+
let nightly =
108+
nightly_raw.starts_with("dev") || nightly_raw.starts_with("nightly");
109+
let minor = otry!(otry!(minor).parse().ok());
110+
111+
Some((minor, nightly))
97112
}
98113

99114
fn which_freebsd() -> Option<i32> {

ci/azure.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ jobs:
4646
TARGET: arm-unknown-linux-gnueabihf
4747
arm-unknown-linux-musleabihf:
4848
TARGET: arm-unknown-linux-musleabihf
49-
asmjs-unknown-emscripten:
50-
TARGET: asmjs-unknown-emscripten
49+
# Disabled because currently broken, see:
50+
# https://github.com/rust-lang/libc/issues/1591
51+
# asmjs-unknown-emscripten:
52+
# TARGET: asmjs-unknown-emscripten
5153
i686-linux-android:
5254
TARGET: i686-linux-android
5355
i686-unknown-linux-musl:
@@ -74,8 +76,10 @@ jobs:
7476
# TARGET: wasm32-wasi
7577
sparc64-unknown-linux-gnu:
7678
TARGET: sparc64-unknown-linux-gnu
77-
wasm32-unknown-emscripten:
78-
TARGET: wasm32-unknown-emscripten
79+
# Disabled because currently broken, see:
80+
# https://github.com/rust-lang/libc/issues/1591
81+
# wasm32-unknown-emscripten:
82+
# TARGET: wasm32-unknown-emscripten
7983
x86_64-linux-android:
8084
TARGET: x86_64-linux-android
8185
x86_64-unknown-linux-gnux32:
@@ -122,10 +126,12 @@ jobs:
122126
ARCH: x86_64
123127
x86_64-pc-windows-msvc:
124128
TARGET: x86_64-pc-windows-msvc
125-
i686-pc-windows-gnu:
126-
TARGET: i686-pc-windows-gnu
127-
ARCH_BITS: 32
128-
ARCH: i686
129+
# Disabled because broken:
130+
# https://github.com/rust-lang/libc/issues/1592
131+
#i686-pc-windows-gnu:
132+
# TARGET: i686-pc-windows-gnu
133+
# ARCH_BITS: 32
134+
# ARCH: i686
129135
i686-pc-windows-msvc:
130136
TARGET: i686-pc-windows-msvc
131137

ci/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ test_target() {
6767
cargo "+${RUST}" "${BUILD_CMD}" -vv $opt --no-default-features --target "${TARGET}" \
6868
--features extra_traits
6969

70+
# Test the 'const-extern-fn' feature on nightly
71+
if [ "${RUST}" = "nightly" ]; then
72+
cargo "+${RUST}" "${BUILD_CMD}" -vv $opt --no-default-features --target "${TARGET}" \
73+
--features const-extern-fn
74+
fi
75+
76+
7077
# Also test that it builds with `extra_traits` and default features:
7178
if [ "$NO_STD" != "1" ]; then
7279
cargo "+${RUST}" "${BUILD_CMD}" -vv $opt --target "${TARGET}" \

ci/docker/mips-unknown-linux-musl/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN mkdir /toolchain
88

99
# Note that this originally came from:
1010
# https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2
11-
RUN curl --retry 5 -L https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \
11+
RUN curl --retry 5 -L https://ci-mirrors.rust-lang.org/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \
1212
tar xjf - -C /toolchain --strip-components=1
1313

1414
ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \

ci/docker/mipsel-unknown-linux-musl/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN mkdir /toolchain
88

99
# Note that this originally came from:
1010
# https://downloads.openwrt.org/snapshots/trunk/malta/generic/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2
11-
RUN curl --retry 5 -L https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \
11+
RUN curl --retry 5 -L https://ci-mirrors.rust-lang.org/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \
1212
tar xjf - -C /toolchain --strip-components=2
1313

1414
ENV PATH=$PATH:/rust/bin:/toolchain/bin \

ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
set -ex
77

8-
MIRRORS_URL="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/libc"
8+
MIRRORS_URL="https://ci-mirrors.rust-lang.org/libc"
99

1010
TARGET="${1}"
1111

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ fn test_openbsd(target: &str) {
322322
"ufs/ufs/quota.h",
323323
"pthread_np.h",
324324
"sys/syscall.h",
325+
"sys/shm.h",
325326
}
326327

327328
cfg.skip_struct(move |ty| {
@@ -818,6 +819,7 @@ fn test_netbsd(target: &str) {
818819
"netinet/dccp.h",
819820
"sys/event.h",
820821
"sys/quota.h",
822+
"sys/shm.h",
821823
}
822824

823825
cfg.type_name(move |ty, is_struct, is_union| {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#![no_std]
3535
#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
3636
#![cfg_attr(target_os = "redox", feature(static_nobundle))]
37+
#![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))]
3738

3839
#[macro_use]
3940
mod macros;

0 commit comments

Comments
 (0)