Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freebsd sem api addition #2526

Merged
merged 1 commit into from Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions libc-test/build.rs
Expand Up @@ -1844,6 +1844,7 @@ fn test_freebsd(target: &str) {
"sys/random.h",
"sys/resource.h",
"sys/rtprio.h",
"sys/sem.h",
"sys/shm.h",
"sys/socket.h",
"sys/stat.h",
Expand Down Expand Up @@ -2175,6 +2176,9 @@ fn test_freebsd(target: &str) {
// We ignore this field because we needed to use a hack in order to make rust 1.19
// happy...
("kinfo_proc", "ki_sparestrings") => true,

// `__sem_base` is a private struct field
("semid_ds", "__sem_base") => true,
_ => false,
}
});
Expand Down
5 changes: 5 additions & 0 deletions libc-test/semver/freebsd.txt
Expand Up @@ -1735,6 +1735,11 @@ sem_init
sem_open
sem_timedwait
sem_unlink
sembuf
semctl
semget
semid_ds
semop
sendfile
sendmmsg
sendmsg
Expand Down
20 changes: 20 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -87,6 +87,11 @@ s! {
pub struct _sem {
data: [u32; 4],
}
pub struct sembuf {
pub sem_num: ::c_ushort,
pub sem_op: ::c_short,
pub sem_flg: ::c_short,
}

pub struct msqid_ds {
pub msg_perm: ::ipc_perm,
Expand Down Expand Up @@ -445,6 +450,18 @@ s! {
pub n_type: ::c_uchar,
pub n_value: ::kvaddr_t,
}

pub struct __c_anonymous_sem {
_priv: ::uintptr_t,
}

pub struct semid_ds {
pub sem_perm: ::ipc_perm,
pub __sem_base: *mut __c_anonymous_sem,
pub sem_nsems: ::c_ushort,
pub sem_otime: ::time_t,
pub sem_ctime: ::time_t,
}
}

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