Skip to content

Commit fda5722

Browse files
committed
Auto merge of #2255 - devnexen:pthread_barrier_fbsd, r=JohnTitor
freebsd/dragonfly adding pthread barrier api.
2 parents 2c94600 + 5b7b4f9 commit fda5722

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,8 @@ fn test_freebsd(target: &str) {
20062006

20072007
// m_owner field is a volatile __lwpid_t
20082008
("umutex", "m_owner") => true,
2009+
// c_has_waiters field is a volatile int32_t
2010+
("ucond", "c_has_waiters") => true,
20092011

20102012
_ => false,
20112013
}

libc-test/semver/dragonfly.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,13 @@ pseudo_AF_XTP
12941294
pthread_attr_get_np
12951295
pthread_attr_getguardsize
12961296
pthread_attr_getstack
1297+
pthread_barrierattr_destroy
1298+
pthread_barrierattr_getpshared
1299+
pthread_barrierattr_init
1300+
pthread_barrierattr_setpshared
1301+
pthread_barrierattr_t
1302+
pthread_barrier_destroy
1303+
pthread_barrier_init
12971304
pthread_cancel
12981305
pthread_condattr_getclock
12991306
pthread_condattr_getpshared

libc-test/semver/freebsd.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,14 @@ pseudo_AF_XTP
15421542
pthread_attr_get_np
15431543
pthread_attr_getguardsize
15441544
pthread_attr_getstack
1545+
pthread_barrierattr_destroy
1546+
pthread_barrierattr_getpshared
1547+
pthread_barrierattr_init
1548+
pthread_barrierattr_setpshared
1549+
pthread_barrierattr_t
1550+
pthread_barrier_destroy
1551+
pthread_barrier_init
1552+
pthread_barrier_wait
15451553
pthread_cancel
15461554
pthread_condattr_getclock
15471555
pthread_condattr_getpshared

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub type cpu_set_t = cpumask_t;
2727

2828
pub type register_t = ::c_long;
2929
pub type umtx_t = ::c_int;
30+
pub type pthread_barrierattr_t = ::c_int;
31+
pub type pthread_barrier_t = ::uintptr_t;
3032
pub type pthread_spinlock_t = ::uintptr_t;
3133

3234
#[cfg_attr(feature = "extra_traits", derive(Debug))]

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub type posix_spawnattr_t = *mut ::c_void;
2222
pub type posix_spawn_file_actions_t = *mut ::c_void;
2323

2424
pub type pthread_spinlock_t = *mut __c_anonymous_pthread_spinlock;
25+
pub type pthread_barrierattr_t = *mut __c_anonymous_pthread_barrierattr;
26+
pub type pthread_barrier_t = *mut __c_anonymous_pthread_barrier;
2527

2628
s! {
2729
pub struct aiocb {
@@ -154,9 +156,30 @@ s! {
154156

155157
}
156158

159+
pub struct ucond {
160+
c_has_waiters: u32,
161+
c_flags: u32,
162+
c_clockid: u32,
163+
c_spare: [u32; 1],
164+
}
165+
157166
pub struct __c_anonymous_pthread_spinlock {
158167
s_clock: umutex,
159168
}
169+
170+
pub struct __c_anonymous_pthread_barrierattr {
171+
pshared: ::c_int,
172+
}
173+
174+
pub struct __c_anonymous_pthread_barrier {
175+
b_lock: umutex,
176+
b_cv: ucond,
177+
b_cycle: i64,
178+
b_count: ::c_int,
179+
b_waiters: ::c_int,
180+
b_refcount: ::c_int,
181+
b_destroying: ::c_int,
182+
}
160183
}
161184

162185
s_no_extra_traits! {

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,23 @@ extern "C" {
15131513
val: *mut ::c_int,
15141514
) -> ::c_int;
15151515
pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: ::c_int) -> ::c_int;
1516+
pub fn pthread_barrierattr_init(attr: *mut ::pthread_barrierattr_t) -> ::c_int;
1517+
pub fn pthread_barrierattr_destroy(attr: *mut ::pthread_barrierattr_t) -> ::c_int;
1518+
pub fn pthread_barrierattr_getpshared(
1519+
attr: *const ::pthread_barrierattr_t,
1520+
shared: *mut ::c_int,
1521+
) -> ::c_int;
1522+
pub fn pthread_barrierattr_setpshared(
1523+
attr: *mut ::pthread_barrierattr_t,
1524+
shared: ::c_int,
1525+
) -> ::c_int;
1526+
pub fn pthread_barrier_init(
1527+
barrier: *mut pthread_barrier_t,
1528+
attr: *const ::pthread_barrierattr_t,
1529+
count: ::c_uint,
1530+
) -> ::c_int;
1531+
pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> ::c_int;
1532+
pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> ::c_int;
15161533
pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
15171534
pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_char, data: ::c_int) -> ::c_int;
15181535
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;

0 commit comments

Comments
 (0)