Skip to content

Commit 5e313e8

Browse files
Require rust >= 1.25 and drop libc_align conditional
This is mostly taken from Josh's work at [1], I just updated to account for conflicts and new uses of `libc_align`. [1]: #2845 Co-authored-by: Josh Triplett <[email protected]>
1 parent 3be8fce commit 5e313e8

Some content is hidden

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

112 files changed

+1795
-2859
lines changed

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ rustc-std-workspace-core = { version = "1.0.0", optional = true }
138138
[features]
139139
default = ["std"]
140140
std = []
141-
align = []
142141
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
143142
extra_traits = []
144143
const-extern-fn = []
144+
145+
# `align` is deprecated and no longer does anything
146+
align = []
147+
145148
# use_std is deprecated, use `std` instead
146149
use_std = ['std']
147150

build.rs

-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
1414
"freebsd13",
1515
"freebsd14",
1616
"freebsd15",
17-
"libc_align",
1817
"libc_cfg_target_vendor",
1918
"libc_const_extern_fn",
2019
"libc_const_extern_fn_unstable",
@@ -51,7 +50,6 @@ fn main() {
5150

5251
let (rustc_minor_ver, is_nightly) = rustc_minor_nightly();
5352
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
54-
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
5553
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
5654
let libc_ci = env::var("LIBC_CI").is_ok();
5755
let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80;
@@ -96,11 +94,6 @@ fn main() {
9694
set_cfg("libc_deny_warnings");
9795
}
9896

99-
// Rust >= 1.25 supports repr(align):
100-
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
101-
set_cfg("libc_align");
102-
}
103-
10497
// Rust >= 1.26 supports i128 and u128:
10598
if rustc_minor_ver >= 26 || rustc_dep_of_std {
10699
set_cfg("libc_int128");

libc-test/build.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@ fn do_ctest() {
6767

6868
fn ctest_cfg() -> ctest::TestGenerator {
6969
let mut cfg = ctest::TestGenerator::new();
70-
let libc_cfgs = [
71-
"libc_align",
72-
"libc_core_cvoid",
73-
"libc_packedN",
74-
"libc_thread_local",
75-
];
70+
let libc_cfgs = ["libc_core_cvoid", "libc_packedN", "libc_thread_local"];
7671
for f in &libc_cfgs {
7772
cfg.cfg(f, None);
7873
}

src/fuchsia/align.rs

-142
This file was deleted.

src/fuchsia/mod.rs

+140-22
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,35 @@ s! {
882882
pub ipi6_addr: ::in6_addr,
883883
pub ipi6_ifindex: ::c_uint,
884884
}
885+
886+
#[cfg_attr(
887+
any(
888+
target_pointer_width = "32",
889+
target_arch = "x86_64"
890+
),
891+
repr(align(4)))]
892+
#[cfg_attr(
893+
not(any(
894+
target_pointer_width = "32",
895+
target_arch = "x86_64"
896+
)),
897+
repr(align(8)))]
898+
pub struct pthread_mutexattr_t {
899+
size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
900+
}
901+
902+
#[cfg_attr(target_pointer_width = "32",
903+
repr(align(4)))]
904+
#[cfg_attr(target_pointer_width = "64",
905+
repr(align(8)))]
906+
pub struct pthread_rwlockattr_t {
907+
size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
908+
}
909+
910+
#[repr(align(4))]
911+
pub struct pthread_condattr_t {
912+
size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
913+
}
885914
}
886915

887916
s_no_extra_traits! {
@@ -979,6 +1008,42 @@ s_no_extra_traits! {
9791008
pub sigev_notify_attributes: *mut pthread_attr_t,
9801009
pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */],
9811010
}
1011+
1012+
#[cfg_attr(all(target_pointer_width = "32",
1013+
any(target_arch = "arm",
1014+
target_arch = "x86_64")),
1015+
repr(align(4)))]
1016+
#[cfg_attr(any(target_pointer_width = "64",
1017+
not(any(target_arch = "arm",
1018+
target_arch = "x86_64"))),
1019+
repr(align(8)))]
1020+
pub struct pthread_mutex_t {
1021+
size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
1022+
}
1023+
1024+
#[cfg_attr(all(target_pointer_width = "32",
1025+
any(target_arch = "arm",
1026+
target_arch = "x86_64")),
1027+
repr(align(4)))]
1028+
#[cfg_attr(any(target_pointer_width = "64",
1029+
not(any(target_arch = "arm",
1030+
target_arch = "x86_64"))),
1031+
repr(align(8)))]
1032+
pub struct pthread_rwlock_t {
1033+
size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
1034+
}
1035+
1036+
#[cfg_attr(target_pointer_width = "32",
1037+
repr(align(4)))]
1038+
#[cfg_attr(target_pointer_width = "64",
1039+
repr(align(8)))]
1040+
#[cfg_attr(target_arch = "x86",
1041+
repr(align(4)))]
1042+
#[cfg_attr(not(target_arch = "x86"),
1043+
repr(align(8)))]
1044+
pub struct pthread_cond_t {
1045+
size: [u8; ::__SIZEOF_PTHREAD_COND_T],
1046+
}
9821047
}
9831048

