Skip to content

Commit

Permalink
add mips32r6 target_arch detection for linux gnu targets
Browse files Browse the repository at this point in the history
  • Loading branch information
chenx97 committed Jun 25, 2023
1 parent 7bb91d4 commit a0a798b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build.rs
Expand Up @@ -34,7 +34,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
("target_os", &["switch", "aix", "ohos"]),
("target_env", &["illumos", "wasi", "aix", "ohos"]),
("target_arch", &["loongarch64", "mips64r6"]),
("target_arch", &["loongarch64", "mips32r6", "mips64r6"]),
];

fn main() {
Expand Down
6 changes: 6 additions & 0 deletions src/unix/linux_like/linux/align.rs
Expand Up @@ -85,6 +85,7 @@ macro_rules! expand_align {

#[cfg_attr(all(target_pointer_width = "32",
any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
Expand All @@ -95,6 +96,7 @@ macro_rules! expand_align {
repr(align(4)))]
#[cfg_attr(any(target_pointer_width = "64",
not(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
Expand All @@ -110,6 +112,7 @@ macro_rules! expand_align {

#[cfg_attr(all(target_pointer_width = "32",
any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
Expand All @@ -120,6 +123,7 @@ macro_rules! expand_align {
repr(align(4)))]
#[cfg_attr(any(target_pointer_width = "64",
not(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
Expand All @@ -134,6 +138,7 @@ macro_rules! expand_align {

#[cfg_attr(all(target_pointer_width = "32",
any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
Expand All @@ -144,6 +149,7 @@ macro_rules! expand_align {
repr(align(4)))]
#[cfg_attr(any(target_pointer_width = "64",
not(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux_like/linux/arch/mips/mod.rs
Expand Up @@ -280,7 +280,7 @@ cfg_if! {
}

cfg_if! {
if #[cfg(target_arch = "mips",
if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"),
any(target_env = "gnu",
target_env = "uclibc"))] {
pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
Expand Down
5 changes: 4 additions & 1 deletion src/unix/linux_like/linux/arch/mod.rs
@@ -1,5 +1,8 @@
cfg_if! {
if #[cfg(any(target_arch = "mips", target_arch = "mips64", target_arch = "mips64r6"))] {
if #[cfg(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"))] {
mod mips;
pub use self::mips::*;
} else if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] {
Expand Down
38 changes: 19 additions & 19 deletions src/unix/linux_like/linux/gnu/b32/mod.rs
Expand Up @@ -43,50 +43,50 @@ cfg_if! {

s! {
pub struct stat {
#[cfg(not(target_arch = "mips"))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
pub st_dev: ::dev_t,
#[cfg(target_arch = "mips")]
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
pub st_dev: ::c_ulong,

#[cfg(not(target_arch = "mips"))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
__pad1: ::c_short,
#[cfg(target_arch = "mips")]
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
st_pad1: [::c_long; 3],
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
#[cfg(not(target_arch = "mips"))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
pub st_rdev: ::dev_t,
#[cfg(target_arch = "mips")]
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
pub st_rdev: ::c_ulong,
#[cfg(not(target_arch = "mips"))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
__pad2: ::c_short,
#[cfg(target_arch = "mips")]
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
st_pad2: [::c_long; 2],
pub st_size: ::off_t,
#[cfg(target_arch = "mips")]
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
st_pad3: ::c_long,
#[cfg(not(target_arch = "mips"))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
pub st_blksize: ::blksize_t,
#[cfg(not(target_arch = "mips"))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
pub st_blocks: ::blkcnt_t,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
#[cfg(not(target_arch = "mips"))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
__unused4: ::c_long,
#[cfg(not(target_arch = "mips"))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))]
__unused5: ::c_long,
#[cfg(target_arch = "mips")]
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
pub st_blksize: ::blksize_t,
#[cfg(target_arch = "mips")]
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
pub st_blocks: ::blkcnt_t,
#[cfg(target_arch = "mips")]
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
st_pad5: [::c_long; 14],
}

Expand Down Expand Up @@ -140,12 +140,12 @@ s! {
#[cfg(target_arch = "powerpc")]
__reserved: ::__syscall_ulong_t,
pub sem_otime: ::time_t,
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6", target_arch = "powerpc")))]
__reserved: ::__syscall_ulong_t,
#[cfg(target_arch = "powerpc")]
__reserved2: ::__syscall_ulong_t,
pub sem_ctime: ::time_t,
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6", target_arch = "powerpc")))]
__reserved2: ::__syscall_ulong_t,
pub sem_nsems: ::__syscall_ulong_t,
__glibc_reserved3: ::__syscall_ulong_t,
Expand Down Expand Up @@ -337,7 +337,7 @@ cfg_if! {
} else if #[cfg(target_arch = "arm")] {
mod arm;
pub use self::arm::*;
} else if #[cfg(target_arch = "mips")] {
} else if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] {
mod mips;
pub use self::mips::*;
} else if #[cfg(target_arch = "m68k")] {
Expand Down
8 changes: 7 additions & 1 deletion src/unix/linux_like/linux/gnu/mod.rs
Expand Up @@ -116,13 +116,15 @@ s! {
target_arch = "sparc",
target_arch = "sparc64",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6")))]
pub c_ispeed: ::speed_t,
#[cfg(not(any(
target_arch = "sparc",
target_arch = "sparc64",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6")))]
pub c_ospeed: ::speed_t,
Expand Down Expand Up @@ -956,7 +958,10 @@ pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02;
pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04;
pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08;
cfg_if! {
if #[cfg(not(any(target_arch="mips", target_arch="mips64", target_arch = "mips64r6")))] {
if #[cfg(not(any(target_arch="mips",
target_arch="mips32r6",
target_arch="mips64",
target_arch = "mips64r6")))] {
pub const KEYCTL_MOVE: u32 = 30;
pub const KEYCTL_CAPABILITIES: u32 = 31;

Expand Down Expand Up @@ -1381,6 +1386,7 @@ cfg_if! {
target_arch = "arm",
target_arch = "m68k",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "powerpc",
target_arch = "sparc",
target_arch = "riscv32"))] {
Expand Down
6 changes: 6 additions & 0 deletions src/unix/linux_like/linux/no_align.rs
Expand Up @@ -70,6 +70,7 @@ macro_rules! expand_align {

pub struct pthread_mutex_t {
#[cfg(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "m68k",
target_arch = "powerpc",
Expand All @@ -78,6 +79,7 @@ macro_rules! expand_align {
target_pointer_width = "32")))]
__align: [::c_long; 0],
#[cfg(not(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "m68k",
target_arch = "powerpc",
Expand All @@ -90,6 +92,7 @@ macro_rules! expand_align {

pub struct pthread_rwlock_t {
#[cfg(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "m68k",
target_arch = "powerpc",
Expand All @@ -98,6 +101,7 @@ macro_rules! expand_align {
target_pointer_width = "32")))]
__align: [::c_long; 0],
#[cfg(not(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "m68k",
target_arch = "powerpc",
Expand All @@ -110,6 +114,7 @@ macro_rules! expand_align {

pub struct pthread_barrier_t {
#[cfg(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "m68k",
target_arch = "powerpc",
Expand All @@ -118,6 +123,7 @@ macro_rules! expand_align {
target_pointer_width = "32")))]
__align: [::c_long; 0],
#[cfg(not(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "m68k",
target_arch = "powerpc",
Expand Down

0 comments on commit a0a798b

Please sign in to comment.