Skip to content

Commit 67bf22c

Browse files
committed
Auto merge of #2526 - devnexen:sem_fbsd, r=Amanieu
freebsd sem api addition
2 parents d4ac6fd + 96fa9a6 commit 67bf22c

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

libc-test/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1845,6 +1845,7 @@ fn test_freebsd(target: &str) {
18451845
"sys/random.h",
18461846
"sys/resource.h",
18471847
"sys/rtprio.h",
1848+
"sys/sem.h",
18481849
"sys/shm.h",
18491850
"sys/socket.h",
18501851
"sys/stat.h",
@@ -2176,6 +2177,9 @@ fn test_freebsd(target: &str) {
21762177
// We ignore this field because we needed to use a hack in order to make rust 1.19
21772178
// happy...
21782179
("kinfo_proc", "ki_sparestrings") => true,
2180+
2181+
// `__sem_base` is a private struct field
2182+
("semid_ds", "__sem_base") => true,
21792183
_ => false,
21802184
}
21812185
});

libc-test/semver/freebsd.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,11 @@ sem_init
17351735
sem_open
17361736
sem_timedwait
17371737
sem_unlink
1738+
sembuf
1739+
semctl
1740+
semget
1741+
semid_ds
1742+
semop
17381743
sendfile
17391744
sendmmsg
17401745
sendmsg

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

+20
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ s! {
8787
pub struct _sem {
8888
data: [u32; 4],
8989
}
90+
pub struct sembuf {
91+
pub sem_num: ::c_ushort,
92+
pub sem_op: ::c_short,
93+
pub sem_flg: ::c_short,
94+
}
9095

9196
pub struct msqid_ds {
9297
pub msg_perm: ::ipc_perm,
@@ -445,6 +450,18 @@ s! {
445450
pub n_type: ::c_uchar,
446451
pub n_value: ::kvaddr_t,
447452
}
453+
454+
pub struct __c_anonymous_sem {
455+
_priv: ::uintptr_t,
456+
}
457+
458+
pub struct semid_ds {
459+
pub sem_perm: ::ipc_perm,
460+
pub __sem_base: *mut __c_anonymous_sem,
461+
pub sem_nsems: ::c_ushort,
462+
pub sem_otime: ::time_t,
463+
pub sem_ctime: ::time_t,
464+
}
448465
}
449466

450467
s_no_extra_traits! {
@@ -2196,6 +2213,9 @@ extern "C" {
21962213
pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void;
21972214
pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
21982215
pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int;
2216+
pub fn semget(key: ::key_t, nsems: ::c_int, semflg: ::c_int) -> ::c_int;
2217+
pub fn semctl(semid: ::c_int, semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int;
2218+
pub fn semop(semid: ::c_int, sops: *mut sembuf, nsops: ::size_t) -> ::c_int;
21992219
pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut ::msqid_ds) -> ::c_int;
22002220
pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
22012221
pub fn msgsnd(

0 commit comments

Comments
 (0)