Skip to content

Commit 6346e17

Browse files
committed
NetBSD: fix pthread types on arm and powerpc
Also while here: fix powerpc64, mips, and mips64 pthread types. These targets are not yet fully/correctly implemented in rust-libc however.
1 parent 17f7b55 commit 6346e17

File tree

1 file changed

+50
-15
lines changed
  • src/unix/bsd/netbsdlike/netbsd

1 file changed

+50
-15
lines changed

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

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ pub type fsfilcnt_t = ::uint64_t;
99
pub type idtype_t = ::c_int;
1010
pub type mqd_t = ::c_int;
1111

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+
}
26+
1227
s! {
1328
pub struct aiocb {
1429
pub aio_offset: ::off_t,
@@ -160,9 +175,13 @@ s! {
160175

161176
pub struct pthread_mutex_t {
162177
ptm_magic: ::c_uint,
163-
ptm_errorcheck: ::c_uchar,
178+
ptm_errorcheck: __cpu_simple_lock_t,
179+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
180+
target_arch = "x86", target_arch = "x86_64"))]
164181
ptm_pad1: [u8; 3],
165-
ptm_interlock: ::c_uchar,
182+
ptm_interlock: __cpu_simple_lock_t,
183+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
184+
target_arch = "x86", target_arch = "x86_64"))]
166185
ptm_pad2: [u8; 3],
167186
ptm_owner: ::pthread_t,
168187
ptm_waiters: *mut u8,
@@ -182,7 +201,7 @@ s! {
182201

183202
pub struct pthread_cond_t {
184203
ptc_magic: ::c_uint,
185-
ptc_lock: ::c_uchar,
204+
ptc_lock: __cpu_simple_lock_t,
186205
ptc_waiters_first: *mut u8,
187206
ptc_waiters_last: *mut u8,
188207
ptc_mutex: *mut ::pthread_mutex_t,
@@ -196,7 +215,7 @@ s! {
196215

197216
pub struct pthread_rwlock_t {
198217
ptr_magic: ::c_uint,
199-
ptr_interlock: ::c_uchar,
218+
ptr_interlock: __cpu_simple_lock_t,
200219
ptr_rblocked_first: *mut u8,
201220
ptr_rblocked_last: *mut u8,
202221
ptr_wblocked_first: *mut u8,
@@ -692,17 +711,33 @@ pub const FD_SETSIZE: usize = 0x100;
692711

693712
pub const ST_NOSUID: ::c_ulong = 8;
694713

695-
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
696-
ptm_magic: 0x33330003,
697-
ptm_errorcheck: 0,
698-
ptm_interlock: 0,
699-
ptm_waiters: 0 as *mut _,
700-
ptm_owner: 0,
701-
ptm_pad1: [0; 3],
702-
ptm_pad2: [0; 3],
703-
ptm_recursed: 0,
704-
ptm_spare2: 0 as *mut _,
705-
};
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+
}
740+
706741
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
707742
ptc_magic: 0x55550005,
708743
ptc_lock: 0,

0 commit comments

Comments
 (0)