Skip to content

Commit 0f64956

Browse files
committed
Update libc to 0.2.126
Test: cd external/rust/crates && atest --host -c Change-Id: Ic8fc77d9593a59f72653d91cc42fe99424723028
1 parent fab7930 commit 0f64956

File tree

90 files changed

+3779
-475
lines changed

Some content is hidden

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

90 files changed

+3779
-475
lines changed

.cargo_vcs_info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"git": {
3-
"sha1": "abb9b4bb0528a218f23789456d5c1aa0715cace1"
3+
"sha1": "5add164cd9beadf360dd6fdc738681e73475d14d"
44
},
55
"path_in_vcs": ""
66
}

Android.bp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ license {
3939

4040
rust_library {
4141
name: "liblibc",
42+
// has rustc warnings
4243
host_supported: true,
4344
crate_name: "libc",
4445
cargo_env_compat: true,
45-
cargo_pkg_version: "0.2.119",
46+
cargo_pkg_version: "0.2.126",
4647
srcs: ["src/lib.rs"],
4748
edition: "2015",
4849
features: [
@@ -56,10 +57,12 @@ rust_library {
5657
"libc_cfg_target_vendor",
5758
"libc_const_size_of",
5859
"libc_core_cvoid",
60+
"libc_int128",
5961
"libc_non_exhaustive",
6062
"libc_packedN",
6163
"libc_priv_mod_use",
6264
"libc_ptr_addr_of",
65+
"libc_underscore_const_names",
6366
"libc_union",
6467
],
6568
apex_available: [

Cargo.toml

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

1212
[package]
1313
name = "libc"
14-
version = "0.2.119"
14+
version = "0.2.126"
1515
authors = ["The Rust Project Developers"]
1616
build = "build.rs"
1717
exclude = [

Cargo.toml.orig

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

METADATA

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ third_party {
77
}
88
url {
99
type: ARCHIVE
10-
value: "https://static.crates.io/crates/libc/libc-0.2.119.crate"
10+
value: "https://static.crates.io/crates/libc/libc-0.2.126.crate"
1111
}
12-
version: "0.2.119"
12+
version: "0.2.126"
1313
license_type: NOTICE
1414
last_upgrade_date {
1515
year: 2022
16-
month: 3
17-
day: 1
16+
month: 5
17+
day: 18
1818
}
1919
}

build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ fn main() {
6060
println!("cargo:rustc-cfg=libc_align");
6161
}
6262

63+
// Rust >= 1.26 supports i128 and u128:
64+
if rustc_minor_ver >= 26 || rustc_dep_of_std {
65+
println!("cargo:rustc-cfg=libc_int128");
66+
}
67+
6368
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
6469
// Otherwise, it defines an incompatible type to retaining
6570
// backwards-compatibility.
@@ -82,6 +87,11 @@ fn main() {
8287
println!("cargo:rustc-cfg=libc_ptr_addr_of");
8388
}
8489

90+
// Rust >= 1.37.0 allows underscores as anonymous constant names.
91+
if rustc_minor_ver >= 37 || rustc_dep_of_std {
92+
println!("cargo:rustc-cfg=libc_underscore_const_names");
93+
}
94+
8595
// #[thread_local] is currently unstable
8696
if rustc_dep_of_std {
8797
println!("cargo:rustc-cfg=libc_thread_local");

src/fixed_width_ints.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,82 @@ pub type uint16_t = u16;
1818
pub type uint32_t = u32;
1919
#[deprecated(since = "0.2.55", note = "Use u64 instead.")]
2020
pub type uint64_t = u64;
21+
22+
cfg_if! {
23+
if #[cfg(all(libc_int128, target_arch = "aarch64", not(target_os = "windows")))] {
24+
// This introduces partial support for FFI with __int128 and
25+
// equivalent types on platforms where Rust's definition is validated
26+
// to match the standard C ABI of that platform.
27+
//
28+
// Rust does not guarantee u128/i128 are sound for FFI, and its
29+
// definitions are in fact known to be incompatible. [0]
30+
//
31+
// However these problems aren't fundamental, and are just platform
32+
// inconsistencies. Specifically at the time of this writing:
33+
//
34+
// * For x64 SysV ABIs (everything but Windows), the types are underaligned.
35+
// * For all Windows ABIs, Microsoft doesn't actually officially define __int128,
36+
// and as a result different implementations don't actually agree on its ABI.
37+
//
38+
// But on the other major aarch64 platforms (android, linux, ios, macos) we have
39+
// validated that rustc has the right ABI for these types. This is important because
40+
// aarch64 uses these types in some fundamental OS types like user_fpsimd_struct,
41+
// which represents saved simd registers.
42+
//
43+
// Any API which uses these types will need to `#[ignore(improper_ctypes)]`
44+
// until the upstream rust issue is resolved, but this at least lets us make
45+
// progress on platforms where this type is important.
46+
//
47+
// The list of supported architectures and OSes is intentionally very restricted,
48+
// as careful work needs to be done to verify that a particular platform
49+
// has a conformant ABI.
50+
//
51+
// [0]: https://github.com/rust-lang/rust/issues/54341
52+
53+
/// C `__int128` (a GCC extension that's part of many ABIs)
54+
pub type __int128 = i128;
55+
/// C `unsigned __int128` (a GCC extension that's part of many ABIs)
56+
pub type __uint128 = u128;
57+
/// C __int128_t (alternate name for [__int128][])
58+
pub type __int128_t = i128;
59+
/// C __uint128_t (alternate name for [__uint128][])
60+
pub type __uint128_t = u128;
61+
62+
cfg_if! {
63+
if #[cfg(libc_underscore_const_names)] {
64+
macro_rules! static_assert_eq {
65+
($a:expr, $b:expr) => {
66+
const _: [(); $a] = [(); $b];
67+
};
68+
}
69+
70+
// NOTE: if you add more platforms to here, you may need to cfg
71+
// these consts. They should always match the platform's values
72+
// for `sizeof(__int128)` and `_Alignof(__int128)`.
73+
const _SIZE_128: usize = 16;
74+
const _ALIGN_128: usize = 16;
75+
76+
// Since Rust doesn't officially guarantee that these types
77+
// have compatible ABIs, we const assert that these values have the
78+
// known size/align of the target platform's libc. If rustc ever
79+
// tries to regress things, it will cause a compilation error.
80+
//
81+
// This isn't a bullet-proof solution because e.g. it doesn't
82+
// catch the fact that llvm and gcc disagree on how x64 __int128
83+
// is actually *passed* on the stack (clang underaligns it for
84+
// the same reason that rustc *never* properly aligns it).
85+
static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128);
86+
static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128);
87+
88+
static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128);
89+
static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128);
90+
91+
static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128);
92+
static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128);
93+
94+
static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128);
95+
static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128);
96+
}
97+
}
98+
}
99+
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
2626
#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
2727
#![cfg_attr(
28-
any(feature = "rustc-dep-of-std", target_os = "redox"),
29-
feature(static_nobundle, native_link_modifiers, native_link_modifiers_bundle)
28+
feature = "rustc-dep-of-std",
29+
feature(native_link_modifiers, native_link_modifiers_bundle)
3030
)]
3131
#![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))]
3232

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ macro_rules! cfg_if {
6262
};
6363
}
6464

