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 tgross35 committed Aug 28, 2024
1 parent f9aa12d commit 5320268
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libc-test/semver/unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ IF_NAMESIZE
IGNBRK
IGNCR
IGNPAR
IN6ADDR_ANY_INIT
IN6ADDR_LOOPBACK_INIT
INADDR_ANY
INADDR_BROADCAST
INADDR_LOOPBACK
Expand Down Expand Up @@ -586,6 +588,8 @@ hstrerror
if_indextoname
if_nametoindex
in6_addr
in6addr_any
in6addr_loopback
in_addr
in_addr_t
in_port_t
Expand Down
8 changes: 8 additions & 0 deletions src/unix/align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ s! {
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 @@ -313,6 +313,11 @@ pub const ATF_PERM: ::c_int = 0x04;
pub const ATF_PUBL: ::c_int = 0x08;
pub const ATF_USETRAILERS: ::c_int = 0x10;

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

cfg_if! {
if #[cfg(any(target_os = "l4re", target_os = "espidf"))] {
// required libraries for L4Re and the ESP-IDF framework are linked externally, ATM
Expand Down
10 changes: 10 additions & 0 deletions src/unix/no_align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ s! {
__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: [u32; 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: [u32; 0],
};

0 comments on commit 5320268

Please sign in to comment.