Skip to content

Commit 5cca062

Browse files
committed
NetBSD: rework recent pthread type corrections to avoid cfg_if!
1 parent a81f45e commit 5cca062

File tree

7 files changed

+26
-45
lines changed

7 files changed

+26
-45
lines changed

src/unix/bsd/netbsdlike/netbsd/aarch64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use PT_FIRSTMACH;
33
pub type c_long = i64;
44
pub type c_ulong = u64;
55
pub type c_char = u8;
6+
pub type __cpu_simple_lock_nv_t = ::c_uchar;
67

78
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0;
89
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1;

src/unix/bsd/netbsdlike/netbsd/arm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use PT_FIRSTMACH;
33
pub type c_long = i32;
44
pub type c_ulong = u32;
55
pub type c_char = u8;
6+
type __cpu_simple_lock_nv_t = ::c_int;
67

78
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
89
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2;

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

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,7 @@ pub type fsblkcnt_t = ::uint64_t;
88
pub type fsfilcnt_t = ::uint64_t;
99
pub type idtype_t = ::c_int;
1010
pub type mqd_t = ::c_int;
11-
12-
cfg_if! {
13-
if #[cfg(any(target_arch = "aarch64",
14-
target_arch = "sparc", target_arch = "sparc64",
15-
target_arch = "x86", target_arch = "x86_64"))] {
16-
type __cpu_simple_lock_t = ::c_uchar;
17-
} else if #[cfg(any(target_arch = "arm", target_arch = "powerpc",
18-
target_arch = "powerpc64"))] {
19-
type __cpu_simple_lock_t = ::c_int;
20-
} else if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] {
21-
type __cpu_simple_lock_t = ::c_uint;
22-
} else {
23-
// Unknown target_arch
24-
}
25-
}
11+
type __pthread_spin_t = __cpu_simple_lock_nv_t;
2612

2713
s! {
2814
pub struct aiocb {
@@ -175,11 +161,11 @@ s! {
175161

176162
pub struct pthread_mutex_t {
177163
ptm_magic: ::c_uint,
178-
ptm_errorcheck: __cpu_simple_lock_t,
164+
ptm_errorcheck: __pthread_spin_t,
179165
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
180166
target_arch = "x86", target_arch = "x86_64"))]
181167
ptm_pad1: [u8; 3],
182-
ptm_interlock: __cpu_simple_lock_t,
168+
ptm_unused: __pthread_spin_t, // actually a union with a non-unused, 0-initialized field
183169
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
184170
target_arch = "x86", target_arch = "x86_64"))]
185171
ptm_pad2: [u8; 3],
@@ -201,7 +187,7 @@ s! {
201187

202188
pub struct pthread_cond_t {
203189
ptc_magic: ::c_uint,
204-
ptc_lock: __cpu_simple_lock_t,
190+
ptc_lock: __pthread_spin_t,
205191
ptc_waiters_first: *mut u8,
206192
ptc_waiters_last: *mut u8,
207193
ptc_mutex: *mut ::pthread_mutex_t,
@@ -215,7 +201,7 @@ s! {
215201

216202
pub struct pthread_rwlock_t {
217203
ptr_magic: ::c_uint,
218-
ptr_interlock: __cpu_simple_lock_t,
204+
ptr_interlock: __pthread_spin_t,
219205
ptr_rblocked_first: *mut u8,
220206
ptr_rblocked_last: *mut u8,
221207
ptr_wblocked_first: *mut u8,
@@ -711,32 +697,21 @@ pub const FD_SETSIZE: usize = 0x100;
711697

712698
pub const ST_NOSUID: ::c_ulong = 8;
713699

714-
cfg_if! {
715-
if #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
716-
target_arch = "x86", target_arch = "x86_64"))] {
717-
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
718-
ptm_magic: 0x33330003,
719-
ptm_errorcheck: 0,
720-
ptm_interlock: 0,
721-
ptm_waiters: 0 as *mut _,
722-
ptm_owner: 0,
723-
ptm_pad1: [0; 3],
724-
ptm_pad2: [0; 3],
725-
ptm_recursed: 0,
726-
ptm_spare2: 0 as *mut _,
727-
};
728-
} else {
729-
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
730-
ptm_magic: 0x33330003,
731-
ptm_errorcheck: 0,
732-
ptm_interlock: 0,
733-
ptm_waiters: 0 as *mut _,
734-
ptm_owner: 0,
735-
ptm_recursed: 0,
736-
ptm_spare2: 0 as *mut _,
737-
};
738-
}
739-
}
700+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
701+
ptm_magic: 0x33330003,
702+
ptm_errorcheck: 0,
703+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
704+
target_arch = "x86", target_arch = "x86_64"))]
705+
ptm_pad1: [0; 3],
706+
ptm_unused: 0,
707+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
708+
target_arch = "x86", target_arch = "x86_64"))]
709+
ptm_pad2: [0; 3],
710+
ptm_waiters: 0 as *mut _,
711+
ptm_owner: 0,
712+
ptm_recursed: 0,
713+
ptm_spare2: 0 as *mut _,
714+
};
740715

741716
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
742717
ptc_magic: 0x55550005,

src/unix/bsd/netbsdlike/netbsd/powerpc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use PT_FIRSTMACH;
33
pub type c_long = i32;
44
pub type c_ulong = u32;
55
pub type c_char = u8;
6+
type __cpu_simple_lock_nv_t = ::c_int;
67

78
pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0;
89
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub type c_long = i64;
22
pub type c_ulong = u64;
33
pub type c_char = i8;
4+
type __cpu_simple_lock_t = ::c_uchar;

src/unix/bsd/netbsdlike/netbsd/x86.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub type c_long = i32;
22
pub type c_ulong = u32;
33
pub type c_char = i8;
4+
type __cpu_simple_lock_nv_t = ::c_uchar;

src/unix/bsd/netbsdlike/netbsd/x86_64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use PT_FIRSTMACH;
33
pub type c_long = i64;
44
pub type c_ulong = u64;
55
pub type c_char = i8;
6+
type __cpu_simple_lock_nv_t = ::c_uchar;
67

78
pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0;
89
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;

0 commit comments

Comments
 (0)