9841049
cfg_if! {
@@ -1306,6 +1371,72 @@ cfg_if! {
13061371
self.sigev_notify_attributes.hash(state);
13071372
}
13081373
}
1374+
1375+
impl PartialEq for pthread_cond_t {
1376+
fn eq(&self, other: &pthread_cond_t) -> bool {
1377+
self.size
1378+
.iter()
1379+
.zip(other.size.iter())
1380+
.all(|(a,b)| a == b)
1381+
}
1382+
}
1383+
impl Eq for pthread_cond_t {}
1384+
impl ::fmt::Debug for pthread_cond_t {
1385+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1386+
f.debug_struct("pthread_cond_t")
1387+
// FIXME: .field("size", &self.size)
1388+
.finish()
1389+
}
1390+
}
1391+
impl ::hash::Hash for pthread_cond_t {
1392+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1393+
self.size.hash(state);
1394+
}
1395+
}
1396+
1397+
impl PartialEq for pthread_mutex_t {
1398+
fn eq(&self, other: &pthread_mutex_t) -> bool {
1399+
self.size
1400+
.iter()
1401+
.zip(other.size.iter())
1402+
.all(|(a,b)| a == b)
1403+
}
1404+
}
1405+
impl Eq for pthread_mutex_t {}
1406+
impl ::fmt::Debug for pthread_mutex_t {
1407+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1408+
f.debug_struct("pthread_mutex_t")
1409+
// FIXME: .field("size", &self.size)
1410+
.finish()
1411+
}
1412+
}
1413+
impl ::hash::Hash for pthread_mutex_t {
1414+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1415+
self.size.hash(state);
1416+
}
1417+
}
1418+
1419+
impl PartialEq for pthread_rwlock_t {
1420+
fn eq(&self, other: &pthread_rwlock_t) -> bool {
1421+
self.size
1422+
.iter()
1423+
.zip(other.size.iter())
1424+
.all(|(a,b)| a == b)
1425+
}
1426+
}
1427+
impl Eq for pthread_rwlock_t {}
1428+
impl ::fmt::Debug for pthread_rwlock_t {
1429+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1430+
f.debug_struct("pthread_rwlock_t")
1431+
// FIXME: .field("size", &self.size)
1432+
.finish()
1433+
}
1434+
}
1435+
impl ::hash::Hash for pthread_rwlock_t {
1436+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1437+
self.size.hash(state);
1438+
}
1439+
}
13091440
}
13101441
}
13111442

@@ -2315,17 +2446,15 @@ pub const RTLD_NOW: ::c_int = 0x2;
23152446

23162447
pub const TCP_MD5SIG: ::c_int = 14;
23172448

2318-
align_const! {
2319-
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
2320-
size: [0; __SIZEOF_PTHREAD_MUTEX_T],
2321-
};
2322-
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
2323-
size: [0; __SIZEOF_PTHREAD_COND_T],
2324-
};
2325-
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
2326-
size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
2327-
};
2328-
}
2449+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
2450+
size: [0; __SIZEOF_PTHREAD_MUTEX_T],
2451+
};
2452+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
2453+
size: [0; __SIZEOF_PTHREAD_COND_T],
2454+
};
2455+
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
2456+
size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
2457+
};
23292458
pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
23302459
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
23312460
pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
@@ -4362,17 +4491,6 @@ cfg_if! {
43624491
}
43634492
}
43644493

4365-
cfg_if! {
4366-
if #[cfg(libc_align)] {
4367-
#[macro_use]
4368-
mod align;
4369-
} else {
4370-
#[macro_use]
4371-
mod no_align;
4372-
}
4373-
}
4374-
expand_align!();
4375-
43764494
cfg_if! {
43774495
if #[cfg(libc_core_cvoid)] {
43784496
pub use ::ffi::c_void;

0 commit comments

Comments
 (0)