Skip to content

Commit 9525816

Browse files
committed
Auto merge of #1108 - jakllsch:netbsd-pthread-types, r=alexcrichton
NetBSD: fix pthread types on arm and powerpc
2 parents 87ea744 + 7cd5d11 commit 9525816

File tree

8 files changed

+26
-8
lines changed

8 files changed

+26
-8
lines changed

ci/style.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
128128
err.error(path, i, "use `extern` instead of `extern \"C\"");
129129
}
130130
if line.contains("#[cfg(") && !line.contains(" if ")
131-
&& !line.contains("target_endian")
131+
&& !(line.contains("target_endian") ||
132+
line.contains("target_arch"))
132133
{
133134
if state != State::Structs {
134135
err.error(path, i, "use cfg_if! and submodules \

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+
pub 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: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +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+
type __pthread_spin_t = __cpu_simple_lock_nv_t;
1112

1213
s! {
1314
pub struct aiocb {
@@ -160,9 +161,14 @@ s! {
160161

161162
pub struct pthread_mutex_t {
162163
ptm_magic: ::c_uint,
163-
ptm_errorcheck: ::c_uchar,
164+
ptm_errorcheck: __pthread_spin_t,
165+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
166+
target_arch = "x86", target_arch = "x86_64"))]
164167
ptm_pad1: [u8; 3],
165-
ptm_interlock: ::c_uchar,
168+
// actually a union with a non-unused, 0-initialized field
169+
ptm_unused: __pthread_spin_t,
170+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
171+
target_arch = "x86", target_arch = "x86_64"))]
166172
ptm_pad2: [u8; 3],
167173
ptm_owner: ::pthread_t,
168174
ptm_waiters: *mut u8,
@@ -182,7 +188,7 @@ s! {
182188

183189
pub struct pthread_cond_t {
184190
ptc_magic: ::c_uint,
185-
ptc_lock: ::c_uchar,
191+
ptc_lock: __pthread_spin_t,
186192
ptc_waiters_first: *mut u8,
187193
ptc_waiters_last: *mut u8,
188194
ptc_mutex: *mut ::pthread_mutex_t,
@@ -196,7 +202,7 @@ s! {
196202

197203
pub struct pthread_rwlock_t {
198204
ptr_magic: ::c_uint,
199-
ptr_interlock: ::c_uchar,
205+
ptr_interlock: __pthread_spin_t,
200206
ptr_rblocked_first: *mut u8,
201207
ptr_rblocked_last: *mut u8,
202208
ptr_wblocked_first: *mut u8,
@@ -698,14 +704,19 @@ pub const ST_NOSUID: ::c_ulong = 8;
698704
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
699705
ptm_magic: 0x33330003,
700706
ptm_errorcheck: 0,
701-
ptm_interlock: 0,
702-
ptm_waiters: 0 as *mut _,
703-
ptm_owner: 0,
707+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
708+
target_arch = "x86", target_arch = "x86_64"))]
704709
ptm_pad1: [0; 3],
710+
ptm_unused: 0,
711+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64",
712+
target_arch = "x86", target_arch = "x86_64"))]
705713
ptm_pad2: [0; 3],
714+
ptm_waiters: 0 as *mut _,
715+
ptm_owner: 0,
706716
ptm_recursed: 0,
707717
ptm_spare2: 0 as *mut _,
708718
};
719+
709720
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
710721
ptc_magic: 0x55550005,
711722
ptc_lock: 0,

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+
pub 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+
pub type __cpu_simple_lock_nv_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+
pub 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+
pub 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)