Skip to content

Commit

Permalink
Add IN6ADDR_ANY_INIT, IN6ADDR_LOOPBACK_INIT, in6addr_any, in6addr_loo…
Browse files Browse the repository at this point in the history
…pback

(backport <rust-lang#3693>)
[ move constants to the align module to support old rustc - Trevor ]
(cherry picked from commit 8db9bc7)
  • Loading branch information
Askar Safin authored and AkhilTThomas committed Feb 5, 2025
1 parent da92ffc commit 46388e4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/unix/align.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
s! {
#[repr(align(4))]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}
}

pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr {
s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
};

pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr {
s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
};
5 changes: 5 additions & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ pub const ATF_USETRAILERS: c_int = 0x10;
pub const FNM_PERIOD: c_int = 1 << 2;
pub const FNM_NOMATCH: c_int = 1;

extern "C" {
pub static in6addr_loopback: in6_addr;
pub static in6addr_any: in6_addr;
}

cfg_if! {
if #[cfg(any(target_os = "illumos", target_os = "solaris",))] {
pub const FNM_CASEFOLD: c_int = 1 << 3;
Expand Down
16 changes: 16 additions & 0 deletions src/unix/no_align.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
s! {
pub struct in6_addr {
pub s6_addr: [u8; 16],
__align: [u32; 0],
}
}

pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr {
s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
__align: [0u32; 0],
};

pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr {
s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
__align: [0u32; 0],
};

0 comments on commit 46388e4

Please sign in to comment.