Skip to content

Commit 5469e06

Browse files
committed
Add alignment feature and use #[repr(align(x))]
1 parent 72b16d2 commit 5469e06

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ appveyor = { repository = "rust-lang/libc", project_name = "rust-lang-libs/libc"
2020
[features]
2121
default = ["use_std"]
2222
use_std = []
23+
align = []
2324

2425
[workspace]
2526
members = ["libc-test"]

src/fuchsia/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ s! {
166166
pub s_addr: in_addr_t,
167167
}
168168

169+
#[cfg_attr(feature = "align", repr(align(4)))]
169170
pub struct in6_addr {
170171
pub s6_addr: [u8; 16],
172+
#[cfg(not(feature = "align"))]
171173
__align: [u32; 0],
172174
}
173175

src/redox/net.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ s! {
99
pub s_addr: in_addr_t,
1010
}
1111

12+
#[cfg_attr(feature = "align", repr(align(4)))]
1213
pub struct in6_addr {
1314
pub s6_addr: [u8; 16],
15+
#[cfg(not(feature = "align"))]
1416
__align: [u32; 0],
1517
}
1618

src/unix/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ s! {
104104
pub s_addr: in_addr_t,
105105
}
106106

107+
#[cfg_attr(feature = "align", repr(align(4)))]
107108
pub struct in6_addr {
108109
pub s6_addr: [u8; 16],
110+
#[cfg(not(feature = "align"))]
109111
__align: [u32; 0],
110112
}
111113

0 commit comments

Comments
 (0)