Skip to content

Commit bf19e3e

Browse files
committed
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]: rust-lang#2845 Co-authored-by: Josh Triplett <josh@joshtriplett.org> (apply <rust-lang#4057> to `main`) (cherry picked from commit b5b553d) As part of this update, drop the `align` feature from Cargo.toml and libc-test.
1 parent e2dd171 commit bf19e3e

Some content is hidden

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

87 files changed

+1348
-1544
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ rustc-std-workspace-core = { version = "1.0.0", optional = true }
139139
[features]
140140
default = ["std"]
141141
std = []
142-
align = []
143-
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
142+
rustc-dep-of-std = ["rustc-std-workspace-core"]
144143
extra_traits = []
145144
const-extern-fn = []
146145

libc-test/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ ctest2 = "0.4.3"
2424
[features]
2525
default = ["std"]
2626
std = ["libc/std"]
27-
align = ["libc/align"]
2827
extra_traits = ["libc/extra_traits"]
2928

3029
[[test]]

src/fuchsia/align.rs

-142
This file was deleted.

src/fuchsia/mod.rs

+132-6
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ s! {
697697
pub direction: ::__u16,
698698
pub trigger: ff_trigger,
699699
pub replay: ff_replay,
700-
// FIXME this is actually a union
700+
// FIXME(1.0): this is actually a union
701701
#[cfg(target_pointer_width = "64")]
702702
pub u: [u64; 4],
703703
#[cfg(target_pointer_width = "32")]
@@ -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

@@ -4356,9 +4487,4 @@ cfg_if! {
43564487
}
43574488
}
43584489

4359-
#[macro_use]
4360-
mod align;
4361-
4362-
expand_align!();
4363-
43644490
pub use ffi::c_void;

src/unix/align.rs

-6
This file was deleted.

src/unix/bsd/apple/b32/align.rs

-7
This file was deleted.

src/unix/bsd/apple/b32/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ s_no_extra_traits! {
5959
__sig: c_long,
6060
__opaque: [::c_char; ::__PTHREAD_ONCE_SIZE__],
6161
}
62+
63+
#[allow(missing_debug_implementations)]
64+
#[repr(align(16))]
65+
pub struct max_align_t {
66+
priv_: [f64; 2]
67+
}
6268
}
6369

6470
cfg_if! {
@@ -145,6 +151,3 @@ extern "C" {
145151
options: ::c_ulong,
146152
) -> ::c_int;
147153
}
148-
149-
mod align;
150-
pub use self::align::*;

0 commit comments

Comments
 (0)