Skip to content

Commit 1ec4e59

Browse files
committed
Auto merge of #3437 - SteveLauC:eventfd_read, r=JohnTitor
feat: eventfd_read/write for Android/FreeBSD/Linux Add ```c int eventfd_read(int fd, eventfd_t *value); int eventfd_write(int fd, eventfd_t value); ``` for * Android * [FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=eventfd&apropos=0&sektion=2&manpath=FreeBSD+13.2-RELEASE&arch=default&format=html) * [Linux](https://man7.org/linux/man-pages/man2/eventfd.2.html)
2 parents af57553 + da88121 commit 1ec4e59

File tree

7 files changed

+22
-0
lines changed

7 files changed

+22
-0
lines changed

libc-test/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,8 @@ fn test_freebsd(target: &str) {
24172417
// the struct "__kvm" is quite tricky to bind so since we only use a pointer to it
24182418
// for now, it doesn't matter too much...
24192419
"kvm_t" => true,
2420+
// `eventfd(2)` and things come with it are added in FreeBSD 13
2421+
"eventfd_t" if Some(13) > freebsd_ver => true,
24202422

24212423
_ => false,
24222424
}
@@ -2494,6 +2496,8 @@ fn test_freebsd(target: &str) {
24942496
| "aio_readv"
24952497
| "aio_writev"
24962498
| "copy_file_range"
2499+
| "eventfd_read"
2500+
| "eventfd_write"
24972501
if Some(13) > freebsd_ver =>
24982502
{
24992503
true

libc-test/semver/android.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3756,3 +3756,5 @@ write
37563756
writev
37573757
dirname
37583758
basename
3759+
eventfd_read
3760+
eventfd_write

libc-test/semver/freebsd.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,3 +2245,5 @@ dirname
22452245
basename
22462246
closefrom
22472247
close_range
2248+
eventfd_read
2249+
eventfd_write

libc-test/semver/linux.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3842,3 +3842,5 @@ vhangup
38423842
vmsplice
38433843
wait4
38443844
waitid
3845+
eventfd_read
3846+
eventfd_write

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ pub type cpusetid_t = ::c_int;
4848

4949
pub type sctp_assoc_t = u32;
5050

51+
pub type eventfd_t = u64;
52+
5153
#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))]
5254
#[repr(u32)]
5355
pub enum devstat_support_flags {
@@ -5383,6 +5385,8 @@ extern "C" {
53835385
pub fn setaudit(auditinfo: *const auditinfo_t) -> ::c_int;
53845386

53855387
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
5388+
pub fn eventfd_read(fd: ::c_int, value: *mut eventfd_t) -> ::c_int;
5389+
pub fn eventfd_write(fd: ::c_int, value: eventfd_t) -> ::c_int;
53865390

53875391
pub fn fdatasync(fd: ::c_int) -> ::c_int;
53885392

src/unix/linux_like/android/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub type Elf64_Off = u64;
4646
pub type Elf64_Word = u32;
4747
pub type Elf64_Xword = u64;
4848

49+
pub type eventfd_t = u64;
50+
4951
s! {
5052
pub struct stack_t {
5153
pub ss_sp: *mut ::c_void,
@@ -3566,6 +3568,8 @@ extern "C" {
35663568
flags: ::c_uint,
35673569
) -> ::ssize_t;
35683570
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
3571+
pub fn eventfd_read(fd: ::c_int, value: *mut eventfd_t) -> ::c_int;
3572+
pub fn eventfd_write(fd: ::c_int, value: eventfd_t) -> ::c_int;
35693573
pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int;
35703574
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int;
35713575
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int;

src/unix/linux_like/linux/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub type iconv_t = *mut ::c_void;
5252
// linux/sctp.h
5353
pub type sctp_assoc_t = ::__s32;
5454

55+
pub type eventfd_t = u64;
5556
#[cfg_attr(feature = "extra_traits", derive(Debug))]
5657
pub enum fpos64_t {} // FIXME: fill this out with a struct
5758
impl ::Copy for fpos64_t {}
@@ -5092,6 +5093,9 @@ extern "C" {
50925093
flags: ::c_uint,
50935094
) -> ::ssize_t;
50945095
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
5096+
pub fn eventfd_read(fd: ::c_int, value: *mut eventfd_t) -> ::c_int;
5097+
pub fn eventfd_write(fd: ::c_int, value: eventfd_t) -> ::c_int;
5098+
50955099
pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int;
50965100
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int;
50975101
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)