65-
#[allow(unused_macros)]
65+
#[allow(unused_macros, unused_macro_rules)]
6666
macro_rules! s {
6767
($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($(
6868
s!(it: $(#[$attr])* pub $t $i { $($field)* });

src/solid/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ extern "C" {
535535
pub fn strtod_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64;
536536
pub fn strtof_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f32;
537537
pub fn strtold_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64;
538-
pub fn _Exit(arg1: c_int);
539-
pub fn abort();
538+
pub fn _Exit(arg1: c_int) -> !;
539+
pub fn abort() -> !;
540540
pub fn abs(arg1: c_int) -> c_int;
541541
pub fn atexit(arg1: ::Option<unsafe extern "C" fn()>) -> c_int;
542542
pub fn atoi(arg1: *const c_char) -> c_int;
@@ -553,7 +553,7 @@ extern "C" {
553553
) -> *mut c_void;
554554
pub fn calloc(arg1: size_t, arg2: size_t) -> *mut c_void;
555555
pub fn div(arg1: c_int, arg2: c_int) -> div_t;
556-
pub fn exit(arg1: c_int);
556+
pub fn exit(arg1: c_int) -> !;
557557
pub fn free(arg1: *mut c_void);
558558
pub fn getenv(arg1: *const c_char) -> *mut c_char;
559559
pub fn labs(arg1: c_long) -> c_long;

0 commit comments

Comments
 (0)