milestone1

This commit is contained in:
2026-05-07 04:35:57 +01:00
parent b9698beceb
commit be17bbc9bc
37 changed files with 973 additions and 317 deletions
@@ -0,0 +1,35 @@
--- a/src/header/sys_eventfd/mod.rs
+++ b/src/header/sys_eventfd/mod.rs
@@ -5,6 +5,7 @@
use crate::c_str::{CStr, CString};
use crate::error::{Errno, ResultExt};
use crate::header::fcntl::{O_CLOEXEC, O_NONBLOCK, O_RDWR};
+use crate::header::errno::EFAULT;
use crate::header::errno::EINVAL;
use crate::platform::{Pal, Sys, types::{c_int, c_uint}};
@@ -35,3 +36,24 @@
}
Sys::open(CStr::borrow(&cpath), oflag, 0).or_minus_one_errno()
}
+
+#[unsafe(no_mangle)]
+pub extern "C" fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int {
+ if value.is_null() {
+ return Err::<c_int, _>(Errno(EFAULT)).or_minus_one_errno();
+ }
+ let mut buf = [0u8; 8];
+ match Sys::read(fd, &mut buf) {
+ Ok(8) => { unsafe { *value = u64::from_ne_bytes(buf); } 0 }
+ _ => -1,
+ }
+}
+
+#[unsafe(no_mangle)]
+pub extern "C" fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int {
+ let buf = value.to_ne_bytes();
+ match Sys::write(fd, &buf) {
+ Ok(8) => 0,
+ _ => -1,
+ }
+}