Skip to content

Commit

Permalink
Require rust >= 1.25 and drop libc_align conditional
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tgross35 committed Nov 17, 2024
1 parent e2dd171 commit 30809c5
Show file tree
Hide file tree
Showing 87 changed files with 1,348 additions and 1,544 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ rustc-std-workspace-core = { version = "1.0.0", optional = true }
[features]
default = ["std"]
std = []
align = []
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
rustc-dep-of-std = ["rustc-std-workspace-core"]
extra_traits = []
const-extern-fn = []

Expand Down
1 change: 0 additions & 1 deletion libc-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ctest2 = "0.4.3"
[features]
default = ["std"]
std = ["libc/std"]
align = ["libc/align"]
extra_traits = ["libc/extra_traits"]

[[test]]
Expand Down
142 changes: 0 additions & 142 deletions src/fuchsia/align.rs

This file was deleted.

138 changes: 132 additions & 6 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ s! {
pub direction: ::__u16,
pub trigger: ff_trigger,
pub replay: ff_replay,
// FIXME this is actually a union
// FIXME(1.0): this is actually a union
#[cfg(target_pointer_width = "64")]
pub u: [u64; 4],
#[cfg(target_pointer_width = "32")]
Expand Down Expand Up @@ -882,6 +882,35 @@ s! {
pub ipi6_addr: ::in6_addr,
pub ipi6_ifindex: ::c_uint,
}

#[cfg_attr(
any(
target_pointer_width = "32",
target_arch = "x86_64"
),
repr(align(4)))]
#[cfg_attr(
not(any(
target_pointer_width = "32",
target_arch = "x86_64"
)),
repr(align(8)))]
pub struct pthread_mutexattr_t {
size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
}

#[cfg_attr(target_pointer_width = "32",
repr(align(4)))]
#[cfg_attr(target_pointer_width = "64",
repr(align(8)))]
pub struct pthread_rwlockattr_t {
size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
}

#[repr(align(4))]
pub struct pthread_condattr_t {
size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -979,6 +1008,42 @@ s_no_extra_traits! {
pub sigev_notify_attributes: *mut pthread_attr_t,
pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */],
}

#[cfg_attr(all(target_pointer_width = "32",
any(target_arch = "arm",
target_arch = "x86_64")),
repr(align(4)))]
#[cfg_attr(any(target_pointer_width = "64",
not(any(target_arch = "arm",
target_arch = "x86_64"))),
repr(align(8)))]
pub struct pthread_mutex_t {
size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
}

#[cfg_attr(all(target_pointer_width = "32",
any(target_arch = "arm",
target_arch = "x86_64")),
repr(align(4)))]
#[cfg_attr(any(target_pointer_width = "64",
not(any(target_arch = "arm",
target_arch = "x86_64"))),
repr(align(8)))]
pub struct pthread_rwlock_t {
size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
}

#[cfg_attr(target_pointer_width = "32",
repr(align(4)))]
#[cfg_attr(target_pointer_width = "64",
repr(align(8)))]
#[cfg_attr(target_arch = "x86",
repr(align(4)))]
#[cfg_attr(not(target_arch = "x86"),
repr(align(8)))]
pub struct pthread_cond_t {
size: [u8; ::__SIZEOF_PTHREAD_COND_T],
}
}

cfg_if! {
Expand Down Expand Up @@ -1306,6 +1371,72 @@ cfg_if! {
self.sigev_notify_attributes.hash(state);
}
}

impl PartialEq for pthread_cond_t {
fn eq(&self, other: &pthread_cond_t) -> bool {
self.size
.iter()
.zip(other.size.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for pthread_cond_t {}
impl ::fmt::Debug for pthread_cond_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("pthread_cond_t")
// FIXME: .field("size", &self.size)
.finish()
}
}
impl ::hash::Hash for pthread_cond_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.size.hash(state);
}
}

impl PartialEq for pthread_mutex_t {
fn eq(&self, other: &pthread_mutex_t) -> bool {
self.size
.iter()
.zip(other.size.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for pthread_mutex_t {}
impl ::fmt::Debug for pthread_mutex_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("pthread_mutex_t")
// FIXME: .field("size", &self.size)
.finish()
}
}
impl ::hash::Hash for pthread_mutex_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.size.hash(state);
}
}

impl PartialEq for pthread_rwlock_t {
fn eq(&self, other: &pthread_rwlock_t) -> bool {
self.size
.iter()
.zip(other.size.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for pthread_rwlock_t {}
impl ::fmt::Debug for pthread_rwlock_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("pthread_rwlock_t")
// FIXME: .field("size", &self.size)
.finish()
}
}
impl ::hash::Hash for pthread_rwlock_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.size.hash(state);
}
}
}
}

Expand Down Expand Up @@ -4356,9 +4487,4 @@ cfg_if! {
}
}

#[macro_use]
mod align;

expand_align!();

pub use ffi::c_void;
6 changes: 0 additions & 6 deletions src/unix/align.rs

This file was deleted.

7 changes: 0 additions & 7 deletions src/unix/bsd/apple/b32/align.rs

This file was deleted.

9 changes: 6 additions & 3 deletions src/unix/bsd/apple/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ s_no_extra_traits! {
__sig: c_long,
__opaque: [::c_char; ::__PTHREAD_ONCE_SIZE__],
}

#[allow(missing_debug_implementations)]
#[repr(align(16))]
pub struct max_align_t {
priv_: [f64; 2]
}
}

cfg_if! {
Expand Down Expand Up @@ -145,6 +151,3 @@ extern "C" {
options: ::c_ulong,
) -> ::c_int;
}

mod align;
pub use self::align::*;
Loading

0 comments on commit 30809c5

Please sign in to comment.