Skip to content

Commit a11e45e

Browse files
committed
Auto merge of #2591 - semarie:openbsd-archs, r=Amanieu
add more archs definition for openbsd it adds libc definitions for more archs for openbsd: arm, mips64, powerpc, powerpc64, and riscv64. it is a first iteration on adding support for at least some of them in rustc. I manually created them from OpenBSD source code and from clang crosscompilation output to determine type size and constants values.
2 parents 18bfd17 + 56234f6 commit a11e45e

File tree

6 files changed

+94
-7
lines changed

6 files changed

+94
-7
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pub type c_long = i32;
2+
pub type c_ulong = u32;
3+
pub type c_char = u8;
4+
5+
// should be pub(crate), but that requires Rust 1.18.0
6+
cfg_if! {
7+
if #[cfg(libc_const_size_of)] {
8+
#[doc(hidden)]
9+
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1;
10+
} else {
11+
#[doc(hidden)]
12+
pub const _ALIGNBYTES: usize = 8 - 1;
13+
}
14+
}
15+
16+
pub const _MAX_PAGE_SHIFT: u32 = 12;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pub type c_long = i64;
2+
pub type c_ulong = u64;
3+
pub type c_char = i8;
4+
5+
#[doc(hidden)]
6+
pub const _ALIGNBYTES: usize = 7;
7+
8+
pub const _MAX_PAGE_SHIFT: u32 = 14;

src/unix/bsd/netbsdlike/openbsd/mod.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,18 +1648,33 @@ cfg_if! {
16481648
}
16491649

16501650
cfg_if! {
1651-
if #[cfg(target_arch = "x86")] {
1652-
mod x86;
1653-
pub use self::x86::*;
1654-
} else if #[cfg(target_arch = "x86_64")] {
1655-
mod x86_64;
1656-
pub use self::x86_64::*;
1657-
} else if #[cfg(target_arch = "aarch64")] {
1651+
if #[cfg(target_arch = "aarch64")] {
16581652
mod aarch64;
16591653
pub use self::aarch64::*;
1654+
} else if #[cfg(target_arch = "arm")] {
1655+
mod arm;
1656+
pub use self::arm::*;
1657+
} else if #[cfg(target_arch = "mips64")] {
1658+
mod mips64;
1659+
pub use self::mips64::*;
1660+
} else if #[cfg(target_arch = "powerpc")] {
1661+
mod powerpc;
1662+
pub use self::powerpc::*;
1663+
} else if #[cfg(target_arch = "powerpc64")] {
1664+
mod powerpc64;
1665+
pub use self::powerpc64::*;
1666+
} else if #[cfg(target_arch = "riscv64")] {
1667+
mod riscv64;
1668+
pub use self::riscv64::*;
16601669
} else if #[cfg(target_arch = "sparc64")] {
16611670
mod sparc64;
16621671
pub use self::sparc64::*;
1672+
} else if #[cfg(target_arch = "x86")] {
1673+
mod x86;
1674+
pub use self::x86::*;
1675+
} else if #[cfg(target_arch = "x86_64")] {
1676+
mod x86_64;
1677+
pub use self::x86_64::*;
16631678
} else {
16641679
// Unknown target_arch
16651680
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pub type c_long = i32;
2+
pub type c_ulong = u32;
3+
pub type c_char = u8;
4+
5+
// should be pub(crate), but that requires Rust 1.18.0
6+
cfg_if! {
7+
if #[cfg(libc_const_size_of)] {
8+
#[doc(hidden)]
9+
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1;
10+
} else {
11+
#[doc(hidden)]
12+
pub const _ALIGNBYTES: usize = 8 - 1;
13+
}
14+
}
15+
16+
pub const _MAX_PAGE_SHIFT: u32 = 12;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pub type c_long = i64;
2+
pub type c_ulong = u64;
3+
pub type c_char = u8;
4+
5+
// should be pub(crate), but that requires Rust 1.18.0
6+
cfg_if! {
7+
if #[cfg(libc_const_size_of)] {
8+
#[doc(hidden)]
9+
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
10+
} else {
11+
#[doc(hidden)]
12+
pub const _ALIGNBYTES: usize = 8 - 1;
13+
}
14+
}
15+
16+
pub const _MAX_PAGE_SHIFT: u32 = 12;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pub type c_long = i64;
2+
pub type c_ulong = u64;
3+
pub type c_char = u8;
4+
5+
// should be pub(crate), but that requires Rust 1.18.0
6+
cfg_if! {
7+
if #[cfg(libc_const_size_of)] {
8+
#[doc(hidden)]
9+
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
10+
} else {
11+
#[doc(hidden)]
12+
pub const _ALIGNBYTES: usize = 8 - 1;
13+
}
14+
}
15+
16+
pub const _MAX_PAGE_SHIFT: u32 = 12;

0 commit comments

Comments
 (0)